Summary
Category metadata loading currently performs synchronous filesystem reads (existsSync + readFileSync) during card prop generation, potentially repeating reads per brief card.
Affected files:
src/lib/category.ts
src/lib/contentCardHelpers.ts
src/pages/briefs/index.astro
Why This Matters
Repeated sync I/O is non-idiomatic for repeated lookup paths and can become a build-time bottleneck as content grows.
Proposed Strategy
- Add an in-memory cache (e.g.,
Map<string, BriefCategory>) in category utilities keyed by category slug/path.
- Ensure each category’s YAML is read and parsed at most once per build.
- Keep current fallback behavior (default category metadata when YAML missing/invalid).
Done Criteria / Validation
- Category lookup path is cached and no longer performs per-card sync reads.
npm run build passes.
npm run qa passes.
- Brief listing/category pages still display expected category prefix/description values.
Summary
Category metadata loading currently performs synchronous filesystem reads (
existsSync+readFileSync) during card prop generation, potentially repeating reads per brief card.Affected files:
src/lib/category.tssrc/lib/contentCardHelpers.tssrc/pages/briefs/index.astroWhy This Matters
Repeated sync I/O is non-idiomatic for repeated lookup paths and can become a build-time bottleneck as content grows.
Proposed Strategy
Map<string, BriefCategory>) in category utilities keyed by category slug/path.Done Criteria / Validation
npm run buildpasses.npm run qapasses.