@knowcode/doc-builder 1.10.4 → 1.10.6

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.
@@ -413,7 +413,12 @@ function generateHTML(title, content, navigation, currentPath = '', config = {},
413
413
  // Get doc-builder version from package.json
414
414
  const packageJson = require('../package.json');
415
415
  const docBuilderVersion = packageJson.version;
416
-
416
+
417
+ // Extract source metadata if available
418
+ const sourceMetadata = config._sourceMetadata || {};
419
+ const sourcePath = sourceMetadata.sourcePath || '';
420
+ const generatedAt = sourceMetadata.generatedAt || new Date().toISOString();
421
+
417
422
  // SEO preparation
418
423
  let seoTags = '';
419
424
  let jsonLd = '';
@@ -498,7 +503,11 @@ function generateHTML(title, content, navigation, currentPath = '', config = {},
498
503
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
499
504
  <meta name="description" content="${escapeHtml(pageDescription || generateDescription(originalContent || content) || siteDescription)}">
500
505
  <title>${escapeHtml(finalSeoTitle || `${title} - ${siteName}`)}</title>
501
-
506
+
507
+ <!-- Source metadata -->
508
+ ${sourcePath ? `<meta name="md-source" content="${escapeHtml(sourcePath)}">` : ''}
509
+ <meta name="doc-generated" content="${escapeHtml(generatedAt)}">
510
+
502
511
  ${seoTags}
503
512
 
504
513
  <!-- Fonts -->
@@ -833,6 +842,13 @@ ${seoTags}
833
842
  mermaidEnhanced: ${config.features?.mermaidEnhanced !== false}
834
843
  }
835
844
  };
845
+
846
+ // Source metadata for JS consumers
847
+ window.__DOC_SOURCE__ = {
848
+ mdSource: ${sourcePath ? `"${escapeHtml(sourcePath)}"` : 'null'},
849
+ generatedAt: "${escapeHtml(generatedAt)}",
850
+ docBuilderVersion: "${docBuilderVersion}"
851
+ };
836
852
  </script>
837
853
  <script src="${resourcePath}js/main.js"></script>
838
854
  ${(config.features?.authentication === 'supabase' || config.features?.privateDirectoryAuth === true) ? `<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
@@ -1140,16 +1156,26 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config, useSt
1140
1156
 
1141
1157
  // Process content
1142
1158
  const htmlContent = processMarkdownContent(content, config);
1143
-
1159
+
1160
+ // Create config with source metadata for HTML generation
1161
+ const generationTimestamp = new Date().toISOString();
1162
+ const htmlConfig = {
1163
+ ...config,
1164
+ _sourceMetadata: {
1165
+ sourcePath: relativePath, // e.g., "docs/technical/local-dev-troubleshooting.md"
1166
+ generatedAt: generationTimestamp
1167
+ }
1168
+ };
1169
+
1144
1170
  // Build navigation - pass config to handle private file filtering
1145
1171
  // For static HTML, we need to build navigation with relative paths
1146
- const navConfig = useStaticHTML ? { ...config, isStaticOutput: true } : config;
1172
+ const navConfig = useStaticHTML ? { ...htmlConfig, isStaticOutput: true } : htmlConfig;
1147
1173
  const navigation = buildNavigationStructure(allFiles, urlPath, navConfig);
1148
-
1174
+
1149
1175
  // Generate full HTML (pass original content and front matter for SEO)
1150
- const html = useStaticHTML
1151
- ? generateStaticHTML(title, htmlContent, navigation, urlPath, config, content, frontMatter)
1152
- : generateHTML(title, htmlContent, navigation, urlPath, config, content, frontMatter);
1176
+ const html = useStaticHTML
1177
+ ? generateStaticHTML(title, htmlContent, navigation, urlPath, htmlConfig, content, frontMatter)
1178
+ : generateHTML(title, htmlContent, navigation, urlPath, htmlConfig, content, frontMatter);
1153
1179
 
1154
1180
  // Write file
1155
1181
  await fs.ensureDir(path.dirname(outputPath));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.10.4",
3
+ "version": "1.10.6",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {