INNER CODE UNIT · TypeScript
seoMetaPlugin
Rodert/JavaPub · src/.vuepress/config.ts:109
const seoMetaPlugin = () => ({
name: "seo-meta-plugin",
extendsPage: (page) => {
const title = buildSeoTitle(page.title, page.path);
const canonicalUrl = new URL(page.path, siteUrl).href;
const description = buildSeoDescription(
page.title,
page.path,
page.frontmatter.description,
page.content,
);
const head = page.frontmatter.head ?? [];
page.frontmatter.head = [
["title", {}, title],
["meta", { name: "description", content: description }],
["link", { rel: "canonical", href: canonicalUrl }],
["meta", { property: "og:description", content: description }],