Skip to content

Commit 154075e

Browse files
committed
ci(docs): add dedicated pdf builds for performance
1 parent e0bc088 commit 154075e

6 files changed

Lines changed: 212 additions & 188 deletions

File tree

apps/docs/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ VERSIONS_SRC="/versions.json"
1111
REPO_ROOT=../..
1212
EXTENSIONS_DIR="$REPO_ROOT/external/extensions"
1313

14-
BUILD_LATEST=true
14+
BUILD_LATEST=${BUILD_LATEST:-true}
1515
BUILD_REPO="git@github.com:NetLogo/docs.git"
1616
BUILD_BRANCH="main"

apps/docs/nuxt.config.pdf.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { getRoutesSubset } from '@repo/netlogo-docs/helpers';
2+
import type { DefineNuxtConfig } from 'nuxt/config';
3+
4+
const pdfOverrides: Parameters<DefineNuxtConfig>[0] = {
5+
routeRules: {
6+
'/**': { isr: 3600 },
7+
},
8+
9+
linkChecker: {
10+
enabled: false,
11+
},
12+
13+
sitemap: {
14+
enabled: false,
15+
},
16+
17+
gtag: {
18+
enabled: false,
19+
},
20+
21+
contentAssets: {
22+
debug: false,
23+
},
24+
25+
ogImage: {
26+
defaults: {
27+
extension: 'png',
28+
width: 400,
29+
height: 600,
30+
},
31+
},
32+
33+
nitro: {
34+
prerender: {
35+
autoSubfolderIndex: false,
36+
crawlLinks: false,
37+
concurrency: 20,
38+
routes: await getRoutesSubset(process.env.NITRO_PRERENDER_ROUTES?.split(',').map((route) => route.trim()) || []),
39+
},
40+
},
41+
};
42+
43+
export default pdfOverrides;

apps/docs/nuxt.config.ts

Lines changed: 161 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { deepMerge } from '@repo/utils/std/objects';
12
import tailwindcss from '@tailwindcss/vite';
23

34
import { getDocumentedExtensionBuilders } from '@repo/netlogo-docs/extension-docs';
@@ -7,166 +8,183 @@ import autogenConfig from './lib/docs/autogen.config';
78
import * as MarkdownConfig from './lib/docs/markdown.config';
89
import runDocsAutogen from './lib/docs/runDocsAutogen';
910

11+
import type { DefineNuxtConfig } from 'nuxt/config';
1012
import { publicEnvironmentVariables, verifyEnvironmentVariables } from './env.public';
13+
import pdfOverrides from './nuxt.config.pdf';
1114
import { vueUiSrc, vueUiStyles } from './turbo';
1215

16+
type NuxtConfigInput = Parameters<DefineNuxtConfig>[0];
1317
const basePath = process.env['BASE_PATH'] ?? '/';
1418

15-
// https://nuxt.com/docs/api/configuration/nuxt-config
16-
export default defineNuxtConfig({
17-
compatibilityDate: '2025-07-15',
18-
app: {
19-
baseURL: basePath,
20-
rootId: '__netlogo',
21-
},
22-
devtools: { enabled: true },
23-
ssr: true,
24-
// prettier-ignore
25-
modules: [
26-
'@nuxtjs/sitemap', // Adds sitemap.xml
27-
'@repo/nuxt-content-assets', // Local asset loading based on relative paths in Markdowns
28-
'@nuxt/content', // Query, navigation, search, and rendering of Markdown files
29-
'@nuxt/ui', // Reka-UI library for Nuxt
30-
'@nuxt/icon', // Optimized icons with iconify
31-
'nuxt-svgo', // SVG loader from file
32-
'@nuxt/eslint', // Linter
33-
'nuxt-gtag', // Google
34-
'nuxt-og-image', // Dynamic Open Graph image generation
35-
'nuxt-link-checker', // Link checking post-build
36-
],
37-
site: { url: 'https://docs.netlogo.org', name: process.env['PRODUCT_NAME'] },
38-
css: ['~/assets/styles/main.scss', '~/assets/styles/tailwind.css', vueUiStyles],
39-
colorMode: {
40-
preference: 'light',
41-
},
42-
43-
gtag: {
44-
id: 'G-ZET3KSPLMC',
45-
},
46-
47-
imports: {
48-
autoImport: true,
49-
transform: {
50-
exclude: [/\bnode_modules\b/, /\b\.git\b/],
51-
},
52-
},
19+
const isUsingPdfConfig = process.env['DOCS_ENV_PDF'] === '1';
20+
const optionalPdfLayer = isUsingPdfConfig ? pdfOverrides : {};
5321

54-
$development: {
55-
experimental: {
56-
payloadExtraction: false,
57-
},
58-
},
22+
if (isUsingPdfConfig) {
23+
console.info('[repo] Running with PDF generation configuration overrides');
24+
}
5925

60-
icon: {
61-
mode: 'css',
62-
cssLayer: 'base',
63-
},
26+
// https://nuxt.com/docs/api/configuration/nuxt-config
6427

65-
components: [
28+
export default defineNuxtConfig(
29+
deepMerge<NuxtConfigInput, NuxtConfigInput>(
6630
{
67-
path: vueUiSrc,
68-
global: true,
69-
pattern: '**/*.vue',
70-
ignore: ['**/examples/*.vue', '**/tests/*.vue'],
71-
pathPrefix: false,
72-
watch: true,
73-
},
74-
{
75-
path: '~/components',
76-
global: true,
77-
pattern: '**/*.vue',
78-
ignore: ['**/examples/*.vue', '**/tests/*.vue'],
79-
pathPrefix: false,
80-
watch: true,
81-
},
82-
],
31+
compatibilityDate: '2025-07-15',
32+
app: {
33+
baseURL: basePath,
34+
rootId: '__netlogo',
35+
},
36+
devtools: { enabled: true },
37+
ssr: true,
38+
// prettier-ignore
39+
modules: [
40+
'@nuxtjs/sitemap', // Adds sitemap.xml
41+
'@repo/nuxt-content-assets', // Local asset loading based on relative paths in Markdowns
42+
'@nuxt/content', // Query, navigation, search, and rendering of Markdown files
43+
'@nuxt/ui', // Reka-UI library for Nuxt
44+
'@nuxt/icon', // Optimized icons with iconify
45+
'nuxt-svgo', // SVG loader from file
46+
'@nuxt/eslint', // Linter
47+
'nuxt-gtag', // Google
48+
'nuxt-og-image', // Dynamic Open Graph image generation
49+
'nuxt-link-checker', // Link checking post-build
50+
],
51+
site: { url: 'https://docs.netlogo.org', name: process.env['PRODUCT_NAME'] },
52+
css: ['~/assets/styles/main.scss', '~/assets/styles/tailwind.css', vueUiStyles],
53+
colorMode: {
54+
preference: 'light',
55+
},
8356

84-
ignore: ['.build/', '.latest/', '.static/', '.preview/'],
57+
gtag: {
58+
id: 'G-ZET3KSPLMC',
59+
},
8560

86-
svgo: {
87-
customComponent: 'SvgImport',
88-
},
61+
imports: {
62+
autoImport: true,
63+
transform: {
64+
exclude: [/\bnode_modules\b/, /\b\.git\b/],
65+
},
66+
},
8967

90-
vite: {
91-
plugins: [tailwindcss()],
92-
optimizeDeps: {
93-
include: ['@repo/vue-ui', ...MarkdownConfig.externalImports],
94-
},
95-
server: {
96-
hmr: {
97-
overlay: true,
68+
$development: {
69+
experimental: {
70+
payloadExtraction: false,
71+
},
9872
},
99-
watch: { usePolling: true },
100-
},
101-
},
10273

103-
content: {
104-
build: MarkdownConfig.buildOptions,
105-
renderer: {
106-
anchorLinks: false,
107-
},
108-
watch: { enabled: false },
109-
},
110-
111-
contentAssets: {
112-
imageSize: 'style attrs',
113-
contentExtensions: 'md',
114-
debug: true,
115-
overrideStaticDimensions: false,
116-
},
117-
118-
ogImage: {
119-
defaults: {
120-
extension: 'jpeg',
121-
sharp: {
122-
quality: 70,
74+
icon: {
75+
mode: 'css',
76+
cssLayer: 'base',
12377
},
124-
},
125-
},
12678

127-
linkChecker: {
128-
excludeLinks: ['/*.pdf', `${basePath}NetLogo_User_Manual.pdf`],
129-
skipInspections: ['no-baseless', 'no-underscores', 'trailing-slash'],
130-
report: {
131-
html: process.env['CHECK'] === 'true',
132-
},
133-
},
134-
135-
runtimeConfig: {
136-
public: {
137-
extensions: (await getDocumentedExtensionBuilders(autogenConfig)).map((ext) => ({
138-
title: ext.fullName,
139-
href: `/${ext.name.toLowerCase()}`,
140-
})),
141-
...publicEnvironmentVariables,
142-
},
143-
},
79+
components: [
80+
{
81+
path: vueUiSrc,
82+
global: true,
83+
pattern: '**/*.vue',
84+
ignore: ['**/examples/*.vue', '**/tests/*.vue'],
85+
pathPrefix: false,
86+
watch: true,
87+
},
88+
{
89+
path: '~/components',
90+
global: true,
91+
pattern: '**/*.vue',
92+
ignore: ['**/examples/*.vue', '**/tests/*.vue'],
93+
pathPrefix: false,
94+
watch: true,
95+
},
96+
],
97+
98+
ignore: ['.build/', '.latest/', '.static/', '.preview/'],
99+
100+
svgo: {
101+
customComponent: 'SvgImport',
102+
},
144103

145-
hooks: {
146-
async ready() {
147-
verifyEnvironmentVariables();
104+
vite: {
105+
plugins: [tailwindcss()],
106+
optimizeDeps: {
107+
include: ['@repo/vue-ui', ...MarkdownConfig.externalImports],
108+
},
109+
server: {
110+
hmr: {
111+
overlay: true,
112+
},
113+
watch: { usePolling: true },
114+
},
115+
},
148116

149-
console.info(`[repo] Using @repo/vue-ui source path: ${vueUiSrc}`);
150-
console.info(`[repo] Using @repo/vue-ui styles path: ${vueUiStyles}`);
117+
content: {
118+
build: MarkdownConfig.buildOptions,
119+
renderer: {
120+
anchorLinks: false,
121+
},
122+
watch: { enabled: false },
123+
},
151124

152-
const noAutogen = process.env['NO_AUTOGEN'] === 'true';
153-
if (noAutogen === true) return;
154-
await runDocsAutogen();
155-
},
156-
'content:file:beforeParse'(ctx) {
157-
addNuxtContentAssetsRoot(ctx.file);
158-
},
159-
},
160-
161-
nitro: {
162-
static: true,
163-
serveStatic: true,
164-
baseURL: basePath,
165-
prerender: {
166-
autoSubfolderIndex: false,
167-
crawlLinks: true,
168-
concurrency: 1,
169-
routes: await getRoutes(),
125+
contentAssets: {
126+
imageSize: 'style attrs',
127+
contentExtensions: 'md',
128+
debug: true,
129+
overrideStaticDimensions: false,
130+
},
131+
132+
ogImage: {
133+
defaults: {
134+
extension: 'jpeg',
135+
sharp: {
136+
quality: 70,
137+
},
138+
},
139+
},
140+
141+
linkChecker: {
142+
excludeLinks: ['/*.pdf', `${basePath}NetLogo_User_Manual.pdf`],
143+
skipInspections: ['no-baseless', 'no-underscores', 'trailing-slash'],
144+
report: {
145+
html: process.env['CHECK'] === 'true',
146+
},
147+
},
148+
149+
runtimeConfig: {
150+
public: {
151+
extensions: (await getDocumentedExtensionBuilders(autogenConfig)).map((ext) => ({
152+
title: ext.fullName,
153+
href: `/${ext.name.toLowerCase()}`,
154+
})),
155+
...publicEnvironmentVariables,
156+
},
157+
},
158+
159+
hooks: {
160+
async ready() {
161+
verifyEnvironmentVariables();
162+
163+
console.info(`[repo] Using @repo/vue-ui source path: ${vueUiSrc}`);
164+
console.info(`[repo] Using @repo/vue-ui styles path: ${vueUiStyles}`);
165+
166+
const noAutogen = process.env['NO_AUTOGEN'] === 'true';
167+
if (noAutogen === true) return;
168+
await runDocsAutogen();
169+
},
170+
'content:file:beforeParse'(ctx) {
171+
addNuxtContentAssetsRoot(ctx.file);
172+
},
173+
},
174+
175+
nitro: {
176+
static: true,
177+
serveStatic: true,
178+
baseURL: basePath,
179+
prerender: {
180+
autoSubfolderIndex: false,
181+
crawlLinks: true,
182+
concurrency: 1,
183+
routes: await getRoutes(),
184+
},
185+
},
170186
},
171-
},
172-
});
187+
optionalPdfLayer,
188+
{ mergeArrays: false },
189+
),
190+
);

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"docs:deploy": "bash ./scripts/deploy.sh",
1313
"docs:preview": "bash ./scripts/preview.sh",
1414
"docs:clean-up": "bash ./scripts/clean-up.sh",
15+
"docs:build-and-generate-manual": "bash ./scripts/generate-manual/build-html.sh && yarn run docs:generate-manual",
1516
"docs:generate-manual": "bash ./scripts/generate-manual/run.sh",
1617
"docs:make-static-site": "bash ./scripts/make-static/run.sh .build/latest .build-static",
1718
"docs:all": "npm run docs:clean-up && npm run docs:build && npm run docs:generate-manual && npm run docs:deploy",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
source .env
3+
source ${BASH_SOURCE%/*}/content
4+
5+
DOCS_ENV_PDF=1 BUILD_LATEST=false ./scripts/generate.sh

0 commit comments

Comments
 (0)