From 601ac4c9d59098f956abd58d619522dd50990b82 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Mon, 8 Jan 2024 16:13:56 +0900 Subject: [PATCH] doc(book): add additional metadata to each page Apply a few metadata improvements reported in Lighthouse, as well as increasing the information for OpenGraph display. This allows for a richer link display on several platforms when shared. --- book/.vitepress/config.mts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/book/.vitepress/config.mts b/book/.vitepress/config.mts index 2b0df59..559c7f0 100644 --- a/book/.vitepress/config.mts +++ b/book/.vitepress/config.mts @@ -31,10 +31,30 @@ export default defineConfig({ preserveSymlinks: true, }, }, - head: [["link", { rel: "icon", type: "image/svg+xml", href: "/mabo/logo.svg" }]], + head: [ + ["link", { rel: "icon", type: "image/svg+xml", href: "/mabo/logo.svg" }], + ["meta", { name: "color-scheme", content: "dark light" }], + ["meta", { name: "theme-color", content: "#d95a00" }], + ["meta", { name: "og:type", content: "website" }], + ["meta", { name: "og:locale", content: "en" }], + ["meta", { name: "og:site_name", content: "Mabo" }], + ], + transformPageData(pageData, ctx) { + pageData.frontmatter.head ??= []; + pageData.frontmatter.head.push([ + "meta", + { + name: "og:title", + content: + pageData.frontmatter.layout === "home" + ? ctx.siteConfig.site.title + : `${pageData.title} | ${ctx.siteConfig.site.title}`, + }, + ]); + }, themeConfig: { // https://vitepress.dev/reference/default-theme-config - logo: "/logo.svg", + logo: { src: "/logo.svg", width: 24, height: 24 }, editLink: { pattern: "https://github.com/dnaka91/mabo/edit/main/book/src/:path", text: "Edit this page on GitHub",