Optimize content fetching and update configurations
Content fetching in the marketing section has been refactored to utilize the Next.js cache, which significantly improves performance. The date format of publishedAt has been updated to be more consistent across files. Code related to CSRF token, fonts, and metadata has been refactored into separate files for easier maintenance and readability.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import { unstable_cache as cache } from 'next/cache';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { ContentRenderer, createCmsClient } from '@kit/cms';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { unstable_cache as cache } from 'next/cache';
|
||||
|
||||
import { createCmsClient } from '@kit/cms';
|
||||
import { PageBody } from '@kit/ui/page';
|
||||
|
||||
@@ -14,14 +16,18 @@ export const generateMetadata = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
async function DocsPage() {
|
||||
const getContentItems = cache(async (resolvedLanguage: string | undefined) => {
|
||||
const client = await createCmsClient();
|
||||
const { t, resolvedLanguage } = await createI18nServerInstance();
|
||||
|
||||
const { items } = await client.getContentItems({
|
||||
return client.getContentItems({
|
||||
collection: 'documentation',
|
||||
language: resolvedLanguage,
|
||||
});
|
||||
});
|
||||
|
||||
async function DocsPage() {
|
||||
const { t, resolvedLanguage } = await createI18nServerInstance();
|
||||
const { items } = await getContentItems(resolvedLanguage);
|
||||
|
||||
// Filter out any docs that have a parentId, as these are children of other docs
|
||||
const cards = items.filter((item) => !item.parentId);
|
||||
|
||||
Reference in New Issue
Block a user