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
...@@ -5,27 +5,27 @@ import * as d3 from "d3"; ...@@ -5,27 +5,27 @@ import * as d3 from "d3";
export default defineNitroPlugin((nitroApp) => { export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('content:file:beforeParse', // nitroApp.hooks.hook('content:file:beforeParse',
(file) => { // (file) => {
if (file?._id?.startsWith('content:3.defense-systems:') && file?._id?.endsWith('.md')) { // if (file?._id?.startsWith('content:3.defense-systems:') && file?._id?.endsWith('.md')) {
const frontMatterRegex = /(?<=---\n).*?(?=\n---)/sg; // const frontMatterRegex = /(?<=---\n).*?(?=\n---)/sg;
const fontMatterMatch = file.body.match(frontMatterRegex); // const fontMatterMatch = file.body.match(frontMatterRegex);
if (fontMatterMatch?.length > 0) { // if (fontMatterMatch?.length > 0) {
const frontMatter = fontMatterMatch[0] // const frontMatter = fontMatterMatch[0]
const parsedFrontMatter = YAML.parse(frontMatter) // const parsedFrontMatter = YAML.parse(frontMatter)
if (parsedFrontMatter?.contributors?.length > 0) { // if (parsedFrontMatter?.contributors?.length > 0) {
// file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n") // // file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n")
} // }
} // }
} // }
}) // })
nitroApp.hooks.hook( nitroApp.hooks.hook(
'content:file:afterParse', 'content:file:afterParse',
(file) => { (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) { if (file?.body?.children?.length > 0) {
// has contributors // has contributors
if (file?.contributors?.length > 0) { if (file?.contributors?.length > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment