Skip to content

Commit

Permalink
chore: Fix landing page ISR
Browse files Browse the repository at this point in the history
* chore: Testing PPR for docs landing page

* chore: Remove PPR

* chore: Dump bundle size in a file

* chore: Try fixing demo path again

* chore: Only send ISR invalidation once

* chore: Unsuspend GHA status
  • Loading branch information
franky47 authored Jan 30, 2024
1 parent 979a3d1 commit 8cc7ff2
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 167 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test-against-nextjs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ jobs:
jobName: next@${{ inputs.version }}${{ matrix.base-path && ' basePath' || ''}}${{ matrix.window-history-support && ' WHS' || ''}}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

invalidate-isr-cache:
name: Invalidate ISR cache
runs-on: ubuntu-latest
needs: test_against_nextjs_release
if: ${{ always() }}
steps:
- name: Invalidate ISR cache for GitHub Actions status on landing page
run: curl -s "https://nuqs.47ng.com/api/isr?tag=github-actions-status&token=${{ secrets.ISR_TOKEN }}"
if: always()
3 changes: 1 addition & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"dayjs": "^1.11.10",
"execa": "^8.0.1",
"lucide-react": "^0.298.0",
"next": "14.0.4",
"next": "14.1.0",
"next-docs-mdx": "^6.0.2",
"next-docs-ui": "^6.0.2",
"next-docs-zeta": "^6.0.2",
Expand Down
16 changes: 10 additions & 6 deletions packages/docs/src/app/(pages)/_landing/bundle-size.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { execa } from 'execa'
import fs from 'node:fs/promises'
import path from 'node:path'
import prettyBytes from 'pretty-bytes'

export async function BundleSize() {
const { stdout } = await execa('./node_modules/.bin/size-limit', ['--json'], {
cwd: path.resolve(process.cwd(), '../../packages/nuqs')
})
const [{ size }] = JSON.parse(stdout)
return prettyBytes(size)
const filePath = path.resolve(process.cwd(), '../../packages/nuqs/size.json')
try {
const json = await fs.readFile(filePath, 'utf8')
const [{ size }] = JSON.parse(json)
return prettyBytes(size)
} catch (error) {
console.error(error)
return 'less than 4KB'
}
}
7 changes: 2 additions & 5 deletions packages/docs/src/app/(pages)/_landing/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { CodeBlock } from '@/src/components/code-block'
import fs from 'node:fs/promises'
import path from 'node:path'
import { Suspense } from 'react'
import { Demo } from './demo.client'

export async function LandingDemo() {
const demoFilePath = path.resolve(
process.cwd(),
'src/app/(pages)/_landing/demo.client.tsx'
)
const demoFilePath =
process.cwd() + '/src/app/(pages)/_landing/demo.client.tsx'
const demoFile = await fs.readFile(demoFilePath, 'utf8')
const demoCode = demoFile
.split('\n')
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/src/app/(pages)/_landing/features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'lucide-react'
import React from 'react'
import { BundleSize } from './bundle-size'
import { GitHubActionsStatus } from './gha-status'

export function FeaturesSection(props: React.ComponentProps<'section'>) {
return (
Expand Down Expand Up @@ -113,7 +114,7 @@ export function FeaturesSection(props: React.ComponentProps<'section'>) {
title={
<span className="flex items-center">
Tested
{/* <GitHubActionsStatus className="ml-4 inline-flex" /> */}
<GitHubActionsStatus className="ml-4 inline-flex" />
</span>
}
description="Tested against every Next.js release."
Expand Down
1 change: 1 addition & 0 deletions packages/nuqs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
size.json
1 change: 1 addition & 0 deletions packages/nuqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"scripts": {
"dev": "tsup --format esm --watch --external=react",
"build": "tsup --clean --external=react",
"postbuild": "size-limit --json > size.json",
"test": "run-p test:*",
"test:types": "tsd",
"test:unit": "vitest run",
Expand Down
Loading

0 comments on commit 8cc7ff2

Please sign in to comment.