Skip to content

Commit b61c582

Browse files
committed
Make post name support chinese
1 parent 391f4c6 commit b61c582

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

app/blog/[...slug]/page.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import 'css/prism.css'
22
import 'katex/dist/katex.css'
3-
4-
import PageTitle from '@/components/PageTitle'
5-
import { components } from '@/components/MDXComponents'
6-
import { MDXLayoutRenderer } from 'pliny/mdx-components'
7-
import { sortPosts, coreContent, allCoreContent } from 'pliny/utils/contentlayer'
8-
import { allBlogs, allAuthors } from 'contentlayer/generated'
9-
import type { Authors, Blog } from 'contentlayer/generated'
3+
import {components} from '@/components/MDXComponents'
4+
import {MDXLayoutRenderer} from 'pliny/mdx-components'
5+
import {allCoreContent, coreContent, sortPosts} from 'pliny/utils/contentlayer'
6+
import type {Authors, Blog} from 'contentlayer/generated'
7+
import {allAuthors, allBlogs} from 'contentlayer/generated'
108
import PostSimple from '@/layouts/PostSimple'
119
import PostLayout from '@/layouts/PostLayout'
1210
import PostBanner from '@/layouts/PostBanner'
13-
import { Metadata } from 'next'
11+
import {Metadata} from 'next'
1412
import siteMetadata from '@/data/siteMetadata'
15-
import { notFound } from 'next/navigation'
13+
import {notFound} from 'next/navigation'
1614

1715
const defaultLayout = 'PostLayout'
1816
const layouts = {
@@ -75,9 +73,7 @@ export async function generateMetadata({
7573
}
7674

7775
export const generateStaticParams = async () => {
78-
const paths = allBlogs.map((p) => ({ slug: p.slug.split('/') }))
79-
80-
return paths
76+
return allBlogs.map((p) => ({slug: p.slug.split('/').map(name => decodeURI(name))}))
8177
}
8278

8379
export default async function Page({ params }: { params: { slug: string[] } }) {

0 commit comments

Comments
 (0)