Skip to main content

YouTube Embed

Lightweight YouTube videos using lite-youtube-embed. Supports using a custom preview image and title.

How to use

<Section columns={1}>
<Markdown>

# YouTube Embed

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.

</Markdown>

import YouTube from "~/components/media/videos/YouTube.astro";
import PreviewImage from "~/assets/jpg/mick-nsenga-50XwniKxiXI-unsplash.jpg";

<YouTube
  url="https://www.youtube.com/watch?v=CHSnz0bCaUk"
  title="Example title to display"
  image={{
    src: PreviewImage,
    alt: "Example alt text here",
  }}
/>

</Section>

Props

PropTypeDescription
imageobject(optional) Image data for the component. See fields below.
imageQualitystring(optional) YouTube preview image quality. Valid choices are: "max" | "high" | "standard" | "low"
labelstring(optional) Custom screen reader text for the play button, default is “Play video”
paramsstring(optional) URL params to customise player. See supported params here
titlestring(optional) The title displayed at the top of the video.
urlstringCan be either a Vimeo video ID or the URL e.g. https://www.youtube.com/watch?v=CHSnz0bCaUk
classstring(optional) Additional classes applied to the root <div>.
(extends)HTMLAttributes<"div">(optional) All standard HTML attributes for a <div>.

image object

  • srcImageMetadata
    The imported image metadata (output from Astro’s image import).
  • alt — string
    (optional) Alt text for the image, defaults to empty string "".

More examples


About MDX

astro-skeleton uses the @astrojs/mdx integration installed and configured in the astro.config.mjs config file.

Why MDX?

MDX is a special flavor of Markdown that supports embedded JavaScript & JSX syntax. This unlocks the ability to mix JavaScript and UI Components into Markdown content for things like interactive charts or alerts.

If you have existing content authored in MDX, this integration will hopefully make migrating a breeze.

Documentation