-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
209 lines (194 loc) · 6.54 KB
/
nuxt.config.ts
File metadata and controls
209 lines (194 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import { readdirSync, readFileSync } from 'node:fs'
import { join, relative } from 'node:path'
import { cwd, env } from 'node:process'
import { defineNuxtConfig } from 'nuxt/config'
import topLevelAwait from 'vite-plugin-top-level-await'
import wasm from 'vite-plugin-wasm'
const baseURL = '/'
const contentRoot = join(cwd(), 'content')
const cloudflareAccountId = env.CLOUDFLARE_ACCOUNT_ID ?? 'cf9baad7d68d7ee717f3339731e81dfb'
const cloudflareContentDbId = env.CLOUDFLARE_CONTENT_DB_ID ?? '8f747fba-1896-4e11-8081-5118f7a6f39f'
function slugify(value: string) {
return value.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
}
function getFiles(dir: string): string[] {
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const fullPath = join(dir, entry.name)
if (entry.isDirectory()) {
return getFiles(fullPath)
}
return entry.isFile() ? [fullPath] : []
})
}
function isPublicDocFile(filePath: string) {
const relativePath = relative(contentRoot, filePath).replace(/\\/g, '/')
if (!relativePath.endsWith('.md')) {
return false
}
if (['README.md', 'LICENSE.md', 'rpc/methods/[method].md'].includes(relativePath)) {
return false
}
return !relativePath.split('/').some(segment => segment.startsWith('_'))
}
function contentFileToRoute(filePath: string) {
const relativePath = relative(contentRoot, filePath).replace(/\\/g, '/')
const withoutExtension = relativePath.replace(/\.md$/, '')
const normalized = withoutExtension.toLowerCase()
if (normalized === 'index') {
return '/'
}
if (normalized.endsWith('/index')) {
return `/${normalized.slice(0, -'/index'.length)}/`
}
return `/${normalized}`
}
function shouldPrerenderRoute(route: string) {
return !route.startsWith('/rpc/') && !route.startsWith('/web-client/reference/')
}
const contentRoutes = getFiles(contentRoot)
.filter(isPublicDocFile)
.map(contentFileToRoute)
const openRpcDocument = JSON.parse(readFileSync(join(cwd(), 'data/openrpc-document.json'), 'utf8')) as { methods?: Array<{ name: string }> }
const rpcMethodRoutes = (openRpcDocument.methods || []).map(method => `/rpc/methods/${slugify(method.name)}`)
const prerenderRoutes = Array.from(new Set([...contentRoutes, ...rpcMethodRoutes]))
.filter(shouldPrerenderRoute)
export default defineNuxtConfig({
extends: ['docus'],
modules: ['@nuxt/eslint'],
ssr: true,
devtools: {
enabled: true,
},
eslint: {
config: {
standalone: false,
},
},
app: {
baseURL,
head: {
meta: [
{ name: 'theme-color', content: '#f6b221' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ property: 'og:title', content: 'Nimiq Developer Center' },
{ property: 'og:description', content: 'Guides, resources and tips on how to create with Nimiq. Start building the future now!' },
{ property: 'og:url', content: 'https://nimiq.com/developers' },
{ property: 'og:image', content: `${baseURL.replace(/\/$/, '')}/og-image.png` },
{ property: 'og:site_name', content: 'Nimiq Developer Center' },
{ property: 'og:type', content: 'website' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:site', content: '@nimiq' },
{ name: 'twitter:creator', content: '@nimiq' },
],
link: [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{ rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: 'anonymous' },
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Mulish:wght@400;500;600;700;800&family=Fira+Code:wght@400;500;600;700&display=swap',
},
{ rel: 'apple-touch-icon', sizes: '180x180', href: `${baseURL}favicons/apple-touch-icon.png` },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: `${baseURL}favicons/favicon-32x32.png` },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: `${baseURL}favicons/favicon-16x16.png` },
{ rel: 'mask-icon', href: `${baseURL}favicons/safari-pinned-tab.svg`, color: '#eaaf0c' },
{ rel: 'shortcut icon', href: `${baseURL}favicons/favicon.ico` },
],
},
},
css: ['~/assets/css/main.css', 'katex/dist/katex.min.css'],
compatibilityDate: '2025-07-22',
future: {
compatibilityVersion: 4,
},
nitro: {
cloudflare: {
deployConfig: true,
wrangler: {
account_id: cloudflareAccountId,
d1_databases: [
{
binding: 'DB',
database_name: 'developer-center-dev-content',
database_id: cloudflareContentDbId,
preview_database_id: cloudflareContentDbId,
},
],
name: 'developer-center-dev-worker',
observability: { logs: { enabled: true, invocation_logs: true } },
},
},
preset: 'cloudflare_module',
prerender: {
crawlLinks: true,
failOnError: false,
autoSubfolderIndex: false,
routes: prerenderRoutes,
},
routeRules: {
'/__og-image__/**': { prerender: false },
'/api/**': { cors: true },
'/raw/**': { prerender: false },
'/rpc/**': { prerender: false },
'/web-client/reference/**': { prerender: false },
},
},
site: {
url: 'https://nimiq.com',
name: 'Nimiq Developer Center',
},
robots: {
robotsTxt: false,
},
llms: {
domain: 'https://nimiq.com/developers',
title: 'Nimiq Developer Center',
description: 'Guides, resources and tips on how to create with Nimiq. Start building the future now!',
full: {
title: 'Full Documentation',
description: 'Full documentation of the Nimiq Developer Center.',
},
},
icon: {
provider: 'iconify',
customCollections: [
{
prefix: 'custom',
dir: './app/assets/icons',
},
],
clientBundle: {
scan: true,
includeCustomCollections: true,
},
},
content: {
experimental: {
sqliteConnector: 'native',
},
build: {
markdown: {
contentHeading: false,
highlight: {
langs: ['bash', 'diff', 'json', 'js', 'ts', 'html', 'css', 'vue', 'shell', 'md', 'yaml'],
},
remarkPlugins: { 'remark-math': {}, [join(cwd(), 'remark-extract-title.mjs')]: {} },
rehypePlugins: { 'rehype-katex': {} },
},
},
},
ui: {
fonts: false,
colorMode: true,
content: false,
mdc: true,
theme: {
colors: ['primary', 'secondary', 'success', 'info', 'warning', 'error', 'neutral'],
},
},
vite: {
plugins: [wasm(), topLevelAwait()],
},
mcp: {
enabled: true,
},
} as any)