@knowcode/doc-builder 1.1.9 → 1.1.11

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 CHANGED
@@ -5,6 +5,41 @@ 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.11] - 2025-07-19
9
+
10
+ ### Fixed (MAJOR)
11
+ - **Fixed navigation completely** - HTML structure now matches JavaScript expectations
12
+ - Replaced incompatible nav-folder structure with nav-section/nav-content structure
13
+ - Navigation now works for both flat and nested folder structures
14
+ - Fixed JavaScript initialization issues with navigation elements
15
+
16
+ ### Changed
17
+ - Complete rewrite of navigation HTML generation to match main.js expectations
18
+ - Updated CSS to work with new nav-section structure
19
+ - Removed conflicting nav-flat classes in favor of universal nav-item approach
20
+
21
+ ### Technical Details
22
+ - HTML now generates `.nav-section` + `.nav-content` instead of `.nav-folder` + `.nav-folder-content`
23
+ - JavaScript can now find and initialize navigation elements properly
24
+ - Collapsible navigation works for nested structures
25
+ - Simple navigation works for flat file structures
26
+
27
+ ## [1.1.10] - 2025-07-19
28
+
29
+ ### Fixed
30
+ - Fixed navigation for flat file structures (no folders)
31
+ - Added proper CSS styling for flat navigation layouts
32
+ - Navigation now works correctly when all files are in root directory
33
+
34
+ ### Added
35
+ - Flat navigation detection and handling
36
+ - Specific CSS classes for flat vs collapsible navigation
37
+ - Improved navigation styling for simple project structures
38
+
39
+ ### Improved
40
+ - Better navigation experience for projects without folder hierarchies
41
+ - Consistent navigation styling across all project structures
42
+
8
43
  ## [1.1.9] - 2025-07-19
9
44
 
10
45
  ### Fixed
@@ -1459,4 +1459,50 @@ tr:hover {
1459
1459
  [data-tooltip]::after {
1460
1460
  display: none;
1461
1461
  }
1462
+ }
1463
+
1464
+ /* Navigation: Enhanced for all structures */
1465
+ .nav-item {
1466
+ margin-bottom: var(--space-0-5);
1467
+ }
1468
+
1469
+ .nav-item .nav-link {
1470
+ display: block;
1471
+ padding: var(--space-1) var(--space-2);
1472
+ color: var(--color-text-secondary);
1473
+ text-decoration: none;
1474
+ border-radius: var(--border-radius-md);
1475
+ transition: all 0.2s ease;
1476
+ font-size: var(--text-sm);
1477
+ font-weight: 400;
1478
+ }
1479
+
1480
+ .nav-item .nav-link:hover {
1481
+ background: var(--color-bg-hover);
1482
+ color: var(--color-text-primary);
1483
+ }
1484
+
1485
+ .nav-item.active .nav-link,
1486
+ .nav-item .nav-link.active {
1487
+ background: var(--color-accent-blue-bg);
1488
+ color: var(--color-accent-blue);
1489
+ font-weight: 500;
1490
+ }
1491
+
1492
+ /* Ensure nav sections are visible and functional */
1493
+ .nav-section {
1494
+ margin-bottom: var(--space-1);
1495
+ }
1496
+
1497
+ .nav-content {
1498
+ padding-left: var(--space-2);
1499
+ }
1500
+
1501
+ /* Override any conflicting styles */
1502
+ .navigation .nav-section .nav-content {
1503
+ display: block;
1504
+ }
1505
+
1506
+ .navigation .nav-section .nav-content.collapsed {
1507
+ display: none;
1462
1508
  }
@@ -166,49 +166,72 @@ function buildNavigationStructure(files, currentFile) {
166
166
  current.files.push(file);
167
167
  });
168
168
 
169
- // Generate HTML
170
- const generateNavHTML = (node, path = '') => {
171
- let html = '';
169
+ // Check if this is a flat structure
170
+ const hasFolders = Object.keys(tree.folders).length > 0;
171
+
172
+ if (!hasFolders) {
173
+ // Generate simple flat navigation that matches what JavaScript expects
174
+ let html = '<div class="nav-section">';
175
+ html += '<div class="nav-content">';
172
176
 
173
- // Add files
174
- node.files.forEach(file => {
177
+ tree.files.forEach(file => {
175
178
  const isActive = file.urlPath === currentFile;
176
179
  const href = file.urlPath.replace(/\\/g, '/');
177
- html += `<li class="${isActive ? 'active' : ''}">
180
+ html += `<div class="nav-item ${isActive ? 'active' : ''}">
178
181
  <a href="${href}" class="nav-link ${isActive ? 'active' : ''}">
179
- ${file.displayName}
182
+ <span class="nav-text">${file.displayName}</span>
180
183
  </a>
181
- </li>`;
184
+ </div>`;
182
185
  });
183
186
 
184
- // Add folders
185
- Object.entries(node.folders).forEach(([folderName, folderNode]) => {
186
- const folderPath = path ? `${path}/${folderName}` : folderName;
187
- const hasActiveChild = checkActiveChild(folderNode, currentFile);
187
+ html += '</div></div>';
188
+ return html;
189
+ } else {
190
+ // Generate collapsible navigation for folder structures
191
+ const generateNavHTML = (node, path = '', level = 0) => {
192
+ let html = '';
188
193
 
189
- html += `<li class="nav-folder ${hasActiveChild ? 'active' : ''}">
190
- <button class="nav-folder-toggle ${hasActiveChild ? 'active' : ''}" data-folder="${folderPath}">
191
- <i class="fas fa-chevron-${hasActiveChild ? 'down' : 'right'}"></i>
192
- ${folderName}
193
- </button>
194
- <ul class="nav-folder-content ${hasActiveChild ? 'active' : ''}">
195
- ${generateNavHTML(folderNode, folderPath)}
196
- </ul>
197
- </li>`;
198
- });
194
+ // Add folders as sections
195
+ Object.entries(node.folders).forEach(([folderName, folderNode]) => {
196
+ const folderPath = path ? `${path}/${folderName}` : folderName;
197
+ const hasActiveChild = checkActiveChild(folderNode, currentFile);
198
+ const sectionId = `nav-${folderPath.replace(/\//g, '-')}`;
199
+
200
+ html += `<div class="nav-section ${hasActiveChild ? 'expanded' : ''}">
201
+ <div class="nav-title collapsible ${hasActiveChild ? 'expanded' : ''}" data-target="${sectionId}">
202
+ <i class="fas fa-chevron-${hasActiveChild ? 'down' : 'right'}"></i>
203
+ <span class="nav-text">${folderName}</span>
204
+ </div>
205
+ <div class="nav-content ${hasActiveChild ? '' : 'collapsed'}" id="${sectionId}">
206
+ ${generateNavHTML(folderNode, folderPath, level + 1)}
207
+ </div>
208
+ </div>`;
209
+ });
210
+
211
+ // Add files
212
+ node.files.forEach(file => {
213
+ const isActive = file.urlPath === currentFile;
214
+ const href = file.urlPath.replace(/\\/g, '/');
215
+ html += `<div class="nav-item ${isActive ? 'active' : ''}">
216
+ <a href="${href}" class="nav-link ${isActive ? 'active' : ''}">
217
+ <span class="nav-text">${file.displayName}</span>
218
+ </a>
219
+ </div>`;
220
+ });
221
+
222
+ return html;
223
+ };
199
224
 
200
- return html;
201
- };
202
-
203
- const checkActiveChild = (node, currentFile) => {
204
- // Check files
205
- if (node.files.some(f => f.urlPath === currentFile)) return true;
225
+ const checkActiveChild = (node, currentFile) => {
226
+ // Check files
227
+ if (node.files.some(f => f.urlPath === currentFile)) return true;
228
+
229
+ // Check folders recursively
230
+ return Object.values(node.folders).some(folder => checkActiveChild(folder, currentFile));
231
+ };
206
232
 
207
- // Check folders recursively
208
- return Object.values(node.folders).some(folder => checkActiveChild(folder, currentFile));
209
- };
210
-
211
- return `<ul class="nav-list">${generateNavHTML(tree)}</ul>`;
233
+ return generateNavHTML(tree);
234
+ }
212
235
  }
213
236
 
214
237
  // Process single markdown file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {