From 0e3ba8db3460f2b4f0599200d3b084979522ee24 Mon Sep 17 00:00:00 2001 From: Gleb Khaykin Date: Wed, 9 Oct 2024 14:01:55 +0400 Subject: [PATCH 1/2] refactor: :hammer: --- app/components/organisms/Carousel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/organisms/Carousel.tsx b/app/components/organisms/Carousel.tsx index 6dc2964..ce85c21 100644 --- a/app/components/organisms/Carousel.tsx +++ b/app/components/organisms/Carousel.tsx @@ -4,6 +4,7 @@ interface CarouselItem { id: number; title: string; content: string; + slug: string; tags: string[]; notionPageId: string; } @@ -13,10 +14,9 @@ export const Carousel = ({ items }: { items: CarouselItem[] }) => {
{items.length > 0 ? (
- {items.map((item, index) => ( + {items.map((item) => ( From 0170dfacc74342c6cd792d9cd36779651ea42589 Mon Sep 17 00:00:00 2001 From: Gleb Khaykin Date: Wed, 9 Oct 2024 16:00:01 +0400 Subject: [PATCH 2/2] feat(links): change document title for according post title --- app/routes/blog.$slug.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/routes/blog.$slug.tsx b/app/routes/blog.$slug.tsx index 975f423..34a02ee 100644 --- a/app/routes/blog.$slug.tsx +++ b/app/routes/blog.$slug.tsx @@ -1,5 +1,5 @@ import { defer, LoaderFunction, LoaderFunctionArgs } from "@remix-run/node"; -import { Await, useLoaderData } from "@remix-run/react"; +import { Await, useLoaderData, useParams } from "@remix-run/react"; import { NotionAPI } from "notion-client"; import React, { lazy, Suspense } from "react"; import { ClientOnly } from "remix-utils/client-only"; @@ -103,6 +103,8 @@ export const loader: LoaderFunction = async ({ export default function NotionRoute() { const { recordMap } = useLoaderData(); + const { slug } = useParams(); + const post = posts.find((p) => p.slug === slug); return (
@@ -117,9 +119,12 @@ export default function NotionRoute() { } > - {(resolvedRecordMap: ExtendedRecordMap) => ( - - )} + {(resolvedRecordMap: ExtendedRecordMap) => { + if (post) { + document.title = post.title; + } + return ; + }}