Welcome, World | Astro astro.buildAstro's new look is live! Learn all about our new brand including the design process, our new logo, typeface, color palette, and mascot.
Video metadata
If a URL’s tags include og:video metadata, <LinkPreview> will render a video player instead of an image.
The above code produces the following result:
Mike Neumegen (@mikeneu@fosstodon.org) fosstodon.orgAttached: 1 video
"Ship just want the user needs" has become a radical idea that frameworks like @astro@webtoo.ls and @eleventy excel at.
@jlengstorf@hachyderm.io sharing a wealth of Jamstack nuggets in our What the Jam interview - https://www.youtube.com/watch?v=0YVCwD_Y7ts
https://TheFutureOfJamstack.org
#TheFutureOfJamstack
Hiding media
If a URL’s image or video is unwanted, add hideMedia as a prop.
The above code produces the following result:
Mike Neumegen (@mikeneu@fosstodon.org) fosstodon.orgAttached: 1 video
"Ship just want the user needs" has become a radical idea that frameworks like @astro@webtoo.ls and @eleventy excel at.
@jlengstorf@hachyderm.io sharing a wealth of Jamstack nuggets in our What the Jam interview - https://www.youtube.com/watch?v=0YVCwD_Y7ts
https://TheFutureOfJamstack.org
#TheFutureOfJamstack
Limitations
The available Open Graph metadata varies from site to site.
If a site doesn’t provide og:image metadata, no image will be displayed, only the page title and description.
If no title is detected or the metadata collection step fails, <LinkPreview> will display only the original link URL.
Styling the preview
By default the <LinkPreview> card has some minimal layout styling, which should adapt to your site’s font settings etc.
You can customise it with CSS by targeting the .link-preview class, for example:
The above styles would render <LinkPreview> like this:
Astro Embed astro-embed.netlify.appHigh performance, rich media embed components. For your site, from the Astro community.
Custom properties API
The <LinkPreview> component supports the following API for controlling its styles with CSS custom properties.
CSS class names API
.link-preview: The root element of the <LinkPreview> card.
.link-preview--has-video: Class applied to the card when it includes video instead of an image.
.link-preview--no-media: Class applied to the card when it includes no image or video.
.link-preview--no-metadata: Class applied when metadata scraping failed, or no valid title was found. In this case the only contents of the card is the original URL link.
Standalone installation
If you only need the <LinkPreview> component, you can install the package directly instead of the main astro-embed package: