Skip to content

Commit

Permalink
docs: set Open Graph images based on page routes (#4477)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Feb 3, 2025
1 parent fd6a3de commit e136112
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions website/rspress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ export default defineConfig({
},
],
},
head: [
({ routePath }) => {
const getOgImage = () => {
if (routePath.endsWith('releases/v1-0')) {
return 'assets/rsbuild-og-image-v1-0.png';
}
return 'rsbuild-og-image.png';
};
return `<meta property="og:image" content="https://assets.rspack.dev/rsbuild/${getOgImage()}">`;
},
],
builderConfig: {
dev: {
lazyCompilation: true,
Expand All @@ -144,8 +155,6 @@ export default defineConfig({
title: 'Rsbuild',
type: 'website',
url: siteUrl,
image:
'https://assets.rspack.dev/rsbuild/assets/rsbuild-og-image-v1-0.png',
description: 'The Rspack-based build tool',
twitter: {
site: '@rspack_dev',
Expand Down

0 comments on commit e136112

Please sign in to comment.