From 9cf2d3de792b7b811a11a087bc7e4c0fc733d0c7 Mon Sep 17 00:00:00 2001 From: taskylizard <75871323+taskylizard@users.noreply.github.com> Date: Sun, 12 Jan 2025 18:23:13 +0000 Subject: [PATCH] fix: ignore headers properly --- docs/.vitepress/hooks/opengraph.ts | 8 ++++---- docs/.vitepress/markdown/headers.ts | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/.vitepress/hooks/opengraph.ts b/docs/.vitepress/hooks/opengraph.ts index 2969da2d6..a7679be22 100644 --- a/docs/.vitepress/hooks/opengraph.ts +++ b/docs/.vitepress/hooks/opengraph.ts @@ -28,7 +28,7 @@ import { headers } from '../transformer/constants' const __dirname = dirname(fileURLToPath(import.meta.url)) const __fonts = resolve(__dirname, '../fonts') -export async function generateImages(config: SiteConfig): Promise { +export async function generateImages(config: SiteConfig) { const pages = await createContentLoader('**/*.md', { excerpt: true }).load() const template = await readFile(resolve(__dirname, './Template.vue'), 'utf-8') @@ -82,20 +82,20 @@ async function generateImage({ template, outDir, fonts -}: GenerateImagesOptions): Promise { +}: GenerateImagesOptions) { const { frontmatter, url } = page const _page = getPage(url) const title = frontmatter.layout === 'home' - ? (frontmatter.hero.name ?? frontmatter.title) + ? frontmatter.hero.name ?? frontmatter.title : frontmatter.title ? frontmatter.title : _page?.title const description = frontmatter.layout === 'home' - ? (frontmatter.hero.tagline ?? frontmatter.description) + ? frontmatter.hero.tagline ?? frontmatter.description : frontmatter.description ? frontmatter.description : _page?.description diff --git a/docs/.vitepress/markdown/headers.ts b/docs/.vitepress/markdown/headers.ts index 5c36edb04..3fc18f099 100644 --- a/docs/.vitepress/markdown/headers.ts +++ b/docs/.vitepress/markdown/headers.ts @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import type { MarkdownRenderer } from 'vitepress' -const excluded = ['Credits'] +import type { MarkdownRenderer } from 'vitepress' +import { headers } from '../transformer/constants' + +const titles = Object.keys(headers).map((key) => headers[key].title) export const headersPlugin = (md: MarkdownRenderer) => { // Add the Feedback component in the heading, before the link. @@ -32,7 +34,7 @@ export const headersPlugin = (md: MarkdownRenderer) => { if (idxClose <= idx) return result const level = tokens[idx].tag.slice(1) - if (excluded.includes(env.frontmatter.title) || level !== '2') return result + if (!titles.includes(env.frontmatter.title) || level !== '2') return result // Find the token for the link. //