@@ -22,7 +22,6 @@ const head: HeadConfig[] = [
22
22
] ,
23
23
// Open Graph
24
24
[ "meta" , { property : "og:site_name" , content : "Oxc" } ] ,
25
- [ "meta" , { property : "og:url" , content : "https://github.com/oxc-project" } ] ,
26
25
[
27
26
"meta" ,
28
27
{
@@ -78,6 +77,31 @@ export const sharedConfig = defineConfig({
78
77
] ) ;
79
78
}
80
79
80
+ // Add page-specific Open Graph and Twitter meta tags
81
+ const title = pageData . frontmatter . title || pageData . title ;
82
+ const description = pageData . frontmatter . description || pageData . description || "A collection of high-performance JavaScript tools written in Rust" ;
83
+
84
+ // Construct the canonical URL for the page
85
+ let url = "https://oxc.rs" ;
86
+ if ( pageData . relativePath !== "index.md" ) {
87
+ const path = pageData . relativePath . replace ( / \. m d $ / , '.html' ) . replace ( / \/ i n d e x \. h t m l $ / , '/' ) ;
88
+ if ( path !== "index.html" ) {
89
+ url += "/" + path . replace ( / ^ \/ + / , '' ) ;
90
+ }
91
+ }
92
+
93
+ if ( title ) {
94
+ head . push ( [ "meta" , { property : "og:title" , content : title } ] ) ;
95
+ head . push ( [ "meta" , { name : "twitter:title" , content : title } ] ) ;
96
+ }
97
+
98
+ if ( description ) {
99
+ head . push ( [ "meta" , { property : "og:description" , content : description } ] ) ;
100
+ head . push ( [ "meta" , { name : "twitter:description" , content : description } ] ) ;
101
+ }
102
+
103
+ head . push ( [ "meta" , { property : "og:url" , content : url } ] ) ;
104
+
81
105
return head ;
82
106
} ,
83
107
themeConfig : {
0 commit comments