File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ interface CarouselItem {
4
4
id : number ;
5
5
title : string ;
6
6
content : string ;
7
+ slug : string ;
7
8
tags : string [ ] ;
8
9
notionPageId : string ;
9
10
}
@@ -13,10 +14,9 @@ export const Carousel = ({ items }: { items: CarouselItem[] }) => {
13
14
< div className = "mb-2 mt-2 w-full max-w-2xl" >
14
15
{ items . length > 0 ? (
15
16
< div className = "carousel carousel-vertical h-full w-full" >
16
- { items . map ( ( item , index ) => (
17
+ { items . map ( ( item ) => (
17
18
< Link
18
19
to = { `/blog/${ item . slug } ` }
19
- id = { `item${ index } ` }
20
20
key = { item . id }
21
21
className = "carousel-item block w-full cursor-pointer transition-all duration-300 hover:bg-gray-100"
22
22
>
Original file line number Diff line number Diff line change 1
1
import { defer , LoaderFunction , LoaderFunctionArgs } from "@remix-run/node" ;
2
- import { Await , useLoaderData } from "@remix-run/react" ;
2
+ import { Await , useLoaderData , useParams } from "@remix-run/react" ;
3
3
import { NotionAPI } from "notion-client" ;
4
4
import React , { lazy , Suspense } from "react" ;
5
5
import { ClientOnly } from "remix-utils/client-only" ;
@@ -103,6 +103,8 @@ export const loader: LoaderFunction = async ({
103
103
104
104
export default function NotionRoute ( ) {
105
105
const { recordMap } = useLoaderData < typeof loader > ( ) ;
106
+ const { slug } = useParams ( ) ;
107
+ const post = posts . find ( ( p ) => p . slug === slug ) ;
106
108
107
109
return (
108
110
< div className = "flex min-h-screen flex-col" >
@@ -117,9 +119,12 @@ export default function NotionRoute() {
117
119
}
118
120
>
119
121
< Await resolve = { recordMap } >
120
- { ( resolvedRecordMap : ExtendedRecordMap ) => (
121
- < NotionPage recordMap = { resolvedRecordMap } />
122
- ) }
122
+ { ( resolvedRecordMap : ExtendedRecordMap ) => {
123
+ if ( post ) {
124
+ document . title = post . title ;
125
+ }
126
+ return < NotionPage recordMap = { resolvedRecordMap } /> ;
127
+ } }
123
128
</ Await >
124
129
</ Suspense >
125
130
</ div >
You can’t perform that action at this time.
0 commit comments