Cache page vars and add markdown content helper#243
Conversation
There was a problem hiding this comment.
Pull request overview
Adds documentation to the global.data.js section in the README to clarify runtime caveats that impact performance and build robustness when using PageData in global data aggregation.
Changes:
- Document that
page.varsis a computed getter (fresh merge on every access) and should be cached per page when reading multiple properties. - Document that
page.varsaccess can throw and recommendtry/catchwhile iterating pages. - Document guidance around rendered content access via
renderInnerPage()fromglobal.data.js.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 28252678542Warning No base build found for commit Coverage: 92.116%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
We might need to make this consistent with the other built in try catch the other or adds. Also maybe domstack shouod cache this? |
- Cache p.vars in try/catch example to avoid double-invoking the getter - Broaden the .vars throw caveat to cover all init failures, not just vars module errors - Correct the raw content caveat: markdown pages do not expose content via vars.content; point to pageFile.filepath for raw source and renderInnerPage() for rendered HTML
784eb3c to
adec85d
Compare
3f4e78b to
5b43818
Compare
5b43818 to
241307a
Compare
241307a to
2b0fff7
Compare
|
Cool this is ready to land. |
Closes #228
Adds
global.data.jscaveats documentation and updatesPageDatabehavior to match the documented API.Changes:
page.varsobject after the first successful access.globalDataVars.page.readMarkdownContent()for reading the raw markdown body without front matter.readMarkdownContent().page.varscan throw when a page failed to initialize, and that this should be treated as a build issue to fix.page.vars.contentby default.renderInnerPage({ pages })is available inglobal.data.js.Validation:
node --test lib/build-pages/page-data.test.js lib/build-pages/page-data-vars-catch.test.jsnpx eslint lib/build-pages/page-data.js lib/build-pages/page-data.test.js lib/build-pages/page-builders/md/index.js lib/build-pages/page-builders/md/parse-md.jsnpm run test:tsc