From c13749badfdfbe93c7190e02734829984cee6067 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 10 Jul 2025 13:59:37 -0400 Subject: [PATCH] Include page url in render context --- src/generator/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/generator/index.js b/src/generator/index.js index cb15a39..d6797a7 100644 --- a/src/generator/index.js +++ b/src/generator/index.js @@ -179,7 +179,14 @@ async function generate({ contentDir = 'content', outputDir = '_site', configPat const raw = await fs.promises.readFile(srcPath, 'utf8'); const { content, data } = matter(raw); const body = require('marked').parse(content); - let html = env.render('layout.njk', { title: data.title || page.data.title, content: body }); + + const pageContext = { + title: data.title || page.data.title, + content: body, + page: { url: '/' + page.file.replace(/\.md$/, '.html') } + }; + + let html = env.render('layout.njk', pageContext); const result = await runHook('onPageRendered', { file: page.file, html }); if (result && result.html) html = result.html; await fs.promises.writeFile(outPath, html);