From 0fa4939a711b69076ba712ac25608b15158666de Mon Sep 17 00:00:00 2001 From: SohamBhattacharjee2003 <125297948+SohamBhattacharjee2003@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:06:37 +0530 Subject: [PATCH] fix: use React.cache() to deduplicate getPage calls --- surfsense_web/app/docs/[[...slug]]/page.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surfsense_web/app/docs/[[...slug]]/page.tsx b/surfsense_web/app/docs/[[...slug]]/page.tsx index 204148bf9..166131f90 100644 --- a/surfsense_web/app/docs/[[...slug]]/page.tsx +++ b/surfsense_web/app/docs/[[...slug]]/page.tsx @@ -2,10 +2,15 @@ import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page import { notFound } from "next/navigation"; import { source } from "@/lib/source"; 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[] }> }) { const params = await props.params; - const page = source.getPage(params.slug); + const page = getDocPage(params.slug); if (!page) notFound(); const MDX = page.data.body; @@ -37,7 +42,7 @@ export async function generateStaticParams() { export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) { const params = await props.params; - const page = source.getPage(params.slug); + const page = getDocPage(params.slug); if (!page) notFound(); return {