WORK-084
ID:WORK-084Status:done

Inject $file.created and $file.modified Variables into Content Pipeline

Priority:highComplexity:moderateMilestone:v1.0.0Source:SPEC-029

Criteria completion

Criteria completion: 8 of 8 (100%) checked; history from Mar 30 to Apr 30%25%50%75%100%Mar 30Apr 3
Branches 3
History 6
  1. e900a90
    Created (done)by bjornolofandersson
  2. f262d7b
    Content editedby Claude
  3. f0a845a
    • ☑ `loadContent()` in `packages/content/src/site.ts` calls the git timestamp utility once before the page loop
    • ☑ Each page's `contentVariables` includes a `file` object with `created` and `modified` string properties
    • ☑ Three-tier resolution order: frontmatter override > git history > fs.stat fallback
    • ☑ When no timestamp is available, the variable is `undefined` (not an empty string or null)
    • ☑ Variables are accessible in Markdoc schemas as `$file.created` and `$file.modified`
    • ☑ Existing `$page` and `$frontmatter` variables are unaffected
    • ☑ Integration test: a page with no frontmatter dates gets git-derived `$file.created` and `$file.modified`
    • ☑ Integration test: a page with explicit frontmatter `created`/`modified` uses those values instead of git data
    by Claude
  4. f87ae8d
    statusreadydone
    by Claude
  5. 2a05e00
    Content editedby Claude
  6. 43cadfe
    Created (ready)by Claude
    plan: break down SPEC-029 into work items WORK-083 through WORK-087

Summary

Wire the shared git timestamp utility into packages/content/src/site.ts so that every page's Markdoc transform config includes $file.created and $file.modified variables. These join the existing $page and $frontmatter variables, making file timestamps available to any rune via standard Markdoc variable references.

Acceptance Criteria

  • loadContent() in packages/content/src/site.ts calls the git timestamp utility once before the page loop
  • Each page's contentVariables includes a file object with created and modified string properties
  • Three-tier resolution order: frontmatter override > git history > fs.stat fallback
  • When no timestamp is available, the variable is undefined (not an empty string or null)
  • Variables are accessible in Markdoc schemas as $file.created and $file.modified
  • Existing $page and $frontmatter variables are unaffected
  • Integration test: a page with no frontmatter dates gets git-derived $file.created and $file.modified
  • Integration test: a page with explicit frontmatter created/modified uses those values instead of git data

Approach

  1. Import the git timestamp utility in packages/content/src/site.ts
  2. Call it once at the start of loadContent() with the content root directory
  3. In the per-page loop, look up timestamps for each file path and merge into contentVariables
  4. Apply the three-tier fallback: check frontmatter first, then git map, then fs.stat

References

  • SPEC-029 (Phase 2 — Variable Injection)
  • WORK-083 (shared git timestamp utility — dependency)
  • packages/content/src/site.ts — existing variable injection point