From e78672f74160cf1bb50b71b656f8eff9541d0f7b Mon Sep 17 00:00:00 2001 From: Vordgi Date: Sat, 16 Nov 2024 15:55:26 +0400 Subject: [PATCH] rd-395 use ...segments instead of ...path in site --- site/src/app/api/search/route.ts | 4 ++-- .../docs/{[[...path]] => [[...segments]]}/page.tsx | 14 +++++++------- site/src/app/sitemap.ts | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) rename site/src/app/docs/{[[...path]] => [[...segments]]}/page.tsx (69%) diff --git a/site/src/app/api/search/route.ts b/site/src/app/api/search/route.ts index 531fe1ed..2423e385 100644 --- a/site/src/app/api/search/route.ts +++ b/site/src/app/api/search/route.ts @@ -11,11 +11,11 @@ export const GET = async (request: Request) => { if (!search) return new Response(JSON.stringify([]), { headers }); - const staticParams = await getStaticParams('', 'path'); + const staticParams = await getStaticParams(); const docs: { href: string; raw: string; title: string }[] = []; for await (const staticParam of staticParams) { - const pathname = `/${staticParam.path.join('/')}`; + const pathname = `/${staticParam.segments.join('/')}`; const { raw, title } = await getPageData(pathname); docs.push({ href: pathname, raw, title }); } diff --git a/site/src/app/docs/[[...path]]/page.tsx b/site/src/app/docs/[[...segments]]/page.tsx similarity index 69% rename from site/src/app/docs/[[...path]]/page.tsx rename to site/src/app/docs/[[...segments]]/page.tsx index c514c50a..93e68401 100644 --- a/site/src/app/docs/[[...path]]/page.tsx +++ b/site/src/app/docs/[[...segments]]/page.tsx @@ -2,9 +2,9 @@ import { Page, getMetadata, getPageInstruction, getStaticParams } from "../robin import { Note } from "../../../components/ui/note"; import { PackageLinks } from "../../../components/ui/package-links"; -const Docs = async ({ params }: { params: Promise<{ path?: string[] }> }) => { - const { path } = await params; - const pathname = '/docs/' + (path?.join('/') || ''); +const Docs = async ({ params }: { params: Promise<{ segments?: string[] }> }) => { + const { segments } = await params; + const pathname = '/docs/' + (segments?.join('/') || ''); const pageInstriction = await getPageInstruction(pathname); return ( @@ -22,15 +22,15 @@ const Docs = async ({ params }: { params: Promise<{ path?: string[] }> }) => { ); } -export const generateMetadata = async ({ params }: { params: Promise<{ path?: string[] }> }) => { - const { path } = await params; - const pathname = '/docs/' + (path?.join('/') || ''); +export const generateMetadata = async ({ params }: { params: Promise<{ segments?: string[] }> }) => { + const { segments } = await params; + const pathname = '/docs/' + (segments?.join('/') || ''); const metadata = await getMetadata(pathname); return metadata; }; export const generateStaticParams = async () => { - const staticParams = await getStaticParams('/docs', 'path'); + const staticParams = await getStaticParams('/docs'); return staticParams; } diff --git a/site/src/app/sitemap.ts b/site/src/app/sitemap.ts index 90f18d7d..c6150ac4 100644 --- a/site/src/app/sitemap.ts +++ b/site/src/app/sitemap.ts @@ -3,11 +3,11 @@ import { type MetadataRoute } from 'next'; import { getStaticParams } from './docs/robindoc'; const sitemap = async (): Promise => { - const staticParams = await getStaticParams('', 'path'); - staticParams.push({ path: [] }); + const staticParams = await getStaticParams(); + staticParams.push({ segments: [] }); - return staticParams.map(({ path }) => ({ - url: `https://robindoc.com/${path.join('/')}/`, + return staticParams.map(({ segments }) => ({ + url: `https://robindoc.com/${segments.join('/')}/`, lastModified: new Date(), changeFrequency: 'daily', priority: 0.7,