@@ -4,10 +4,12 @@ import { pluginLlms } from '@rspress/plugin-llms';
44import { pluginRss } from '@rspress/plugin-rss' ;
55import { transformerNotationHighlight } from '@shikijs/transformers' ;
66import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics' ;
7+ import { pluginOpenGraph } from 'rsbuild-plugin-open-graph' ;
78import { pluginFontOpenSans } from 'rspress-plugin-font-open-sans' ;
89import { defineConfig } from 'rspress/config' ;
910
1011const siteUrl = 'https://lib.rsbuild.dev' ;
12+ const description = 'The Rsbuild-based library development tool' ;
1113
1214export default defineConfig ( {
1315 plugins : [
@@ -62,6 +64,17 @@ export default defineConfig({
6264 // exclude document fragments from routes
6365 exclude : [ '**/zh/shared/**' , '**/en/shared/**' ] ,
6466 } ,
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+ ] ,
6578 themeConfig : {
6679 socialLinks : [
6780 {
@@ -85,7 +98,7 @@ export default defineConfig({
8598 lang : 'en' ,
8699 label : 'English' ,
87100 title : 'Rslib' ,
88- description : 'The Rsbuild-based library development tool' ,
101+ description,
89102 editLink : {
90103 docRepoBaseUrl :
91104 'https://github.com/web-infra-dev/rslib/tree/main/website/docs' ,
@@ -127,6 +140,19 @@ export default defineConfig({
127140 '@zh' : path . join ( __dirname , 'docs/zh' ) ,
128141 } ,
129142 } ,
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+ ] ,
131157 } ,
132158} ) ;
0 commit comments