From 7ad91b52f18241a801cce395ca1f1a048cf53bb1 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 30 Jan 2024 09:29:07 +0100 Subject: [PATCH] doc: Enable ISR invalidation for latest version --- .github/workflows/ci-cd.yml | 2 ++ packages/docs/src/app/api/isr/route.ts | 2 +- packages/docs/src/app/docs/layout.tsx | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 16b40431..9ae7f4e0 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -108,3 +108,5 @@ jobs: continue-on-error: true env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Invalidate ISR cache for NPM in the docs + run: curl -s "https://nuqs.47ng.com/api/isr?tag=npm&token=${{ secrets.ISR_TOKEN }}" diff --git a/packages/docs/src/app/api/isr/route.ts b/packages/docs/src/app/api/isr/route.ts index 55928b63..d872f7cb 100644 --- a/packages/docs/src/app/api/isr/route.ts +++ b/packages/docs/src/app/api/isr/route.ts @@ -1,7 +1,7 @@ import { revalidateTag } from 'next/cache' import { NextRequest, NextResponse } from 'next/server' -const ACCEPTED_TAGS = ['github', 'github-actions-status'] +const ACCEPTED_TAGS = ['github', 'github-actions-status', 'npm'] export async function GET(req: NextRequest) { const token = req.nextUrl.searchParams.get('token') diff --git a/packages/docs/src/app/docs/layout.tsx b/packages/docs/src/app/docs/layout.tsx index 94d31b6f..464c64aa 100644 --- a/packages/docs/src/app/docs/layout.tsx +++ b/packages/docs/src/app/docs/layout.tsx @@ -43,6 +43,10 @@ async function SidebarFooter() { } async function getLatestVersion() { - const res = await fetch('https://registry.npmjs.org/nuqs').then(r => r.json()) + const res = await fetch('https://registry.npmjs.org/nuqs', { + next: { + tags: ['npm'] + } + }).then(r => r.json()) return res['dist-tags'].latest }