From 7b957855bac2927476a473bcd14261cb84e7fa54 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Tue, 21 Nov 2023 13:41:20 +0100 Subject: [PATCH] activate hook for all the pages --- server/plugins/content.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/server/plugins/content.ts b/server/plugins/content.ts index 1e597d72..0de47c44 100644 --- a/server/plugins/content.ts +++ b/server/plugins/content.ts @@ -5,27 +5,27 @@ import * as d3 from "d3"; export default defineNitroPlugin((nitroApp) => { - nitroApp.hooks.hook('content:file:beforeParse', - (file) => { - if (file?._id?.startsWith('content:3.defense-systems:') && file?._id?.endsWith('.md')) { - const frontMatterRegex = /(?<=---\n).*?(?=\n---)/sg; + // nitroApp.hooks.hook('content:file:beforeParse', + // (file) => { + // if (file?._id?.startsWith('content:3.defense-systems:') && file?._id?.endsWith('.md')) { + // const frontMatterRegex = /(?<=---\n).*?(?=\n---)/sg; - const fontMatterMatch = file.body.match(frontMatterRegex); - if (fontMatterMatch?.length > 0) { - const frontMatter = fontMatterMatch[0] - const parsedFrontMatter = YAML.parse(frontMatter) - if (parsedFrontMatter?.contributors?.length > 0) { - // file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n") - } - } - } - }) + // const fontMatterMatch = file.body.match(frontMatterRegex); + // if (fontMatterMatch?.length > 0) { + // const frontMatter = fontMatterMatch[0] + // const parsedFrontMatter = YAML.parse(frontMatter) + // if (parsedFrontMatter?.contributors?.length > 0) { + // // file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n") + // } + // } + // } + // }) nitroApp.hooks.hook( 'content:file:afterParse', (file) => { - if (file?._id?.startsWith('content:3.defense-systems:') && file._id.endsWith('.md')) { + if (file?._id?.startsWith('content') && file._id.endsWith('.md')) { if (file?.body?.children?.length > 0) { // has contributors if (file?.contributors?.length > 0) { -- GitLab