Update CMS client configuration and refactor content organization
The code changes involve a significant update to the configuration of our CMS client. The nature of retrieving content items has been refactored to be more granular, allowing for the identification and fetching of content from specified collections rather than general categories. These modifications improve the efficiency and specificity of content queries. Furthermore, other changes were made to provide a better alignment of our content structure, including the reorganization of content files and renaming of image paths in various components for consistency.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
@@ -8,13 +10,18 @@ import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
import { Post } from '../../blog/_components/post';
|
||||
|
||||
const getPostBySlug = cache(async (slug: string) => {
|
||||
const client = await createCmsClient();
|
||||
|
||||
return client.getContentItemBySlug({ slug, collection: 'posts' });
|
||||
});
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: { slug: string };
|
||||
}): Promise<Metadata | undefined> {
|
||||
const cms = await createCmsClient();
|
||||
const post = await cms.getContentItemById(params.slug);
|
||||
const post = await getPostBySlug(params.slug);
|
||||
|
||||
if (!post) {
|
||||
notFound();
|
||||
@@ -29,7 +36,7 @@ export async function generateMetadata({
|
||||
title,
|
||||
description,
|
||||
type: 'article',
|
||||
publishedTime: publishedAt.toDateString(),
|
||||
publishedTime: publishedAt?.toDateString(),
|
||||
url: post.url,
|
||||
images: image
|
||||
? [
|
||||
@@ -49,8 +56,7 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
async function BlogPost({ params }: { params: { slug: string } }) {
|
||||
const cms = await createCmsClient();
|
||||
const post = await cms.getContentItemById(params.slug);
|
||||
const post = await getPostBySlug(params.slug);
|
||||
|
||||
if (!post) {
|
||||
notFound();
|
||||
|
||||
@@ -12,7 +12,7 @@ export const Post: React.FC<{
|
||||
<div>
|
||||
<PostHeader post={post} />
|
||||
|
||||
<div className={'mx-auto flex max-w-2xl flex-col space-y-6'}>
|
||||
<div className={'mx-auto flex max-w-2xl flex-col space-y-6 py-8'}>
|
||||
<article className={styles.HTML}>
|
||||
<ContentRenderer content={content} />
|
||||
</article>
|
||||
|
||||
@@ -15,12 +15,18 @@ export const generateMetadata = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
async function BlogPage() {
|
||||
async function BlogPage({ searchParams }: { searchParams: { page: string } }) {
|
||||
const { t } = await createI18nServerInstance();
|
||||
const cms = await createCmsClient();
|
||||
|
||||
const page = searchParams.page ? parseInt(searchParams.page) : 0;
|
||||
const limit = 10;
|
||||
const offset = page * limit;
|
||||
|
||||
const posts = await cms.getContentItems({
|
||||
categories: ['blog'],
|
||||
collection: 'posts',
|
||||
limit,
|
||||
offset,
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,7 +14,7 @@ import { DocsCards } from '../_components/docs-cards';
|
||||
const getPageBySlug = cache(async (slug: string) => {
|
||||
const client = await createCmsClient();
|
||||
|
||||
return client.getContentItemById(slug);
|
||||
return client.getContentItemBySlug({ slug, collection: 'documentation' });
|
||||
});
|
||||
|
||||
interface PageParams {
|
||||
|
||||
@@ -40,11 +40,14 @@ const Node: React.FC<{
|
||||
level: number;
|
||||
activePath: string;
|
||||
}> = ({ node, level, activePath }) => {
|
||||
const pathPrefix = `/docs`;
|
||||
const url = `${pathPrefix}/${node.url}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocsNavLink
|
||||
label={node.title}
|
||||
url={node.url}
|
||||
url={url}
|
||||
level={level}
|
||||
activePath={activePath}
|
||||
/>
|
||||
|
||||
@@ -6,9 +6,11 @@ async function DocsLayout({ children }: React.PropsWithChildren) {
|
||||
const cms = await createCmsClient();
|
||||
|
||||
const pages = await cms.getContentItems({
|
||||
categories: ['documentation'],
|
||||
collection: 'documentation',
|
||||
});
|
||||
|
||||
console.log(pages);
|
||||
|
||||
return (
|
||||
<div className={'flex'}>
|
||||
<DocsNavigation pages={buildDocumentationTree(pages)} />
|
||||
|
||||
@@ -19,7 +19,7 @@ async function DocsPage() {
|
||||
const { t } = await createI18nServerInstance();
|
||||
|
||||
const docs = await client.getContentItems({
|
||||
categories: ['documentation'],
|
||||
collection: 'documentation',
|
||||
});
|
||||
|
||||
// Filter out any docs that have a parentId, as these are children of other docs
|
||||
|
||||
@@ -76,7 +76,7 @@ function Home() {
|
||||
}
|
||||
width={3069}
|
||||
height={1916}
|
||||
src={`/assets/images/dashboard-demo.webp`}
|
||||
src={`/images/dashboard-demo.webp`}
|
||||
alt={`App Image`}
|
||||
/>
|
||||
</div>
|
||||
@@ -135,7 +135,7 @@ function Home() {
|
||||
<RightFeatureContainer>
|
||||
<Image
|
||||
className="rounded-2xl"
|
||||
src={'/assets/images/sign-in.webp'}
|
||||
src={'/images/sign-in.webp'}
|
||||
width={'626'}
|
||||
height={'683'}
|
||||
alt={'Sign In'}
|
||||
@@ -147,7 +147,7 @@ function Home() {
|
||||
<LeftFeatureContainer>
|
||||
<Image
|
||||
className="rounded-2xl"
|
||||
src={'/assets/images/dashboard.webp'}
|
||||
src={'/images/dashboard.webp'}
|
||||
width={'887'}
|
||||
height={'743'}
|
||||
alt={'Dashboard'}
|
||||
|
||||
@@ -66,9 +66,9 @@ export const metadata = {
|
||||
description: appConfig.description,
|
||||
},
|
||||
icons: {
|
||||
icon: '/assets/images/favicon/favicon.ico',
|
||||
icon: '/images/favicon/favicon.ico',
|
||||
shortcut: '/shortcut-icon.png',
|
||||
apple: '/assets/images/favicon/apple-touch-icon.png',
|
||||
apple: '/images/favicon/apple-touch-icon.png',
|
||||
other: {
|
||||
rel: 'apple-touch-icon-precomposed',
|
||||
url: '/apple-touch-icon-precomposed.png',
|
||||
|
||||
Reference in New Issue
Block a user