-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
chore: remove blog data from providers, cache snippets #8243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors blog data handling by removing providers in favor of utility functions and enabling caching for download snippets. Since the OpenNext integration, fetching blog posts is no longer expensive as it simply loads the blog-data.json
file.
- Removes
websiteFeeds
andblogData
providers in favor offeeds
andblog
utilities - Switches
downloadSnippets
provider to use"use cache"
directive instead of React'scache()
- Moves blog data generation logic from generators to scripts directory
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
apps/site/util/feeds.ts | Adds feed generation utilities to replace websiteFeeds provider |
apps/site/util/blog.ts | Adds blog data utilities to replace blogData provider |
apps/site/scripts/blog-data/generate.mjs | Moves blog data generation logic from generators directory |
apps/site/next-data/providers/downloadSnippets.ts | Updates to use "use cache" directive |
apps/site/types/blog.ts | Changes date field from Date to string type |
Multiple component files | Updates imports to use new utility functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8243 +/- ##
==========================================
- Coverage 76.45% 75.94% -0.52%
==========================================
Files 115 115
Lines 9643 9718 +75
Branches 317 317
==========================================
+ Hits 7373 7380 +7
- Misses 2269 2337 +68
Partials 1 1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK how I feel this being all moved as an "util" as it is core pieces of the website.... But then we have also snippets, and other pieces that are important also in util. I feel these aren't util and shouldn't live there. That's why "next-data" (Data related to Next.js)
Can we rethink about moving this? It might not be needed at all and just be fine as it is (without "use cache" and react cache)
That said, I still believe this could benefit from "use cache" as could the snippet generation as they are expensive paths and generating/building them only once globally makes much more sense. "use cache" is recommended for anything computationally expensive. |
|
I still don't see why this should be an "util", also the generator isn't only sorting, it is doing mapping and a lot of other things. I don't see what's the difference of this being moved/refactored within an util folder. There's no advantage here. |
I don't think it's a "generator". All the other generators are async functions that populate data, this merely filters pre-generated data by To me, filtering seems more of a utility than a generator. WDYT @nodejs/nodejs-website? Opinions? |
This PR does two things (since they are both related to providers):
downloadSnippets
provider to"use cache"
, this was a very simple change.websiteFeeds
andblogData
providers in favor of two additionalutils
(feeds
andblog
, respectively).This is because, since the OpenNext integration, fetching blog posts is no longer an expensive task. Now, it's as simple as loading the
blog-data.json
file, which is already loaded (innext.json.mjs
). Thus, this no longer needs to be a generator/provider pair, and can be a utility.