Skip to content

Cache page vars and add markdown content helper#243

Merged
bcomnes merged 3 commits into
masterfrom
docs/global-data-caveats
Jun 26, 2026
Merged

Cache page vars and add markdown content helper#243
bcomnes merged 3 commits into
masterfrom
docs/global-data-caveats

Conversation

@bcomnes

@bcomnes bcomnes commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Closes #228

Adds global.data.js caveats documentation and updates PageData behavior to match the documented API.

Changes:

  • Cache the merged page.vars object after the first successful access.
  • Return a shallow-frozen vars object so callers treat it as read-only.
  • Invalidate the vars cache if any source object reference changes, including globalDataVars.
  • Add page.readMarkdownContent() for reading the raw markdown body without front matter.
  • Share markdown front matter splitting between the markdown builder and readMarkdownContent().
  • Document that page.vars can throw when a page failed to initialize, and that this should be treated as a build issue to fix.
  • Clarify that markdown raw source is not exposed as page.vars.content by default.
  • Document that renderInnerPage({ pages }) is available in global.data.js.

Validation:

  • node --test lib/build-pages/page-data.test.js lib/build-pages/page-data-vars-catch.test.js
  • npx 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.js
  • npm run test:tsc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.vars is a computed getter (fresh merge on every access) and should be cached per page when reading multiple properties.
  • Document that page.vars access can throw and recommend try/catch while iterating pages.
  • Document guidance around rendered content access via renderInnerPage() from global.data.js.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@coveralls

coveralls commented Apr 18, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28252678542

Warning

No base build found for commit 6590690 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 92.116%

Details

  • Patch coverage: 62 of 62 lines across 3 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 4177
Covered Lines: 3957
Line Coverage: 94.73%
Relevant Branches: 757
Covered Branches: 588
Branch Coverage: 77.68%
Branches in Coverage %: Yes
Coverage Strength: 73.08 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md Outdated
Comment thread README.md
Comment thread README.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bcomnes

bcomnes commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

We might need to make this consistent with the other built in try catch the other or adds. Also maybe domstack shouod cache this?

bcomnes added 2 commits June 26, 2026 09:11
- 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
@bcomnes bcomnes force-pushed the docs/global-data-caveats branch 2 times, most recently from 784eb3c to adec85d Compare June 26, 2026 16:37
@bcomnes bcomnes changed the title Document global.data.js caveats for vars getter and rendering Cache page vars and document global.data.js caveats Jun 26, 2026
@bcomnes bcomnes force-pushed the docs/global-data-caveats branch 3 times, most recently from 3f4e78b to 5b43818 Compare June 26, 2026 16:49
@bcomnes bcomnes changed the title Cache page vars and document global.data.js caveats Cache page vars and add markdown content helper Jun 26, 2026
@bcomnes bcomnes force-pushed the docs/global-data-caveats branch from 5b43818 to 241307a Compare June 26, 2026 16:53
@bcomnes bcomnes force-pushed the docs/global-data-caveats branch from 241307a to 2b0fff7 Compare June 26, 2026 16:55
@bcomnes

bcomnes commented Jun 26, 2026

Copy link
Copy Markdown
Owner Author

Cool this is ready to land.

@bcomnes bcomnes merged commit f733392 into master Jun 26, 2026
10 checks passed
@bcomnes bcomnes deleted the docs/global-data-caveats branch June 26, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document global.data.js caveats: vars getter, error handling, and raw content

3 participants