File tree Expand file tree Collapse file tree 3 files changed +30
-6
lines changed
app/(blog)/posts/[...slug] Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,35 @@ export async function generateStaticParams() {
14
14
return [ { slug : [ "no-post" ] } ] ;
15
15
}
16
16
17
- return posts . map ( ( post ) => ( {
18
- slug : post . urlPath . split ( "/" ) . map ( segment => encodeURIComponent ( segment ) ) ,
19
- } ) ) ;
17
+ // 로깅 추가
18
+ console . log ( "Generating static params for posts:" ) ;
19
+
20
+ return posts . map ( ( post ) => {
21
+ // 인코딩하지 않고 원래 경로 세그먼트 사용
22
+ const slugSegments = post . urlPath . split ( "/" ) ;
23
+ console . log ( `Post path: ${ post . urlPath } -> Segments: ${ slugSegments . join ( "/" ) } ` ) ;
24
+
25
+ return {
26
+ slug : slugSegments ,
27
+ } ;
28
+ } ) ;
20
29
}
21
30
22
31
export default async function PostPage ( { params } : PostPageProps ) {
23
32
const { slug } = await params ;
24
- const decodedSlug = slug . map ( ( s ) => decodeURIComponent ( s ) ) . filter ( Boolean ) ;
33
+ console . log ( "Raw URL slug segments:" , slug ) ;
34
+
35
+ // 모든 세그먼트를 명시적으로 디코딩
36
+ const decodedSlug = slug . map ( ( s ) => {
37
+ try {
38
+ return decodeURIComponent ( s ) ;
39
+ } catch ( e ) {
40
+ console . error ( `Failed to decode segment "${ s } ":` , e ) ;
41
+ return s ; // 디코딩 실패 시 원본 유지
42
+ }
43
+ } ) . filter ( Boolean ) ;
44
+
45
+ console . log ( "Decoded slug:" , decodedSlug ) ;
25
46
const post = await getPost ( decodedSlug ) ;
26
47
27
48
if ( ! post ) {
Original file line number Diff line number Diff line change @@ -53,7 +53,9 @@ const PostCard = ({
53
53
( summary || plainContent || content ) . substring ( 0 , 150 ) + "..." ;
54
54
55
55
return (
56
- < Link href = { `/posts/${ encodeURIComponent ( urlPath ) } ` } className = "block h-full" >
56
+ < Link
57
+ href = { `/posts/${ urlPath } ` }
58
+ className = "block h-full" >
57
59
< motion . div
58
60
className = "h-full group overflow-hidden rounded-lg border border-border bg-card shadow-sm hover:shadow-md"
59
61
whileHover = { {
Original file line number Diff line number Diff line change @@ -137,8 +137,9 @@ export async function getPost(slug: string[]): Promise<Post | null> {
137
137
return null ;
138
138
}
139
139
140
- // URL로 전달된 인코딩된 슬러그를 디코딩
140
+ // URL 슬러그 처리 - 인코딩/ 디코딩 없이 사용
141
141
const urlPath = slug . join ( "/" ) . replace ( / \/ + / g, "/" ) . replace ( / \. m d $ / , "" ) ;
142
+ console . log ( "Getting post with urlPath:" , urlPath ) ;
142
143
143
144
try {
144
145
// 메타데이터 타입 안전성 강화
You can’t perform that action at this time.
0 commit comments