@kenjura/ursa 0.46.0 → 0.47.0
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 +5 -0
- package/package.json +1 -1
- package/src/jobs/generate.js +19 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/jobs/generate.js
CHANGED
|
@@ -578,7 +578,7 @@ export async function generate({
|
|
|
578
578
|
|
|
579
579
|
// Automatic index generation for folders without index.html
|
|
580
580
|
progress.log(`Checking for missing index files...`);
|
|
581
|
-
await generateAutoIndices(output, allSourceFilenamesThatAreDirectories, source, templates, menu, footer);
|
|
581
|
+
await generateAutoIndices(output, allSourceFilenamesThatAreDirectories, source, templates, menu, footer, allSourceFilenamesThatAreArticles);
|
|
582
582
|
|
|
583
583
|
// Save the hash cache to .ursa folder in source directory
|
|
584
584
|
if (hashCache.size > 0) {
|
|
@@ -631,7 +631,7 @@ export async function generate({
|
|
|
631
631
|
* @param {string} menu - Rendered menu HTML
|
|
632
632
|
* @param {string} footer - Footer HTML
|
|
633
633
|
*/
|
|
634
|
-
async function generateAutoIndices(output, directories, source, templates, menu, footer) {
|
|
634
|
+
async function generateAutoIndices(output, directories, source, templates, menu, footer, generatedArticles) {
|
|
635
635
|
// Alternate index file names to look for (in priority order)
|
|
636
636
|
const INDEX_ALTERNATES = ['_index.html', 'home.html', '_home.html'];
|
|
637
637
|
|
|
@@ -639,6 +639,17 @@ async function generateAutoIndices(output, directories, source, templates, menu,
|
|
|
639
639
|
const sourceNorm = source.replace(/\/+$/, '');
|
|
640
640
|
const outputNorm = output.replace(/\/+$/, '');
|
|
641
641
|
|
|
642
|
+
// Build set of directories that already have an index.html from a source index.md/txt/yml
|
|
643
|
+
const dirsWithSourceIndex = new Set();
|
|
644
|
+
for (const articlePath of generatedArticles) {
|
|
645
|
+
const base = basename(articlePath, extname(articlePath));
|
|
646
|
+
if (base === 'index') {
|
|
647
|
+
const dir = dirname(articlePath);
|
|
648
|
+
const outputDir = dir.replace(sourceNorm, outputNorm);
|
|
649
|
+
dirsWithSourceIndex.add(outputDir);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
642
653
|
// Get all output directories (including root)
|
|
643
654
|
const outputDirs = new Set([outputNorm]);
|
|
644
655
|
for (const dir of directories) {
|
|
@@ -653,7 +664,12 @@ async function generateAutoIndices(output, directories, source, templates, menu,
|
|
|
653
664
|
for (const dir of outputDirs) {
|
|
654
665
|
const indexPath = join(dir, 'index.html');
|
|
655
666
|
|
|
656
|
-
// Skip if index.
|
|
667
|
+
// Skip if this directory had a source index.md/txt/yml that was already processed
|
|
668
|
+
if (dirsWithSourceIndex.has(dir)) {
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// Skip if index.html already exists (e.g., created by previous run)
|
|
657
673
|
if (existsSync(indexPath)) {
|
|
658
674
|
continue;
|
|
659
675
|
}
|