Skip to content

fix: switch default meta.image to .png #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2024
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