Document global.data.js caveats for vars getter and rendering#243
Document global.data.js caveats for vars getter and rendering#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.
- 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
Coverage Report for CI Build 24612616510Coverage remained the same at 91.469%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. 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? |
Closes #228
Adds a Caveats section to the
global.data.jsdocumentation covering four runtime behaviors that users currently discover through source diving or trial and error:page.varsis a computed getter that merges four sources on every access. Caching the result when reading multiple properties reduces redundant work, especially on large sites.page.varsthrows if the underlying page module has a syntax error or runtime error. Wrapping intry/catchwhen iterating all pages prevents one broken page from aborting the whole function.page.vars.contentfor markdown pages is the raw markdown source string, not rendered HTML.renderInnerPage()is the path to rendered HTML.renderInnerPage()is available inglobal.data.jssince it receives fully initializedPageDatainstances.