Skip to content

Commit b1ce457

Browse files
authored
Merge pull request #20 from khaykingleb/link-title
Link title
2 parents 1881501 + 0170dfa commit b1ce457

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

app/components/organisms/Carousel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface CarouselItem {
44
id: number;
55
title: string;
66
content: string;
7+
slug: string;
78
tags: string[];
89
notionPageId: string;
910
}
@@ -13,10 +14,9 @@ export const Carousel = ({ items }: { items: CarouselItem[] }) => {
1314
<div className="mb-2 mt-2 w-full max-w-2xl">
1415
{items.length > 0 ? (
1516
<div className="carousel carousel-vertical h-full w-full">
16-
{items.map((item, index) => (
17+
{items.map((item) => (
1718
<Link
1819
to={`/blog/${item.slug}`}
19-
id={`item${index}`}
2020
key={item.id}
2121
className="carousel-item block w-full cursor-pointer transition-all duration-300 hover:bg-gray-100"
2222
>

app/routes/blog.$slug.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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";
33
import { NotionAPI } from "notion-client";
44
import React, { lazy, Suspense } from "react";
55
import { ClientOnly } from "remix-utils/client-only";
@@ -103,6 +103,8 @@ export const loader: LoaderFunction = async ({
103103

104104
export default function NotionRoute() {
105105
const { recordMap } = useLoaderData<typeof loader>();
106+
const { slug } = useParams();
107+
const post = posts.find((p) => p.slug === slug);
106108

107109
return (
108110
<div className="flex min-h-screen flex-col">
@@ -117,9 +119,12 @@ export default function NotionRoute() {
117119
}
118120
>
119121
<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+
}}
123128
</Await>
124129
</Suspense>
125130
</div>

0 commit comments

Comments
 (0)