Skip to content

Commit

Permalink
fix: switch default meta.image to .png (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Nov 25, 2024
1 parent 6e1edc1 commit d39bf40
Showing 1 changed file with 10 additions and 4 deletions.
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

0 comments on commit d39bf40

Please sign in to comment.