Skip to content

Commit

Permalink
hotfix: fallback to previous year when no current posts in the year (n…
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer authored Jan 2, 2024
1 parent dbd0322 commit c013608
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions layouts/BlogCategoryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ const getCurrentCategory = (pathname: string) => {

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

// This is a React Async Server Component
Expand Down

0 comments on commit c013608

Please sign in to comment.