Skip to content

Commit 1512587

Browse files
committed
fix: enable Pagefind search while preserving SSR for /admin
- Add PAGEFIND_OUTPUT_DIR env toggle to nuxt.config for static generation - Update build script to run SSR build first, then static for Pagefind indexing - Copy Pagefind assets to Vercel static output after indexing - Add .pagefind-temp to gitignore
1 parent 1adeb80 commit 1512587

File tree

3 files changed

+162
-149
lines changed

3 files changed

+162
-149
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pnpm-debug.log*
3535
# Vercel
3636
.vercel
3737

38+
# Pagefind temp output
39+
.pagefind-temp
40+
3841
# Netlify (legacy)
3942
.netlify
4043
.env*.local

nuxt.config.ts

Lines changed: 117 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,126 @@
11
import type { BundledLanguage } from "shiki";
22

3-
const highlightLangs: BundledLanguage[] = ["python", "tsx", "toml", "dotenv", "ini"];
3+
const highlightLangs: BundledLanguage[] = [
4+
"python",
5+
"tsx",
6+
"toml",
7+
"dotenv",
8+
"ini",
9+
];
410

511
const highlightOptions = {
6-
theme: {
7-
default: "github-light",
8-
light: "github-light",
9-
dark: "github-dark",
10-
},
11-
langs: highlightLangs,
12-
compress: false,
12+
theme: {
13+
default: "github-light",
14+
light: "github-light",
15+
dark: "github-dark",
16+
},
17+
langs: highlightLangs,
18+
compress: false,
1319
};
1420

21+
// Allow overriding output dir for Pagefind static generation
22+
const pagefindOutputDir = process.env.PAGEFIND_OUTPUT_DIR;
23+
1524
// https://nuxt.com/docs/api/configuration/nuxt-config
1625
export default defineNuxtConfig({
17-
compatibilityDate: "2025-07-15",
18-
devtools: { enabled: true },
19-
20-
future: {
21-
compatibilityVersion: 4,
22-
},
23-
24-
experimental: {
25-
viewTransition: true,
26-
},
27-
28-
modules: [
29-
"@nuxt/content",
30-
"@nuxtjs/tailwindcss",
31-
"@nuxt/image",
32-
"@nuxtjs/sitemap",
33-
"@nuxt/icon",
34-
"@nuxtjs/color-mode",
35-
"nuxt-studio",
36-
],
37-
38-
studio: {
39-
route: "/admin",
40-
repository: {
41-
provider: "github",
42-
owner: "Joehoel",
43-
repo: "site",
44-
branch: "master",
45-
},
46-
},
47-
48-
css: ["~/assets/css/main.css"],
49-
50-
content: {
51-
build: {
52-
markdown: {
53-
highlight: highlightOptions,
54-
},
55-
},
56-
},
57-
58-
colorMode: {
59-
classSuffix: "",
60-
preference: "system",
61-
fallback: "light",
62-
},
63-
64-
tailwindcss: {
65-
cssPath: false, // We're using our own CSS file
66-
},
67-
68-
site: {
69-
url: "https://joelkuijper.me",
70-
},
71-
72-
routeRules: {
73-
"/admin/**": { ssr: true },
74-
"/__nuxt_studio/**": { ssr: true },
75-
"/**": { prerender: true },
76-
},
77-
78-
runtimeConfig: {
79-
public: {
80-
dev: process.env.NODE_ENV !== "production",
81-
},
82-
},
83-
84-
nitro: {
85-
preset: "vercel",
86-
prerender: {
87-
// Don't fail on 404s - some content may link to draft posts
88-
failOnError: false,
89-
},
90-
},
91-
92-
app: {
93-
head: {
94-
htmlAttrs: { lang: "nl" },
95-
meta: [
96-
{ charset: "utf-8" },
97-
{ name: "viewport", content: "width=device-width, initial-scale=1" },
98-
],
99-
link: [
100-
{ rel: "icon", type: "image/svg+xml", href: "/icon.svg" },
101-
{
102-
rel: "alternate",
103-
type: "application/rss+xml",
104-
title: "RSS Feed",
105-
href: "/rss.xml",
106-
},
107-
{
108-
rel: "alternate",
109-
type: "application/rss+xml",
110-
title: "Notes RSS Feed",
111-
href: "/notes/rss.xml",
112-
},
113-
],
114-
},
115-
},
26+
compatibilityDate: "2025-07-15",
27+
devtools: { enabled: true },
28+
29+
future: {
30+
compatibilityVersion: 4,
31+
},
32+
33+
experimental: {
34+
viewTransition: true,
35+
},
36+
37+
modules: [
38+
"@nuxt/content",
39+
"@nuxtjs/tailwindcss",
40+
"@nuxt/image",
41+
"@nuxtjs/sitemap",
42+
"@nuxt/icon",
43+
"@nuxtjs/color-mode",
44+
"nuxt-studio",
45+
],
46+
47+
studio: {
48+
route: "/admin",
49+
repository: {
50+
provider: "github",
51+
owner: "Joehoel",
52+
repo: "site",
53+
branch: "master",
54+
},
55+
},
56+
57+
css: ["~/assets/css/main.css"],
58+
59+
content: {
60+
build: {
61+
markdown: {
62+
highlight: highlightOptions,
63+
},
64+
},
65+
},
66+
67+
colorMode: {
68+
classSuffix: "",
69+
preference: "system",
70+
fallback: "light",
71+
},
72+
73+
tailwindcss: {
74+
cssPath: false, // We're using our own CSS file
75+
},
76+
77+
site: {
78+
url: "https://joelkuijper.me",
79+
},
80+
81+
routeRules: {
82+
"/admin/**": { ssr: true },
83+
"/__nuxt_studio/**": { ssr: true },
84+
"/**": { prerender: true },
85+
},
86+
87+
runtimeConfig: {
88+
public: {
89+
dev: process.env.NODE_ENV !== "production",
90+
},
91+
},
92+
93+
nitro: {
94+
preset: pagefindOutputDir ? "static" : "vercel",
95+
output: pagefindOutputDir ? { dir: pagefindOutputDir } : undefined,
96+
prerender: {
97+
// Don't fail on 404s - some content may link to draft posts
98+
failOnError: false,
99+
},
100+
},
101+
102+
app: {
103+
head: {
104+
htmlAttrs: { lang: "nl" },
105+
meta: [
106+
{ charset: "utf-8" },
107+
{ name: "viewport", content: "width=device-width, initial-scale=1" },
108+
],
109+
link: [
110+
{ rel: "icon", type: "image/svg+xml", href: "/icon.svg" },
111+
{
112+
rel: "alternate",
113+
type: "application/rss+xml",
114+
title: "RSS Feed",
115+
href: "/rss.xml",
116+
},
117+
{
118+
rel: "alternate",
119+
type: "application/rss+xml",
120+
title: "Notes RSS Feed",
121+
href: "/notes/rss.xml",
122+
},
123+
],
124+
},
125+
},
116126
});

package.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
{
2-
"name": "nuxt-app",
3-
"private": true,
4-
"type": "module",
5-
"scripts": {
6-
"build": "nuxt build",
7-
"dev": "nuxt dev",
8-
"generate": "nuxt generate",
9-
"postgenerate": "pagefind --site .vercel/output/static",
10-
"preview": "nuxt preview",
11-
"postinstall": "nuxt prepare",
12-
"lint": "oxlint .",
13-
"lint:fix": "oxlint --fix .",
14-
"format": "oxfmt .",
15-
"format:check": "oxfmt --check .",
16-
"fix": "bun run lint:fix && bun run format"
17-
},
18-
"dependencies": {
19-
"@fontsource-variable/albert-sans": "^5.2.8",
20-
"@nuxt/content": "3.11.0",
21-
"@nuxt/icon": "2.2.1",
22-
"@nuxt/image": "2.0.0",
23-
"@nuxtjs/color-mode": "4.0.0",
24-
"@nuxtjs/sitemap": "7.5.2",
25-
"@nuxtjs/tailwindcss": "6.14.0",
26-
"@pagefind/default-ui": "^1.4.0",
27-
"@vercel/analytics": "^1.6.1",
28-
"better-sqlite3": "^12.6.2",
29-
"feed": "^5.2.0",
30-
"nuxt": "^4.3.0",
31-
"nuxt-studio": "^1.1.1",
32-
"vue": "^3.5.27",
33-
"vue-router": "^4.6.4"
34-
},
35-
"devDependencies": {
36-
"@tailwindcss/typography": "^0.5.19",
37-
"oxfmt": "^0.26.0",
38-
"oxlint": "1.40.0",
39-
"pagefind": "^1.4.0"
40-
},
41-
"volta": {
42-
"node": "22.22.0"
43-
}
2+
"name": "nuxt-app",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build && PAGEFIND_OUTPUT_DIR=.pagefind-temp nuxt generate && pagefind --site .pagefind-temp/public && cp -r .pagefind-temp/public/pagefind .vercel/output/static/ && rm -rf .pagefind-temp",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
10+
"preview": "nuxt preview",
11+
"postinstall": "nuxt prepare",
12+
"lint": "oxlint .",
13+
"lint:fix": "oxlint --fix .",
14+
"format": "oxfmt .",
15+
"format:check": "oxfmt --check .",
16+
"fix": "bun run lint:fix && bun run format"
17+
},
18+
"dependencies": {
19+
"@fontsource-variable/albert-sans": "^5.2.8",
20+
"@nuxt/content": "3.11.0",
21+
"@nuxt/icon": "2.2.1",
22+
"@nuxt/image": "2.0.0",
23+
"@nuxtjs/color-mode": "4.0.0",
24+
"@nuxtjs/sitemap": "7.5.2",
25+
"@nuxtjs/tailwindcss": "6.14.0",
26+
"@pagefind/default-ui": "^1.4.0",
27+
"@vercel/analytics": "^1.6.1",
28+
"better-sqlite3": "^12.6.2",
29+
"feed": "^5.2.0",
30+
"nuxt": "^4.3.0",
31+
"nuxt-studio": "^1.1.1",
32+
"vue": "^3.5.27",
33+
"vue-router": "^4.6.4"
34+
},
35+
"devDependencies": {
36+
"@tailwindcss/typography": "^0.5.19",
37+
"oxfmt": "^0.26.0",
38+
"oxlint": "1.40.0",
39+
"pagefind": "^1.4.0"
40+
},
41+
"volta": {
42+
"node": "22.22.0"
43+
}
4444
}

0 commit comments

Comments
 (0)