From 2a2e9005fdae80136c61ef02d596a56491a85d71 Mon Sep 17 00:00:00 2001 From: Aaron Yarborough <3855819+AaronJY@users.noreply.github.com> Date: Thu, 8 May 2025 13:49:44 +0100 Subject: [PATCH] feat: add isr to ...path --- package-lock.json | 4 ++-- src/pages/[[...path]].jsx | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3dd717..6e61a58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "www-aaronjy-me", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "www-aaronjy-me", - "version": "2.1.1", + "version": "2.1.2", "dependencies": { "@highlightjs/cdn-assets": "^11.11.1", "@mdx-js/mdx": "^3.1.0", diff --git a/src/pages/[[...path]].jsx b/src/pages/[[...path]].jsx index a4e3b8e..0aa7951 100644 --- a/src/pages/[[...path]].jsx +++ b/src/pages/[[...path]].jsx @@ -9,7 +9,25 @@ import { MDXClient } from "next-mdx-remote-client"; import { serialize } from "next-mdx-remote-client/serialize"; import { NextSeo } from "next-seo"; -export async function getServerSideProps({ params }) { +export async function getStaticPaths() { + const res = await fetchBasicPages(); + if (!res.ok) { + throw new FailedFetchBasicPagesError(); + } + + const pages = (await res.json()).data; + const paths = pages.map((page) => { + return { + params: { + path: page.path?.split("/") ?? [], + }, + }; + }); + + return { paths, fallback: false }; +} + +export async function getStaticProps({ params }) { const { path } = params; const res = await fetchBasicPages([], { path: { @@ -37,6 +55,7 @@ export async function getServerSideProps({ params }) { title, mdxSource, }, + revalidate: 60, }; }