This commit updates diverse packages such as "@makerkit/data-loader-supabase-core" and "@makerkit/data-loader-supabase-nextjs" to the new versions in the package.json files. Also, several refactorings were done in logging within services and loaders by progressing 'server-only' imports and improving context handling. Additionally, type annotations have been added to several exported functions for better code readability and maintainability.
68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import { cache } from 'react';
|
|
|
|
import { notFound } from 'next/navigation';
|
|
|
|
import { ContentRenderer, createCmsClient } from '@kit/cms';
|
|
import { If } from '@kit/ui/if';
|
|
|
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
|
|
|
import { SitePageHeader } from '../../_components/site-page-header';
|
|
import styles from '../../blog/_components/html-renderer.module.css';
|
|
import { DocsCards } from '../_components/docs-cards';
|
|
|
|
const getPageBySlug = cache(async (slug: string) => {
|
|
const client = await createCmsClient();
|
|
|
|
return client.getContentItemById(slug);
|
|
});
|
|
|
|
interface PageParams {
|
|
params: {
|
|
slug: string[];
|
|
};
|
|
}
|
|
|
|
export const generateMetadata = async ({ params }: PageParams) => {
|
|
const page = await getPageBySlug(params.slug.join('/'));
|
|
|
|
if (!page) {
|
|
notFound();
|
|
}
|
|
|
|
const { title, description } = page;
|
|
|
|
return {
|
|
title,
|
|
description,
|
|
};
|
|
};
|
|
|
|
async function DocumentationPage({ params }: PageParams) {
|
|
const page = await getPageBySlug(params.slug.join('/'));
|
|
|
|
if (!page) {
|
|
notFound();
|
|
}
|
|
|
|
const description = page?.description ?? '';
|
|
|
|
return (
|
|
<div className={'flex flex-1 flex-col'}>
|
|
<SitePageHeader title={page.title} subtitle={description} />
|
|
|
|
<div className={'container flex max-w-5xl flex-col space-y-4 py-6'}>
|
|
<article className={styles.HTML}>
|
|
<ContentRenderer content={page.content} />
|
|
</article>
|
|
|
|
<If condition={page.children}>
|
|
<DocsCards cards={page.children ?? []} />
|
|
</If>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default withI18n(DocumentationPage);
|