timlrx / tailwind-nextjs-starter-blog

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.
https://tailwind-nextjs-starter-blog.vercel.app/
MIT License
8.78k stars 2.04k forks source link

Blogs with Chinese tag do not show in tag page #993

Closed hansenz42 closed 1 month ago

hansenz42 commented 3 months ago

Describe the bug When clicking on a Chinese tag, no blogs are displayed on the tag page.

To Reproduce Steps:

  1. Go to 'tag page'
  2. Click on 'a Chinese tag'
  3. no blog shows

Expected behavior Blogs associated with the selected tag should be displayed on the page.

Screenshots

image

System Info (if dev / build issue):

Browser Info (if display / formatting issue):

Additional context This issue only occurs with Chinese tags; English tags work correctly. When using npm run dev, the functionality works as expected. However, the issue arises when deployed to Vercel or using npm run build.

hansenz42 commented 3 months ago

After inspecting the source code, I discovered that removing the encodeURI function around tag in the generateStaticParams method of app/tags/[tag]/page.tsx will resolve the issue.

export const generateStaticParams = async () => {
  const tagCounts = tagData as Record<string, number>
  const tagKeys = Object.keys(tagCounts)
  const paths = tagKeys.map((tag) => ({
    tag: tag,    // remove encodeURI
  }))
  return paths
}