Skip to content

Commit

Permalink
rd-395 use ...segments instead of ...path in site
Browse files Browse the repository at this point in the history
  • Loading branch information
vordgi committed Nov 16, 2024
1 parent 91ed952 commit e78672f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions site/src/app/api/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions site/src/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { type MetadataRoute } from 'next';
import { getStaticParams } from './docs/robindoc';

const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
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,
Expand Down

0 comments on commit e78672f

Please sign in to comment.