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.82k stars 2.05k forks source link

feat: support chinese tag name #771

Closed z2015 closed 11 months ago

z2015 commented 12 months ago

For chinese tag name in devlopment mode will get error below:

Error: Page "/tags/[tag]/page" is missing param "/tags/%E6%97%A5%E8%AE%B0" in "generateStaticParams()", which is required with "output: export" config.

Should be fixed with encodeURI method.

vercel[bot] commented 12 months ago

Someone is attempting to deploy a commit to a Personal Account owned by @timlrx on Vercel.

@timlrx first needs to authorize it.

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tailwind-nextjs-starter-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2023 3:35am
klaaay commented 11 months ago

I noticed that with this modification, the "tag" in params will be encoded twice in the production environment. Thus, it needs to be decoded twice to restore its normal Chinese display.

export default function TagPage({ params }: { params: { tag: string } }) {
+   const tag = decodeURI(decodeURI(params.tag))
  // Capitalize first letter and convert space to dash
  const title = tag[0].toUpperCase() + tag.split(' ').join('-').slice(1)
  const filteredPosts = allCoreContent(
    sortPosts(allBlogs.filter((post) => post.tags && post.tags.map((t) => slug(t)).includes(tag)))
  )
  return <ListLayout posts={filteredPosts} title={title} />
}
JcobCN commented 11 months ago

@klaaay @timlrx z2015:feat/support-chinese-tag this pr in Dev mode work good but when i deploy to vercel, it takes mistake, make Chinese tag error, url= tag/页面 will show blank page, blogs do not list. restore this change and fallback last version, it works good. https://www.animeirl.top/tags/%E5%B7%A5%E5%85%B7