@knowcode/doc-builder 1.1.10 → 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,25 @@ 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
+
8
27
  ## [1.1.10] - 2025-07-19
9
28
 
10
29
  ### Fixed
@@ -1461,16 +1461,12 @@ tr:hover {
1461
1461
  }
1462
1462
  }
1463
1463
 
1464
- /* Navigation: Flat vs Collapsible */
1465
- .nav-flat .nav-folder-toggle {
1466
- display: none;
1467
- }
1468
-
1469
- .nav-flat li {
1464
+ /* Navigation: Enhanced for all structures */
1465
+ .nav-item {
1470
1466
  margin-bottom: var(--space-0-5);
1471
1467
  }
1472
1468
 
1473
- .nav-flat .nav-link {
1469
+ .nav-item .nav-link {
1474
1470
  display: block;
1475
1471
  padding: var(--space-1) var(--space-2);
1476
1472
  color: var(--color-text-secondary);
@@ -1481,13 +1477,32 @@ tr:hover {
1481
1477
  font-weight: 400;
1482
1478
  }
1483
1479
 
1484
- .nav-flat .nav-link:hover {
1480
+ .nav-item .nav-link:hover {
1485
1481
  background: var(--color-bg-hover);
1486
1482
  color: var(--color-text-primary);
1487
1483
  }
1488
1484
 
1489
- .nav-flat .nav-link.active {
1485
+ .nav-item.active .nav-link,
1486
+ .nav-item .nav-link.active {
1490
1487
  background: var(--color-accent-blue-bg);
1491
1488
  color: var(--color-accent-blue);
1492
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;
1493
1508
  }
@@ -166,60 +166,71 @@ 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
- const navHTML = generateNavHTML(tree);
212
-
213
- // If there are no folders (flat structure), wrap in a simple nav-list
214
- // If there are folders, use collapsible navigation
215
- const hasFolders = Object.keys(tree.folders).length > 0;
216
-
217
- if (!hasFolders) {
218
- // Simple flat navigation
219
- return `<ul class="nav-list nav-flat">${navHTML}</ul>`;
220
- } else {
221
- // Collapsible navigation with folders
222
- return `<ul class="nav-list nav-collapsible">${navHTML}</ul>`;
233
+ return generateNavHTML(tree);
223
234
  }
224
235
  }
225
236
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.1.10",
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": {