Skip to content

Cache brief category metadata lookups during builds #32

@plx

Description

@plx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions