mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 21:02:40 +02:00
Merge pull request #1075 from SohamBhattacharjee2003/fix/deduplicate-getpage-cache
fix: deduplicate getpage cache
This commit is contained in:
commit
71a5b40513
1 changed files with 7 additions and 2 deletions
|
|
@ -2,10 +2,15 @@ import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { source } from "@/lib/source";
|
import { source } from "@/lib/source";
|
||||||
import { getMDXComponents } from "@/mdx-components";
|
import { getMDXComponents } from "@/mdx-components";
|
||||||
|
import { cache } from "react";
|
||||||
|
|
||||||
|
const getDocPage = cache((slug?: string[]) => {
|
||||||
|
return source.getPage(slug);
|
||||||
|
});
|
||||||
|
|
||||||
export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {
|
export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const page = source.getPage(params.slug);
|
const page = getDocPage(params.slug);
|
||||||
if (!page) notFound();
|
if (!page) notFound();
|
||||||
|
|
||||||
const MDX = page.data.body;
|
const MDX = page.data.body;
|
||||||
|
|
@ -37,7 +42,7 @@ export async function generateStaticParams() {
|
||||||
|
|
||||||
export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) {
|
export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const page = source.getPage(params.slug);
|
const page = getDocPage(params.slug);
|
||||||
if (!page) notFound();
|
if (!page) notFound();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue