|
|
|
|
@ -13,6 +13,19 @@ import llmstxt from 'vitepress-plugin-llms'
|
|
|
|
|
const prod = !!process.env.NETLIFY
|
|
|
|
|
const siteUrl = 'https://vitepress.dev'
|
|
|
|
|
|
|
|
|
|
const ogImage = new URL('/vitepress-og.jpg', siteUrl).href
|
|
|
|
|
|
|
|
|
|
const localeToOgLocaleMap: Record<string, string> = {
|
|
|
|
|
root: 'en_US',
|
|
|
|
|
zh: 'zh_CN',
|
|
|
|
|
pt: 'pt_BR',
|
|
|
|
|
ru: 'ru_RU',
|
|
|
|
|
es: 'es_ES',
|
|
|
|
|
ko: 'ko_KR',
|
|
|
|
|
fa: 'fa_IR',
|
|
|
|
|
ja: 'ja_JP'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
title: 'VitePress',
|
|
|
|
|
|
|
|
|
|
@ -83,9 +96,6 @@ export default defineConfig({
|
|
|
|
|
['link', { rel: 'icon', type: 'image/svg+xml', href: '/vitepress-logo-mini.svg' }],
|
|
|
|
|
['link', { rel: 'icon', type: 'image/png', href: '/vitepress-logo-mini.png' }],
|
|
|
|
|
['meta', { name: 'theme-color', content: '#5f67ee' }],
|
|
|
|
|
['meta', { property: 'og:type', content: 'website' }],
|
|
|
|
|
['meta', { property: 'og:site_name', content: 'VitePress' }],
|
|
|
|
|
['meta', { property: 'og:image', content: new URL('/vitepress-og.jpg', siteUrl).href }],
|
|
|
|
|
['script', { src: 'https://cdn.usefathom.com/script.js', 'data-site': 'AZBRSFGG', 'data-spa': 'auto', defer: '' }]
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
@ -145,15 +155,24 @@ export default defineConfig({
|
|
|
|
|
transformPageData: prod ? (pageData, ctx) => {
|
|
|
|
|
const url = new URL(pageData.relativePath.replace(/(?:(^|\/)index)?\.md$/, '$1'), siteUrl).href
|
|
|
|
|
const site = resolveSiteDataByRoute(ctx.siteConfig.site, pageData.relativePath)
|
|
|
|
|
const locale = site.lang.replace(/-([a-z]+)$/i, '_$1')
|
|
|
|
|
const title = `${pageData.title || site.title} | VitePress`
|
|
|
|
|
const title = pageData.title ? `${pageData.title} | VitePress` : site.title
|
|
|
|
|
const description = pageData.description || site.description
|
|
|
|
|
const locale = localeToOgLocaleMap[site.localeIndex || 'root']
|
|
|
|
|
|
|
|
|
|
;((pageData.frontmatter.head ??= []) as HeadConfig[]).push(
|
|
|
|
|
['meta', { property: 'og:url', content: url }],
|
|
|
|
|
['meta', { property: 'og:locale', content: locale }],
|
|
|
|
|
['meta', { property: 'og:title', content: title }],
|
|
|
|
|
['meta', { property: 'og:description', content: description }]
|
|
|
|
|
['meta', { property: 'og:description', content: description }],
|
|
|
|
|
['meta', { property: 'og:type', content: 'website' }],
|
|
|
|
|
['meta', { property: 'og:locale', content: locale }],
|
|
|
|
|
['meta', { property: 'og:site_name', content: 'VitePress' }],
|
|
|
|
|
['meta', { property: 'og:image', content: ogImage }],
|
|
|
|
|
['meta', { property: 'og:image:secure_url', content: ogImage }],
|
|
|
|
|
['meta', { property: 'og:image:type', content: 'image/jpeg' }],
|
|
|
|
|
['meta', { property: 'og:image:width', content: '1280' }],
|
|
|
|
|
['meta', { property: 'og:image:height', content: '640' }],
|
|
|
|
|
['meta', { property: 'og:image:alt', content: 'VitePress' }],
|
|
|
|
|
['link', { rel: 'canonical', href: url }]
|
|
|
|
|
)
|
|
|
|
|
} : undefined
|
|
|
|
|
})
|
|
|
|
|
|