@@ -4,10 +4,12 @@ import { pluginLlms } from '@rspress/plugin-llms';
4
4
import { pluginRss } from '@rspress/plugin-rss' ;
5
5
import { transformerNotationHighlight } from '@shikijs/transformers' ;
6
6
import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics' ;
7
+ import { pluginOpenGraph } from 'rsbuild-plugin-open-graph' ;
7
8
import { pluginFontOpenSans } from 'rspress-plugin-font-open-sans' ;
8
9
import { defineConfig } from 'rspress/config' ;
9
10
10
11
const siteUrl = 'https://lib.rsbuild.dev' ;
12
+ const description = 'The Rsbuild-based library development tool' ;
11
13
12
14
export default defineConfig ( {
13
15
plugins : [
@@ -62,6 +64,17 @@ export default defineConfig({
62
64
// exclude document fragments from routes
63
65
exclude : [ '**/zh/shared/**' , '**/en/shared/**' ] ,
64
66
} ,
67
+ head : [
68
+ ( { routePath } ) => {
69
+ const getOgImage = ( ) => {
70
+ if ( routePath . endsWith ( 'blog/introducing-rslib' ) ) {
71
+ return 'assets/rslib-og-image-introducing.png' ;
72
+ }
73
+ return 'rslib-og-image.png' ;
74
+ } ;
75
+ return `<meta property="og:image" content="https://assets.rspack.dev/rslib/${ getOgImage ( ) } ">` ;
76
+ } ,
77
+ ] ,
65
78
themeConfig : {
66
79
socialLinks : [
67
80
{
@@ -85,7 +98,7 @@ export default defineConfig({
85
98
lang : 'en' ,
86
99
label : 'English' ,
87
100
title : 'Rslib' ,
88
- description : 'The Rsbuild-based library development tool' ,
101
+ description,
89
102
editLink : {
90
103
docRepoBaseUrl :
91
104
'https://github.com/web-infra-dev/rslib/tree/main/website/docs' ,
@@ -127,6 +140,19 @@ export default defineConfig({
127
140
'@zh' : path . join ( __dirname , 'docs/zh' ) ,
128
141
} ,
129
142
} ,
130
- plugins : [ pluginGoogleAnalytics ( { id : 'G-Q66CEHQ6JR' } ) , pluginSass ( ) ] ,
143
+ plugins : [
144
+ pluginGoogleAnalytics ( { id : 'G-Q66CEHQ6JR' } ) ,
145
+ pluginSass ( ) ,
146
+ pluginOpenGraph ( {
147
+ title : 'Rslib' ,
148
+ type : 'website' ,
149
+ url : siteUrl ,
150
+ description,
151
+ twitter : {
152
+ site : '@rspack_dev' ,
153
+ card : 'summary_large_image' ,
154
+ } ,
155
+ } ) ,
156
+ ] ,
131
157
} ,
132
158
} ) ;
0 commit comments