Documentation: utils / postFileUtils
Purpose:
- Reads blog post files and metadata.
- Parses frontmatter, excerpts, and metadata from markdown files.
Lifecycle Role:
Used by blog routes and post retrieval during page rendering.
Dependencies:
Upstream:
- Filesystem
- gray-matter
- createExcerpt
- hash util
- fs, path
Downstream:
- blog route handlers
- blog services
- menu/rss/sitemap generators
Data Flow:
Inputs:
- Blog file paths
- directory and options tags/sort
Outputs:
- Parsed content and metadata
- array of post metadata objects
Side Effects:
- File reads
Performance and Scalability:
Bottlenecks:
- Disk I/O, including recursive reads
- in-memory sorting
Concurrency:
None
Security and Stability:
Validation:
- File name sanitation required
- Validate slug/tags/title/date
Vulnerabilities:
- Path traversal
- malformed frontmatter
- unsanitized metadata
Architecture Assessment:
Coupling:
Moderate coupling; filepath handling tightly linked
Abstraction:
Content loader and parser utility
Recommendations:
- Sanitize paths
- Cache parsed content using LRU or indexed cache
- Implement indexing and depth limits for recursive reads