Skip to content

Commit ee2926a

Browse files
CopilotBoshen
andcommitted
Changes before error encountered
Co-authored-by: Boshen <[email protected]>
1 parent 21ac89f commit ee2926a

File tree

3 files changed

+3891
-202
lines changed

3 files changed

+3891
-202
lines changed

.vitepress/config/shared.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const head: HeadConfig[] = [
2222
],
2323
// Open Graph
2424
["meta", { property: "og:site_name", content: "Oxc" }],
25-
["meta", { property: "og:url", content: "https://github.com/oxc-project" }],
2625
[
2726
"meta",
2827
{
@@ -78,6 +77,31 @@ export const sharedConfig = defineConfig({
7877
]);
7978
}
8079

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(/\.md$/, '.html').replace(/\/index\.html$/, '/');
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+
81105
return head;
82106
},
83107
themeConfig: {

0 commit comments

Comments
 (0)