@knowcode/doc-builder 1.4.2 → 1.4.3
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 +13 -0
- package/lib/core-builder.js +42 -9
- package/package/CACHE-BUSTING-GUIDE.md +82 -0
- package/package/CHANGELOG.md +902 -0
- package/package/README.md +248 -0
- package/package/assets/css/notion-style.css +1914 -0
- package/package/assets/js/auth.js +67 -0
- package/package/assets/js/main.js +1331 -0
- package/package/cli.js +764 -0
- package/package/index.js +38 -0
- package/package/lib/builder.js +32 -0
- package/package/lib/config.js +278 -0
- package/package/lib/core-builder.js +957 -0
- package/package/lib/deploy.js +497 -0
- package/package/lib/dev-server.js +96 -0
- package/package/package.json +34 -0
- package/package/scripts/npx-runner.js +27 -0
- package/package/scripts/setup.js +56 -0
- package/package/test-cache-bust.sh +43 -0
- package/package.json +1 -1
- package/knowcode-doc-builder-1.4.2.tgz +0 -0
- /package/{knowcode-doc-builder-1.3.15.tgz → package/knowcode-doc-builder-1.3.15.tgz} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ 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.4.3] - 2025-07-20
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Restored tooltip functionality by adding back the extractSummary function
|
|
12
|
+
- Added data-tooltip attributes to navigation items showing document summaries
|
|
13
|
+
- Removed unwanted Home link from sidebar breadcrumbs section
|
|
14
|
+
- Navigation items now display helpful summaries on hover
|
|
15
|
+
|
|
16
|
+
### Technical Details
|
|
17
|
+
- extractSummary function extracts first 150 characters of meaningful content
|
|
18
|
+
- Tooltips are properly escaped for HTML safety
|
|
19
|
+
- Sidebar header simplified by removing redundant breadcrumb navigation
|
|
20
|
+
|
|
8
21
|
## [1.4.2] - 2025-01-20
|
|
9
22
|
|
|
10
23
|
### Fixed
|
package/lib/core-builder.js
CHANGED
|
@@ -24,6 +24,36 @@ function escapeHtml(text) {
|
|
|
24
24
|
return text.replace(/[&<>"']/g, m => map[m]);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// Extract summary from markdown content for tooltips
|
|
28
|
+
function extractSummary(content, maxLength = 150) {
|
|
29
|
+
// Remove front matter
|
|
30
|
+
content = content.replace(/^---[\s\S]*?---\n/, '');
|
|
31
|
+
|
|
32
|
+
// Remove headers
|
|
33
|
+
content = content.replace(/^#+\s+.+$/gm, '');
|
|
34
|
+
|
|
35
|
+
// Remove code blocks
|
|
36
|
+
content = content.replace(/```[\s\S]*?```/g, '');
|
|
37
|
+
content = content.replace(/`[^`]+`/g, '');
|
|
38
|
+
|
|
39
|
+
// Remove images and links
|
|
40
|
+
content = content.replace(/!\[[^\]]*\]\([^)]*\)/g, '');
|
|
41
|
+
content = content.replace(/\[[^\]]*\]\([^)]*\)/g, '');
|
|
42
|
+
|
|
43
|
+
// Remove HTML tags
|
|
44
|
+
content = content.replace(/<[^>]+>/g, '');
|
|
45
|
+
|
|
46
|
+
// Remove extra whitespace
|
|
47
|
+
content = content.trim().replace(/\s+/g, ' ');
|
|
48
|
+
|
|
49
|
+
// Truncate if needed
|
|
50
|
+
if (content.length > maxLength) {
|
|
51
|
+
content = content.substring(0, maxLength).trim() + '...';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return content || 'No description available';
|
|
55
|
+
}
|
|
56
|
+
|
|
27
57
|
// Process markdown content
|
|
28
58
|
function processMarkdownContent(content) {
|
|
29
59
|
// Convert mermaid code blocks to mermaid divs with titles
|
|
@@ -144,12 +174,6 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
144
174
|
<!-- Sidebar -->
|
|
145
175
|
<aside class="sidebar">
|
|
146
176
|
<div class="sidebar-header">
|
|
147
|
-
<div class="sidebar-breadcrumbs">
|
|
148
|
-
<a href="/index.html" class="sidebar-home-link">
|
|
149
|
-
<i class="fas fa-home"></i>
|
|
150
|
-
<span>Home</span>
|
|
151
|
-
</a>
|
|
152
|
-
</div>
|
|
153
177
|
<div class="filter-box">
|
|
154
178
|
<input type="text" placeholder="Filter items..." class="filter-input" id="nav-filter">
|
|
155
179
|
<i class="fas fa-search filter-icon"></i>
|
|
@@ -321,9 +345,10 @@ function buildNavigationStructure(files, currentFile) {
|
|
|
321
345
|
}
|
|
322
346
|
|
|
323
347
|
const linkPath = '/' + file.urlPath;
|
|
348
|
+
const tooltip = file.summary ? ` data-tooltip="${escapeHtml(file.summary)}"` : '';
|
|
324
349
|
|
|
325
350
|
html += `
|
|
326
|
-
<a href="${linkPath}" class="nav-item${isActive}"><i class="fas fa-file-alt"></i> ${title}</a>`;
|
|
351
|
+
<a href="${linkPath}" class="nav-item${isActive}"${tooltip}><i class="fas fa-file-alt"></i> ${title}</a>`;
|
|
327
352
|
});
|
|
328
353
|
|
|
329
354
|
html += `</div></div>`;
|
|
@@ -402,6 +427,9 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config) {
|
|
|
402
427
|
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
403
428
|
const title = titleMatch ? titleMatch[1] : fileName;
|
|
404
429
|
|
|
430
|
+
// Extract summary for tooltip
|
|
431
|
+
const summary = extractSummary(content);
|
|
432
|
+
|
|
405
433
|
// Process content
|
|
406
434
|
const htmlContent = processMarkdownContent(content);
|
|
407
435
|
|
|
@@ -415,7 +443,7 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config) {
|
|
|
415
443
|
await fs.ensureDir(path.dirname(outputPath));
|
|
416
444
|
await fs.writeFile(outputPath, html);
|
|
417
445
|
|
|
418
|
-
return { title, urlPath };
|
|
446
|
+
return { title, urlPath, summary };
|
|
419
447
|
}
|
|
420
448
|
|
|
421
449
|
// Get all markdown files
|
|
@@ -437,11 +465,16 @@ async function getAllMarkdownFiles(dir, baseDir = dir) {
|
|
|
437
465
|
.replace(/[-_]/g, ' ')
|
|
438
466
|
.replace(/\b\w/g, l => l.toUpperCase());
|
|
439
467
|
|
|
468
|
+
// Read file to extract summary
|
|
469
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
470
|
+
const summary = extractSummary(content);
|
|
471
|
+
|
|
440
472
|
files.push({
|
|
441
473
|
path: fullPath,
|
|
442
474
|
relativePath,
|
|
443
475
|
urlPath,
|
|
444
|
-
displayName
|
|
476
|
+
displayName,
|
|
477
|
+
summary
|
|
445
478
|
});
|
|
446
479
|
}
|
|
447
480
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Cache Busting Guide for @knowcode/doc-builder
|
|
2
|
+
|
|
3
|
+
If you're not seeing updates after upgrading to a new version, it's likely due to caching. Follow these steps:
|
|
4
|
+
|
|
5
|
+
## 1. Clean Everything Locally
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Remove old build artifacts
|
|
9
|
+
rm -rf html/
|
|
10
|
+
|
|
11
|
+
# Clear npm cache
|
|
12
|
+
npm cache clean --force
|
|
13
|
+
|
|
14
|
+
# Remove node_modules and reinstall
|
|
15
|
+
rm -rf node_modules
|
|
16
|
+
npm install
|
|
17
|
+
|
|
18
|
+
# Make sure you have the latest version
|
|
19
|
+
npm install @knowcode/doc-builder@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. Rebuild with Fresh Files
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Build fresh documentation
|
|
26
|
+
npx @knowcode/doc-builder build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 3. Deploy with Force Flag
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Force Vercel to ignore cache
|
|
33
|
+
vercel --prod --force
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 4. Clear Browser Cache
|
|
37
|
+
|
|
38
|
+
- **Chrome/Edge**: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
|
|
39
|
+
- **Firefox**: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
|
|
40
|
+
- **Safari**: Cmd+Option+R
|
|
41
|
+
- Or use Incognito/Private browsing mode
|
|
42
|
+
|
|
43
|
+
## 5. Clear Vercel/CDN Cache (if applicable)
|
|
44
|
+
|
|
45
|
+
If using Vercel:
|
|
46
|
+
1. Go to your project dashboard
|
|
47
|
+
2. Settings → Functions → Purge Cache
|
|
48
|
+
3. Or redeploy with a different domain temporarily
|
|
49
|
+
|
|
50
|
+
## 6. Add Cache Busting to Your Build
|
|
51
|
+
|
|
52
|
+
Edit your `doc-builder.config.js` to add version query strings:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
module.exports = {
|
|
56
|
+
// ... other config
|
|
57
|
+
cacheBust: true, // This will add ?v=timestamp to CSS/JS files
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Common Issues
|
|
62
|
+
|
|
63
|
+
- **"I updated but nothing changed"** - It's cache. Follow all steps above.
|
|
64
|
+
- **"Tooltips still don't work"** - Clear browser cache and check console for errors
|
|
65
|
+
- **"Spacing is still wrong"** - The CSS is cached. Hard refresh the page.
|
|
66
|
+
|
|
67
|
+
## Verify You Have The Right Version
|
|
68
|
+
|
|
69
|
+
Check the version in your package.json:
|
|
70
|
+
```bash
|
|
71
|
+
npm list @knowcode/doc-builder
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Should show: `@knowcode/doc-builder@1.3.13` or higher.
|
|
75
|
+
|
|
76
|
+
## Still Not Working?
|
|
77
|
+
|
|
78
|
+
1. Open browser DevTools
|
|
79
|
+
2. Go to Network tab
|
|
80
|
+
3. Check "Disable cache" checkbox
|
|
81
|
+
4. Refresh the page
|
|
82
|
+
5. Look at the CSS/JS files being loaded - they should not show "(from cache)"
|