astro-link-previews

This integration provides a single component, that is able to display previews/embeds for most existing websites.

It is powered by https://microlink.io/ which provides 50 free and unauthanticated API calls per day. This integration caches resolved URLs to speed up SSG. If you like their service / need more, please subscribe to one of their plans. This integration isn't affiliated to them.

In contrast to microlinks SDK, this integration is a bit more opniated, aims to ship zero JS to the client, is GDPR-compliant whenever you use the small or normal variant and supports a 2-click variant for GDPR-complient rich embeds.

Installation

For external images to be downloaded while building, instead of remote loading by the client (and thus being more GDPR compliant), you need to add the following to your astr.config.js. The components will work even without this though.

image: { remotePatterns: [{ protocol: "https" }] },

You can find more info about that in astros docs.

Usage

Previews

Small size previews

<Card size="small" url="https://github.com/microlinkhq" />
<Card size="small" url="https://www.last.fm/music/Tracky+Birthday/_/Websiiite+(with+Dragan+Espenschied)" />

Normal size previews

<Card url="https://astro.build/" />

Normal size without prestyling

<Card withStyling={false} url="https://en.wikipedia.org/wiki/Ada_Lovelace" />

Large preview

<Card size="large" url="https://www.youtube.com/watch?v=USKD3vPD6ZA" />

Embedded 2-Click-Variant

<Card size="embed" url="https://www.youtube.com/watch?v=W3id8E34cRQ" />

Embedded with custom text

<Card size="embed" url="https://www.youtube.com/watch?v=LWGJA9i18Co">
  <div slot="previewText">Foobar 2000</div>
</Card>

Embedded but falls back to large preview

When no iFrame is available, the component falls back to the large preview instead.

<Card size="embed" url="https://livewire.laravel.com/" />