Skip to content

Commit d39680a

Browse files
committed
push
1 parent 18487e1 commit d39680a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

.vitepress/config/shared.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export const sharedConfig = defineConfig({
6464
base: "/",
6565
head,
6666
lastUpdated: false,
67-
transformHead: ({ pageData }) => {
68-
const head: HeadConfig[] = [];
67+
transformPageData(pageData) {
68+
pageData.frontmatter.head ??= []
6969

7070
if (pageData.frontmatter.canonical) {
71-
head.push([
71+
pageData.frontmatter.head.push([
7272
"link",
7373
{
7474
rel: "canonical",
@@ -80,7 +80,7 @@ export const sharedConfig = defineConfig({
8080
// Add page-specific Open Graph and Twitter meta tags
8181
const title = pageData.frontmatter.title || pageData.title;
8282
const description = pageData.frontmatter.description || pageData.description || "A collection of high-performance JavaScript tools written in Rust";
83-
83+
8484
// Construct the canonical URL for the page
8585
let url = "https://oxc.rs";
8686
if (pageData.relativePath !== "index.md") {
@@ -91,18 +91,17 @@ export const sharedConfig = defineConfig({
9191
}
9292

9393
if (title) {
94-
head.push(["meta", { property: "og:title", content: title }]);
95-
head.push(["meta", { name: "twitter:title", content: title }]);
94+
pageData.frontmatter.head.push(["meta", { property: "og:title", content: title }]);
95+
pageData.frontmatter.head.push(["meta", { name: "twitter:title", content: title }]);
9696
}
9797

9898
if (description) {
99-
head.push(["meta", { property: "og:description", content: description }]);
100-
head.push(["meta", { name: "twitter:description", content: description }]);
99+
pageData.frontmatter.head.push(["meta", { property: "og:description", content: description }]);
100+
pageData.frontmatter.head.push(["meta", { name: "twitter:description", content: description }]);
101101
}
102102

103-
head.push(["meta", { property: "og:url", content: url }]);
103+
pageData.frontmatter.head.push(["meta", { property: "og:url", content: url }]);
104104

105-
return head;
106105
},
107106
themeConfig: {
108107
siteTitle: "Oxc",

0 commit comments

Comments
 (0)