Skip to content

feat(build): add BuildValue for values computed once per build - #112

Open
Princesseuh wants to merge 1 commit into
mainfrom
feat/build-values
Open

feat(build): add BuildValue for values computed once per build#112
Princesseuh wants to merge 1 commit into
mainfrom
feat/build-values

Conversation

@Princesseuh

Copy link
Copy Markdown
Member

Adds BuildValue: a value computed once per build from content and shared across every page that reads it via ctx.build_value(&MY_VALUE).

static ARTICLE_COUNT: BuildValue<usize> =
    BuildValue::new(|ctx| ctx.content::<Article>("articles").entries().count());

// in a routes render():
let count = ctx.build_value(&ARTICLE_COUNT);

This replaces the pattern of one route computing something in its render() and stashing it in a global for other routes to read. On incremental builds the producing route can be served from cache — skipping its render() — which leaves the global unset and breaks its readers. A build value is computed lazily on read, memoized for the rest of the build, and records its own content dependencies onto every page that reads it, so readers re-render exactly when the values inputs change.

Also removes the unused assets() method from the ContentContext trait, and PageContext::from_static_route / from_dynamic_route now take a &BuildValueStore — both only affect code that drives the build loop directly instead of going through coronate().

@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy Preview for maudit-framework ready!

Name Link
🔨 Latest commit cefbc52
🔍 Latest deploy log https://app.netlify.com/projects/maudit-framework/deploys/6a75997d6bc15600096b6a4d
😎 Deploy Preview https://deploy-preview-112--maudit-framework.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added website Improvements or additions to documentation crt:maudit Changes in Maudit crate. examples labels Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crt:maudit Changes in Maudit crate. examples website Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant