Skip to content
Snippets Groups Projects
Commit 7b957855 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

activate hook for all the pages

parent 31ecb368
No related branches found
No related tags found
No related merge requests found
Pipeline #116254 passed with stages
in 10 minutes and 52 seconds
......@@ -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) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment