diff --git a/packages/fdr-sdk/src/navigation/types/NavigationNodePage.ts b/packages/fdr-sdk/src/navigation/types/NavigationNodePage.ts index 48e425180d..1a5d6d6147 100644 --- a/packages/fdr-sdk/src/navigation/types/NavigationNodePage.ts +++ b/packages/fdr-sdk/src/navigation/types/NavigationNodePage.ts @@ -17,8 +17,9 @@ export function isPage(node: NavigationNode): node is NavigationNodePage { return ( isApiLeaf(node) || node.type === "changelog" || - node.type === "changelogYear" || - node.type === "changelogMonth" || + // TODO: Uncomment when changelog years and months are visitable + // node.type === "changelogYear" || + // node.type === "changelogMonth" || hasMarkdown(node) ); } diff --git a/packages/ui/docs-bundle/src/middleware.ts b/packages/ui/docs-bundle/src/middleware.ts index e6452495ca..76b9728529 100644 --- a/packages/ui/docs-bundle/src/middleware.ts +++ b/packages/ui/docs-bundle/src/middleware.ts @@ -1,6 +1,6 @@ // eslint-disable-next-line import/no-internal-modules import { FernUser, getAuthEdgeConfig, verifyFernJWTConfig } from "@fern-ui/ui/auth"; -import { NextRequest, NextResponse, type MiddlewareConfig, type NextMiddleware } from "next/server"; +import { NextRequest, NextResponse, type NextMiddleware } from "next/server"; import urlJoin from "url-join"; import { extractBuildId, extractNextDataPathname } from "./utils/extractNextDataPathname"; import { getPageRoute, getPageRouteMatch, getPageRoutePath } from "./utils/pageRoutes"; @@ -134,7 +134,7 @@ export const middleware: NextMiddleware = async (request) => { return NextResponse.rewrite(nextUrl, { request: { headers } }); }; -export const config: MiddlewareConfig = { +export const config = { matcher: [ /** * Match all requests to posthog diff --git a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all.ts b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all.ts index a750d4df50..e0ef5a3e7e 100644 --- a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all.ts +++ b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all.ts @@ -64,7 +64,7 @@ const handler: NextApiHandler = async ( const node = FernNavigation.utils.convertLoadDocsForUrlResponse(docs); const slugCollector = NodeCollector.collect(node); - const urls = slugCollector.getSlugs().map((slug) => urljoin(xFernHost, slug)); + const urls = slugCollector.getPageSlugs().map((slug) => urljoin(xFernHost, slug)); const results = await Promise.all( urls.map(async (url): Promise => { diff --git a/packages/ui/docs-bundle/src/utils/getDocsPageProps.ts b/packages/ui/docs-bundle/src/utils/getDocsPageProps.ts index f96e2b1081..6b837bf549 100644 --- a/packages/ui/docs-bundle/src/utils/getDocsPageProps.ts +++ b/packages/ui/docs-bundle/src/utils/getDocsPageProps.ts @@ -57,7 +57,7 @@ export async function getDocsPageProps( slug: string[], ): Promise { if (xFernHost == null || Array.isArray(xFernHost)) { - return { notFound: true }; + return { notFound: true, revalidate: true }; } const pathname = decodeURI(slug != null ? slug.join("/") : ""); @@ -71,9 +71,9 @@ export async function getDocsPageProps( console.log(`[getDocsPageProps] Fetch completed in ${end - start}ms for ${url}`); if (!docs.ok) { if ((docs.error as any).content.statusCode === 401) { - return { redirect: await getUnauthenticatedRedirect(xFernHost, `/${slug.join("/")}`) }; + return { redirect: await getUnauthenticatedRedirect(xFernHost, `/${slug.join("/")}`), revalidate: true }; } else if ((docs.error as any).content.statusCode === 404) { - return { notFound: true }; + return { notFound: true, revalidate: true }; } // eslint-disable-next-line no-console @@ -191,6 +191,7 @@ async function convertDocsToDocsPageProps({ destination: conformTrailingSlash(redirect.destination), permanent: redirect.permanent ?? false, }, + revalidate: true, }; } @@ -208,6 +209,7 @@ async function convertDocsToDocsPageProps({ destination: encodeURI(urljoin("/", root.slug)), permanent: false, }, + revalidate: true, }; } @@ -229,10 +231,11 @@ async function convertDocsToDocsPageProps({ destination: encodeURI(urljoin("/", node.redirect) || "/"), permanent: false, }, + revalidate: true, }; } - return { notFound: true }; + return { notFound: true, revalidate: true }; } if (node.type === "redirect") { @@ -241,6 +244,7 @@ async function convertDocsToDocsPageProps({ destination: encodeURI(urljoin("/", node.redirect)), permanent: false, }, + revalidate: true, }; } @@ -260,7 +264,7 @@ async function convertDocsToDocsPageProps({ if (content == null) { // eslint-disable-next-line no-console console.error(`Failed to resolve path for ${url}`); - return { notFound: true }; + return { notFound: true, revalidate: true }; } const colors = {