Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/astro/src/default/components/MetaTags.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ import { readPublicAsset } from '../utils/publicAsset';
interface Props {
meta?: MetaTagsConfig;
}

const DEFAULT_OG_IMAGE = 'https://tutorialkit.dev/tutorialkit-opengraph.png';

const { meta = {} } = Astro.props;
let imageUrl = meta.image;

// Resolve relative paths to /public folder
if (imageUrl?.startsWith('/') || imageUrl?.startsWith('.')) {
imageUrl = readPublicAsset(imageUrl, true);

if (!imageUrl) {
console.warn(`Image ${meta.image} not found in "/public" folder`);
console.warn(`\nImage ${meta.image} not found in "/public" folder`);
}
}

imageUrl ??= readLogoFile('logo', true);
imageUrl ??= DEFAULT_OG_IMAGE;

if (imageUrl?.endsWith('.svg')) {
console.warn(`Using a SVG open graph image "${imageUrl}". This is not supported by most social platforms.
You should rather set "meta.image" to a raster image (PNG, WEBP).`);
console.warn(
`\nUsing a SVG open graph image "${imageUrl}". This is not supported by most social platforms. You should rather set "meta.image" to a raster image (PNG, WEBP).`,
);
}
---

Expand Down