@knowcode/doc-builder 1.1.5 ā 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/lib/core-builder.js +6 -5
- package/lib/deploy.js +109 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,36 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.7] - 2025-07-19
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed CSS and JS assets not loading on deployed Vercel sites
|
|
12
|
+
- Changed all asset paths from relative to absolute URLs (/css/, /js/)
|
|
13
|
+
- Fixed missing styling on deployed documentation
|
|
14
|
+
- Corrected asset path resolution for Vercel's static hosting
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- All HTML templates now use absolute paths for CSS and JS files
|
|
18
|
+
- Logo links now use absolute paths for consistent navigation
|
|
19
|
+
- Index.html generation uses absolute asset paths
|
|
20
|
+
|
|
21
|
+
## [1.1.6] - 2025-01-19
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- Fixed missing CSS and JS styling in deployed documentation
|
|
25
|
+
- Corrected relative paths for assets (css/style.css instead of ./css/style.css)
|
|
26
|
+
- Added proper styling to fallback index.html
|
|
27
|
+
- Enhanced index.html with beautiful grid layout when no README exists
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Cache headers for CSS and JS files in vercel.json
|
|
31
|
+
- Proper meta tags and viewport settings in generated index files
|
|
32
|
+
- Beautiful card-based layout for documentation listing
|
|
33
|
+
|
|
34
|
+
### Improved
|
|
35
|
+
- Index.html now uses the same Notion-inspired styling as other pages
|
|
36
|
+
- Better visual consistency across all generated pages
|
|
37
|
+
|
|
8
38
|
## [1.1.5] - 2025-01-19
|
|
9
39
|
|
|
10
40
|
### Added
|
package/lib/core-builder.js
CHANGED
|
@@ -59,7 +59,7 @@ function processMarkdownContent(content) {
|
|
|
59
59
|
// Generate HTML from template
|
|
60
60
|
function generateHTML(title, content, navigation, currentPath = '', config = {}) {
|
|
61
61
|
const depth = currentPath.split('/').filter(p => p).length;
|
|
62
|
-
const relativePath = depth > 0 ? '../'.repeat(depth) : '
|
|
62
|
+
const relativePath = depth > 0 ? '../'.repeat(depth) : '';
|
|
63
63
|
|
|
64
64
|
const siteName = config.siteName || 'Documentation';
|
|
65
65
|
const siteDescription = config.siteDescription || 'Documentation site';
|
|
@@ -82,7 +82,8 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
82
82
|
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
|
|
83
83
|
|
|
84
84
|
<!-- Styles -->
|
|
85
|
-
<link rel="stylesheet" href="
|
|
85
|
+
<link rel="stylesheet" href="/css/notion-style.css">
|
|
86
|
+
<link rel="stylesheet" href="/css/style.css">
|
|
86
87
|
|
|
87
88
|
<!-- Favicon -->
|
|
88
89
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>š</text></svg>">
|
|
@@ -91,7 +92,7 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
91
92
|
<!-- Header -->
|
|
92
93
|
<header class="header">
|
|
93
94
|
<div class="header-content">
|
|
94
|
-
<a href="
|
|
95
|
+
<a href="/index.html" class="logo">${siteName}</a>
|
|
95
96
|
|
|
96
97
|
<div class="header-actions">
|
|
97
98
|
<div class="deployment-info">
|
|
@@ -138,8 +139,8 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
138
139
|
</div>
|
|
139
140
|
|
|
140
141
|
<!-- Scripts -->
|
|
141
|
-
<script src="
|
|
142
|
-
${config.features?.authentication ? `<script src="
|
|
142
|
+
<script src="/js/main.js"></script>
|
|
143
|
+
${config.features?.authentication ? `<script src="/js/auth.js"></script>` : ''}
|
|
143
144
|
</body>
|
|
144
145
|
</html>`;
|
|
145
146
|
}
|
package/lib/deploy.js
CHANGED
|
@@ -66,7 +66,27 @@ async function setupVercelProject(config) {
|
|
|
66
66
|
"installCommand": "",
|
|
67
67
|
"framework": null,
|
|
68
68
|
"cleanUrls": true,
|
|
69
|
-
"trailingSlash": false
|
|
69
|
+
"trailingSlash": false,
|
|
70
|
+
"headers": [
|
|
71
|
+
{
|
|
72
|
+
"source": "/css/(.*)",
|
|
73
|
+
"headers": [
|
|
74
|
+
{
|
|
75
|
+
"key": "Cache-Control",
|
|
76
|
+
"value": "public, max-age=31536000, immutable"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"source": "/js/(.*)",
|
|
82
|
+
"headers": [
|
|
83
|
+
{
|
|
84
|
+
"key": "Cache-Control",
|
|
85
|
+
"value": "public, max-age=31536000, immutable"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
70
90
|
};
|
|
71
91
|
|
|
72
92
|
fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
|
|
@@ -166,6 +186,17 @@ async function deployToVercel(config, isProd = false) {
|
|
|
166
186
|
throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
|
|
167
187
|
}
|
|
168
188
|
|
|
189
|
+
// Check if CSS files exist
|
|
190
|
+
const cssPath = path.join(outputPath, 'css', 'style.css');
|
|
191
|
+
if (!fs.existsSync(cssPath)) {
|
|
192
|
+
console.log(chalk.yellow('\nā ļø Warning: CSS files not found in output directory!'));
|
|
193
|
+
console.log(chalk.yellow(' Your documentation may appear without styling.'));
|
|
194
|
+
console.log(chalk.cyan('\nš” To fix this:'));
|
|
195
|
+
console.log(chalk.white(' 1. Update to latest version: ') + chalk.gray('npm update @knowcode/doc-builder'));
|
|
196
|
+
console.log(chalk.white(' 2. Rebuild your docs: ') + chalk.gray('npx @knowcode/doc-builder build'));
|
|
197
|
+
console.log(chalk.white(' 3. Then deploy again: ') + chalk.gray('npx @knowcode/doc-builder deploy\n'));
|
|
198
|
+
}
|
|
199
|
+
|
|
169
200
|
// Simple deployment message
|
|
170
201
|
console.log(chalk.blue('\nš Starting deployment to Vercel...'));
|
|
171
202
|
console.log(chalk.gray('This will take a few seconds...\n'));
|
|
@@ -181,7 +212,27 @@ async function deployToVercel(config, isProd = false) {
|
|
|
181
212
|
"installCommand": "",
|
|
182
213
|
"framework": null,
|
|
183
214
|
"cleanUrls": true,
|
|
184
|
-
"trailingSlash": false
|
|
215
|
+
"trailingSlash": false,
|
|
216
|
+
"headers": [
|
|
217
|
+
{
|
|
218
|
+
"source": "/css/(.*)",
|
|
219
|
+
"headers": [
|
|
220
|
+
{
|
|
221
|
+
"key": "Cache-Control",
|
|
222
|
+
"value": "public, max-age=31536000, immutable"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"source": "/js/(.*)",
|
|
228
|
+
"headers": [
|
|
229
|
+
{
|
|
230
|
+
"key": "Cache-Control",
|
|
231
|
+
"value": "public, max-age=31536000, immutable"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
]
|
|
185
236
|
};
|
|
186
237
|
fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
|
|
187
238
|
}
|
|
@@ -295,15 +346,20 @@ async function prepareDeployment(config) {
|
|
|
295
346
|
if (!fs.existsSync(indexPath)) {
|
|
296
347
|
const readmePath = path.join(outputDir, 'README.html');
|
|
297
348
|
if (fs.existsSync(readmePath)) {
|
|
298
|
-
// Create redirect to README.html
|
|
349
|
+
// Create redirect to README.html with proper styling
|
|
299
350
|
const redirectHtml = `<!DOCTYPE html>
|
|
300
351
|
<html>
|
|
301
352
|
<head>
|
|
353
|
+
<meta charset="UTF-8">
|
|
354
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
302
355
|
<meta http-equiv="refresh" content="0; url=README.html">
|
|
303
356
|
<title>Redirecting...</title>
|
|
357
|
+
<link rel="stylesheet" href="/css/style.css">
|
|
304
358
|
</head>
|
|
305
359
|
<body>
|
|
306
|
-
<
|
|
360
|
+
<div style="text-align: center; margin-top: 50px;">
|
|
361
|
+
<p>Redirecting to <a href="README.html">documentation</a>...</p>
|
|
362
|
+
</div>
|
|
307
363
|
</body>
|
|
308
364
|
</html>`;
|
|
309
365
|
fs.writeFileSync(indexPath, redirectHtml);
|
|
@@ -318,25 +374,62 @@ async function prepareDeployment(config) {
|
|
|
318
374
|
const indexHtml = `<!DOCTYPE html>
|
|
319
375
|
<html>
|
|
320
376
|
<head>
|
|
377
|
+
<meta charset="UTF-8">
|
|
378
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
321
379
|
<title>Documentation</title>
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
ul { list-style: none; padding: 0; }
|
|
326
|
-
li { margin: 10px 0; }
|
|
327
|
-
a { color: #0066cc; text-decoration: none; }
|
|
328
|
-
a:hover { text-decoration: underline; }
|
|
329
|
-
</style>
|
|
380
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
|
381
|
+
<link rel="stylesheet" href="/css/style.css">
|
|
382
|
+
<link rel="stylesheet" href="/css/notion-style.css">
|
|
330
383
|
</head>
|
|
331
384
|
<body>
|
|
332
|
-
<
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
385
|
+
<div class="navigation">
|
|
386
|
+
<div class="nav-header">
|
|
387
|
+
<h2>${config.siteName || 'Documentation'}</h2>
|
|
388
|
+
</div>
|
|
389
|
+
<nav>
|
|
390
|
+
<ul>
|
|
391
|
+
${htmlFiles.map(file => {
|
|
392
|
+
const name = file.replace('.html', '').replace(/-/g, ' ');
|
|
393
|
+
const capitalizedName = name.split(' ').map(word =>
|
|
394
|
+
word.charAt(0).toUpperCase() + word.slice(1)
|
|
395
|
+
).join(' ');
|
|
396
|
+
return `<li><a href="${file}"><i class="fas fa-file"></i> ${capitalizedName}</a></li>`;
|
|
397
|
+
}).join('\n ')}
|
|
398
|
+
</ul>
|
|
399
|
+
</nav>
|
|
400
|
+
</div>
|
|
401
|
+
<div class="content">
|
|
402
|
+
<div class="header">
|
|
403
|
+
<h1 style="text-align: center; margin: 50px 0;">š Documentation</h1>
|
|
404
|
+
</div>
|
|
405
|
+
<div class="main-content">
|
|
406
|
+
<div class="doc-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding: 20px;">
|
|
407
|
+
${htmlFiles.map(file => {
|
|
408
|
+
const name = file.replace('.html', '').replace(/-/g, ' ');
|
|
409
|
+
const capitalizedName = name.split(' ').map(word =>
|
|
410
|
+
word.charAt(0).toUpperCase() + word.slice(1)
|
|
411
|
+
).join(' ');
|
|
412
|
+
return `
|
|
413
|
+
<a href="${file}" class="doc-card" style="display: block; padding: 20px; border: 1px solid #e1e4e8; border-radius: 8px; text-decoration: none; color: inherit; transition: all 0.2s;">
|
|
414
|
+
<h3 style="margin: 0 0 10px 0; color: #0366d6;"><i class="fas fa-file-alt"></i> ${capitalizedName}</h3>
|
|
415
|
+
<p style="margin: 0; color: #586069; font-size: 14px;">Click to view this documentation</p>
|
|
416
|
+
</a>`;
|
|
417
|
+
}).join('')}
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
<script src="/js/main.js"></script>
|
|
422
|
+
<style>
|
|
423
|
+
.doc-card:hover {
|
|
424
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
425
|
+
transform: translateY(-2px);
|
|
426
|
+
}
|
|
427
|
+
</style>
|
|
336
428
|
</body>
|
|
337
429
|
</html>`;
|
|
338
430
|
fs.writeFileSync(indexPath, indexHtml);
|
|
339
431
|
console.log(chalk.green('ā
Created index.html with file listing'));
|
|
432
|
+
console.log(chalk.yellow('š Remember to rebuild before deploying to see styling!'));
|
|
340
433
|
}
|
|
341
434
|
}
|
|
342
435
|
}
|