diff --git a/docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx b/docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx index 021adb72..c70ab589 100644 --- a/docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx +++ b/docs/tutorialkit.dev/src/content/docs/reference/configuration.mdx @@ -430,6 +430,7 @@ type DownloadAsZip = Configures `` tags for Open Graph protocole and Twitter. TutorialKit will use your logo as the default image. +Relative paths are resolved to `public` directory. The `MetaTagsSchema` type has the following shape: @@ -449,6 +450,13 @@ meta: image: /cover.png title: Title shown on social media and search engines description: Description shown on social media and search engines + +meta: + image: /cover.png # Resolves to public/cover.png + +meta: + image: 'https://tutorialkit.dev/tutorialkit-opengraph.png' # URL is used as is + ``` :::tip diff --git a/packages/astro/src/default/components/MetaTags.astro b/packages/astro/src/default/components/MetaTags.astro index d91c4f2a..3782c82a 100644 --- a/packages/astro/src/default/components/MetaTags.astro +++ b/packages/astro/src/default/components/MetaTags.astro @@ -7,13 +7,16 @@ interface Props { meta?: MetaTagsConfig; } const { meta = {} } = Astro.props; -let imageUrl; -if (meta.image) { - imageUrl = readPublicAsset(meta.image, true); +let imageUrl = meta.image; + +if (imageUrl?.startsWith('/') || imageUrl?.startsWith('.')) { + imageUrl = readPublicAsset(imageUrl, true); + if (!imageUrl) { console.warn(`Image ${meta.image} not found in "/public" folder`); } } + imageUrl ??= readLogoFile('logo', true); ---