Conversation
Templates received only global.vars.js output in vars, while pages received both global.vars.js and global.data.js output via PageData.vars. This inconsistency forced every template that needed aggregated data to re-derive it from the pages array, duplicating logic from global.data.js. Merging globalDataVars into the globalVars object passed to templateBuilder makes template vars consistent with how page vars already work.
Coverage Report for CI Build 24619419220Coverage increased (+0.009%) to 91.478%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Aligns template rendering with page rendering by ensuring templates receive global.data.js outputs in vars, eliminating duplicated aggregation logic in templates and resolving the inconsistency described in #235.
Changes:
- Merge
globalDataVarsinto theglobalVarsobject passed totemplateBuilder, withglobalDataVarstaking precedence.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merges globalVars and globalDataVars once before the pMap loop instead of once per template render. Updates TemplateFunction and templateBuilder JSDoc to accurately describe that vars now includes global.data.js output.
There was a problem hiding this comment.
Pull request overview
This PR makes template rendering receive the same aggregated site variables as pages by merging global.data.js output into the vars passed to templates, aligning template behavior with PageData.vars.
Changes:
- Hoists a single merged
templateGlobalVars = { ...globalVars, ...globalDataVars }and passes it intotemplateBuilder()for all template renders. - Updates template builder JSDoc to reflect that template
varsincludesglobal.data.jsoutput.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/build-pages/index.js | Merges globalVars + globalDataVars once per build and passes merged vars into templateBuilder() |
| lib/build-pages/page-builders/template-builder.js | Updates JSDoc to document the expanded vars contract for templates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
global.data.js now returns a globalDataSentinel value. feeds.template.js reads it from vars and includes it as a custom extension field in feed.json. The test asserts the sentinel appears in the generated feed, which only passes when globalDataVars are correctly merged into templateGlobalVars. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR makes template rendering consistent with page rendering by including global.data.js output in the vars object passed to templates, eliminating the need for templates to re-derive aggregated site data from pages.
Changes:
- Merge
globalDataVarsinto theglobalVarspassed totemplateBuilder()(withglobal.data.jstaking precedence). - Update
templateBuilder/template function JSDoc to reflect the expandedvarscontract. - Add an integration regression test ensuring
global.data.jsoutput is visible in templatevars.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test-cases/general-features/src/global.data.js | Adds a sentinel value to verify global.data.js output can flow into template vars. |
| test-cases/general-features/src/feeds.template.js | Reads the sentinel from vars and emits it into feed.json for verification. |
| test-cases/general-features/index.test.js | Asserts the generated feed includes the sentinel value, covering the new behavior end-to-end. |
| lib/build-pages/page-builders/template-builder.js | Updates JSDoc to describe vars as global.vars merged with global.data output. |
| lib/build-pages/index.js | Hoists and passes a merged {...globalVars, ...globalDataVars} object into templateBuilder(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bcomnes
left a comment
There was a problem hiding this comment.
This looks good. Just make sure it's done consistently with how pages handles this
Closes #235
Templates received only
global.vars.jsoutput invars, while pages received bothglobal.vars.jsandglobal.data.jsoutput via thePageData.varsgetter. This inconsistency forced every template that needed aggregated data to re-derive it from thepagesarray, duplicating logic thatglobal.data.jsalready performs.The fix merges
globalDataVarsinto theglobalVarsobject passed totemplateBuilder, making templatevarsconsistent with how pagevarsalready work.Before this change, a feeds template that needed aggregated post data had to re-implement the full filtering and sorting pipeline from
global.data.js. After this change it can readvars.recentPosts(or whateverglobal.data.jsreturns) directly.The merge order follows the same precedence as
PageData.vars:globalVarsis the base, andglobalDataVarsoverrides it. Templates that do not have aglobal.data.jsfile are unaffected sinceglobalDataVarswill be an empty object in that case.