-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat all code and update more parts of the wiki
- Loading branch information
Showing
33 changed files
with
596 additions
and
550 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,100 @@ | ||
import type {HeadConfig, TransformContext} from "vitepress"; | ||
|
||
export function generateMeta(context: TransformContext, hostname: string) { | ||
const head: HeadConfig[] = []; | ||
const { pageData } = context; | ||
const head: HeadConfig[] = []; | ||
const {pageData} = context; | ||
|
||
const url = `${hostname}/${pageData.relativePath.replace(/((^|\/)index)?\.md$/, "$2")}`; | ||
const url = `${hostname}/${pageData.relativePath.replace(/((^|\/)index)?\.md$/, "$2")}`; | ||
|
||
head.push( | ||
["link", { rel: "canonical", href: url }], | ||
["meta", { property: "og:url", content: url }], | ||
["meta", { name: "twitter:url", content: url }], | ||
["meta", { name: "twitter:card", content: "summary_large_image" }], | ||
["meta", { property: "og:title", content: pageData.frontmatter.title }], | ||
["meta", { name: "twitter:title", content: pageData.frontmatter.title }], | ||
); | ||
if (pageData.frontmatter.description) { | ||
head.push( | ||
[ | ||
"meta", | ||
{ | ||
property: "og:description", | ||
content: pageData.frontmatter.description, | ||
}, | ||
], | ||
[ | ||
"meta", | ||
{ | ||
name: "twitter:description", | ||
content: pageData.frontmatter.description, | ||
}, | ||
], | ||
["link", {rel: "canonical", href: url}], | ||
["meta", {property: "og:url", content: url}], | ||
["meta", {name: "twitter:url", content: url}], | ||
["meta", {name: "twitter:card", content: "summary_large_image"}], | ||
["meta", {property: "og:title", content: pageData.frontmatter.title}], | ||
["meta", {name: "twitter:title", content: pageData.frontmatter.title}], | ||
); | ||
} | ||
if (pageData.frontmatter.image) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "og:image", | ||
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`, | ||
}, | ||
]); | ||
head.push([ | ||
"meta", | ||
{ | ||
name: "twitter:image", | ||
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`, | ||
}, | ||
]); | ||
} else { | ||
const url = pageData.filePath.replace("index.md", "").replace(".md", ""); | ||
const imageUrl = `${url}/__og_image__/og.png` | ||
.replaceAll("//", "/") | ||
.replace(/^\//, ""); | ||
if (pageData.frontmatter.description) { | ||
head.push( | ||
[ | ||
"meta", | ||
{ | ||
property: "og:description", | ||
content: pageData.frontmatter.description, | ||
}, | ||
], | ||
[ | ||
"meta", | ||
{ | ||
name: "twitter:description", | ||
content: pageData.frontmatter.description, | ||
}, | ||
], | ||
); | ||
} | ||
if (pageData.frontmatter.image) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "og:image", | ||
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`, | ||
}, | ||
]); | ||
head.push([ | ||
"meta", | ||
{ | ||
name: "twitter:image", | ||
content: `${hostname}/${pageData.frontmatter.image.replace(/^\//, "")}`, | ||
}, | ||
]); | ||
} else { | ||
const url = pageData.filePath.replace("index.md", "").replace(".md", ""); | ||
const imageUrl = `${url}/__og_image__/og.png` | ||
.replaceAll("//", "/") | ||
.replace(/^\//, ""); | ||
|
||
head.push( | ||
["meta", { property: "og:image", content: `${hostname}/${imageUrl}` }], | ||
["meta", { property: "og:image:width", content: "1200" }], | ||
["meta", { property: "og:image:height", content: "628" }], | ||
["meta", { property: "og:image:type", content: "image/png" }], | ||
[ | ||
"meta", | ||
{ property: "og:image:alt", content: pageData.frontmatter.title }, | ||
], | ||
["meta", { name: "twitter:image", content: `${hostname}/${imageUrl}` }], | ||
["meta", { name: "twitter:image:width", content: "1200" }], | ||
["meta", { name: "twitter:image:height", content: "628" }], | ||
[ | ||
"meta", | ||
{ name: "twitter:image:alt", content: pageData.frontmatter.title }, | ||
], | ||
); | ||
} | ||
if (pageData.frontmatter.tag) { | ||
head.push([ | ||
"meta", | ||
{ property: "article:tag", content: pageData.frontmatter.tag }, | ||
]); | ||
} | ||
if (pageData.frontmatter.date) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "article:published_time", | ||
content: pageData.frontmatter.date, | ||
}, | ||
]); | ||
} | ||
if (pageData.lastUpdated && pageData.frontmatter.lastUpdated !== false) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "article:modified_time", | ||
content: new Date(pageData.lastUpdated).toISOString(), | ||
}, | ||
]); | ||
} | ||
head.push( | ||
["meta", {property: "og:image", content: `${hostname}/${imageUrl}`}], | ||
["meta", {property: "og:image:width", content: "1200"}], | ||
["meta", {property: "og:image:height", content: "628"}], | ||
["meta", {property: "og:image:type", content: "image/png"}], | ||
[ | ||
"meta", | ||
{property: "og:image:alt", content: pageData.frontmatter.title}, | ||
], | ||
["meta", {name: "twitter:image", content: `${hostname}/${imageUrl}`}], | ||
["meta", {name: "twitter:image:width", content: "1200"}], | ||
["meta", {name: "twitter:image:height", content: "628"}], | ||
[ | ||
"meta", | ||
{name: "twitter:image:alt", content: pageData.frontmatter.title}, | ||
], | ||
); | ||
} | ||
if (pageData.frontmatter.tag) { | ||
head.push([ | ||
"meta", | ||
{property: "article:tag", content: pageData.frontmatter.tag}, | ||
]); | ||
} | ||
if (pageData.frontmatter.date) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "article:published_time", | ||
content: pageData.frontmatter.date, | ||
}, | ||
]); | ||
} | ||
if (pageData.lastUpdated && pageData.frontmatter.lastUpdated !== false) { | ||
head.push([ | ||
"meta", | ||
{ | ||
property: "article:modified_time", | ||
content: new Date(pageData.lastUpdated).toISOString(), | ||
}, | ||
]); | ||
} | ||
|
||
return head; | ||
return head; | ||
} |
Oops, something went wrong.