-
Notifications
You must be signed in to change notification settings - Fork 29
Prerender the first 300 tag pages #400
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,14 @@ const getCachedTagFromName = unstable_cache( | |
| ['tag-details'], | ||
| ); | ||
|
|
||
| const getCachedTags = unstable_cache( | ||
| async () => [ | ||
| ...(await fetchTagsData({ isCategory: true })), | ||
| ...(await fetchTagsData()).slice(0, 100), | ||
| ], | ||
|
Comment on lines
+38
to
+41
|
||
| ['tags'], | ||
| ); | ||
|
|
||
| const getCachedCategoryTags = unstable_cache( | ||
| async () => fetchTagsData({ isCategory: true }), | ||
| ['category-tags'], | ||
|
|
@@ -42,7 +50,7 @@ const getCachedCategoryTags = unstable_cache( | |
| export const generateMetadata: GenerateMetaData = async ({ params }) => { | ||
| const tagName = (await params).name.join('/'); | ||
| const data = await getCachedTagFromName([tagName]); | ||
| const categoryTags = await getCachedCategoryTags() || []; | ||
| const categoryTags = (await getCachedCategoryTags()) || []; | ||
|
|
||
| const isCategoryTag = categoryTags.includes(tagName); | ||
|
|
||
|
|
@@ -89,7 +97,7 @@ export default async function TagDetails({ | |
| } | ||
|
|
||
| export async function generateStaticParams() { | ||
| const tags = (await getCachedCategoryTags()) || []; | ||
| const tags = (await getCachedTags()) || []; | ||
| const listOfNames = tags.map((tag) => ({ name: [...tag.split('/')] })); | ||
|
|
||
| if (listOfNames.length === 0) { | ||
|
|
||
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.
getCachedTagsreturns all category tags plus the first 300 non-category tags. That meansgenerateStaticParams()can pre-render more than 300 pages (categories + 300), which seems to conflict with the PR goal of prerendering “the first 300 tag pages”. If the intent is an overall cap, apply the limit after combining (or otherwise clarify/encode the intended cap in code).