fix(build): make BLOG_YEAR scope lite builds to blog years again - #8071
leecalcote wants to merge 2 commits into
Conversation
make site-blog advertised "2026 posts only" and passed BLOG_YEAR, but nothing read it: year filtering was added in 8c73741 and removed with the rest of that change by its revert, 8d3d41b. The blog profile sourced every blog year. - build-collections: getBlogYearFilter turns BLOG_YEAR (one year or a comma-separated list) into ignore globs for the other src/collections/blog/<year> directories. It applies to lightweight builds that include the blog (content, blog profiles), warns when it cannot apply (full build, blog excluded), and fails on a value that is not a year or has no directory rather than silently building nothing. - gatsby-config: add the globs to the collections source and log the blog years in the build scope. - Makefile: site-blog defaults to the latest year directory instead of a hardcoded 2026 and accepts BLOG_YEAR overrides. - Unit tests with node:test (npm run test:unit), run in Checks CI. - CONTRIBUTING: document the blog profile, BLOG_YEAR, and make site-blog. Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
The Checks workflow has been disabled since December 2025, so the unit test step added there never runs. Build PR Preview runs on every PR; run the tests right after install, before the long site build. Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe build now supports selecting blog years for lightweight builds. It derives the default year, filters other blog directories, validates ChangesBlog year filtering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Developer
participant Makefile
participant GatsbyConfig
participant BuildCollections
Makefile->>Makefile: derive or accept BLOG_YEAR
Makefile->>GatsbyConfig: start site-blog build
GatsbyConfig->>BuildCollections: getBlogYearFilter(options)
BuildCollections-->>GatsbyConfig: selected years and ignore globs
GatsbyConfig->>GatsbyConfig: apply collection ignore patterns
GatsbyConfig-->>Developer: log selected or inactive filtering state
Merge Risk: ⚪ Minimal · up to The scoped blog build correctly selects requested years and excludes unselected year directories. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Preview deployment for PR #8071 removed. This PR preview was automatically pruned because we keep only the 3 most recently updated previews on GitHub Pages to stay within deployment size limits. If needed, push a new commit to this PR to generate a fresh preview. |
Symptom
make site-blogsays "2026 posts only, much faster builds" and passesBLOG_YEAR=2026, but the dev server sourced every blog year (2019-2026). Nothing ingatsby-config.js,gatsby-node.js, orsrc/utils/build-collections.jsreadBLOG_YEAR.Root cause
Year filtering was added in 8c73741 ("Refactor gatsby-config.js for improved configuration") as a
LITE_BUILD_PROFILE === "blog"block that rewrote the blog source path. That commit was reverted wholesale in 8d3d41b, and the year filter went with it. The Makefile targets (86786ba, 8c66231) survived, so the knob became a silent no-op. Since then, lite builds moved to a singlecollectionsfilesystem source with ignore globs frombuild-collections.js, so the old path-rewrite approach no longer fits.Fix
Year filtering is restored in the current build-scope mechanism instead of reviving the reverted block.
src/utils/build-collections.js:getBlogYearFilter()turnsBLOG_YEAR(2026or2025,2026) into ignore globs (**/collections/blog/<year>/**) for every other year directory (fromlistBlogYears()).contentandblogprofiles).BUILD_FULL_SITE=trueor a profile that excludes the blog.gatsby-config.js: appends those globs to the collections source and logsBuild Scope blog years (BLOG_YEAR): ....Makefile:site-blogdefaultsBLOG_YEARto the latest year directory instead of a hardcoded2026that goes stale every January, and acceptsBLOG_YEAR=2025,2026 make site-blog. Help text updated.src/utils/build-collections.test.js(14 cases,node:test, no new dependencies), run withnpm run test:unitin Build PR Preview right after install (Checks, where they are also added, has been disabled since December 2025). A mutation (inverting the year filter) fails 2 cases.CONTRIBUTING.mddocuments theblogprofile,BLOG_YEAR, andmake site-blog.Blog listing, category, and tag pages need no change. They query
allMdxfor theblogcollection and render whatever was sourced.Verification
LITE_BUILD_PROFILE=blog make site(all years)make site-blog(BLOG_YEAR=2026)excludes (blog): events, integrations, members, news, resourcesblog years (BLOG_YEAR): 2026/bloglisting posts/blog/ai/how-to-disable-how-is-claude-doing-this-session/blog/engineering/supercharge-your-git-workflow-with-powerful-aliases/blog,/blog/category/engineeringConfig paths checked by loading
gatsby-config.js:core+BLOG_YEAR=2026: warns "the blog collection is excluded from this build", no extra globs.BUILD_FULL_SITE=true+BLOG_YEAR=2026: warns "BUILD_FULL_SITE=true builds every blog year", no globs.BLOG_YEAR=1999: fails with "has no directory under src/collections/blog; available years: 2019, ..., 2026".BLOG_YEAR=latest: fails with "must be a comma-separated list of four-digit years".content+BLOG_YEAR=2025,2026: ignores 2019-2024.make site(emptyBLOG_YEAR): unchanged.npm run test:unit: 14/14 pass.npm run check:contributing-versionspasses.Watch for
.claude/skills/layer5-blog-writer/SKILL.mdstep 7b builds the whole blog profile to validate one post. AddingBLOG_YEAR=<post year>would make it faster. I left it out because the skill is versioned separately.<collection>/<YYYY>/layout if they want the same treatment.Summary by CodeRabbit
New Features
BLOG_YEARto build only selected blog content.Documentation
Tests