Skip to content

Commit c013608

Browse files
hotfix: fallback to previous year when no current posts in the year (#6206)
1 parent dbd0322 commit c013608

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

layouts/BlogCategoryLayout.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ const getCurrentCategory = (pathname: string) => {
2020

2121
// if either the pathname does not match to a blog page
2222
// which should not happen (as this hook should only be used in blog pages)
23-
// or if there is no category in the URL we return the current year as category name
23+
// or if there is no category in the URL we return the previous year as category name
2424
// which is always the default category (for example, the blog index)
25-
return `year-${new Date().getFullYear()}`;
25+
// see https://github.com/nodejs/nodejs.org/issues/6205 for a permanent solution
26+
return `year-${new Date().getFullYear() - 1}`;
2627
};
2728

2829
// This is a React Async Server Component

0 commit comments

Comments
 (0)