Skip to content

Commit

Permalink
doc: Enable ISR invalidation for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 committed Jan 30, 2024
1 parent 8cc7ff2 commit 7ad91b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
2 changes: 1 addition & 1 deletion packages/docs/src/app/api/isr/route.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
6 changes: 5 additions & 1 deletion packages/docs/src/app/docs/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 7ad91b5

Please sign in to comment.