nrdocs 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/bin.mjs +25 -4
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -589,6 +589,21 @@ function extractTitle(markdownContent, filePath) {
589
589
  }
590
590
  return basename3.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
591
591
  }
592
+ function isSkippablePlaceholderIndex(contentDir, relativePath) {
593
+ const normalized = relativePath.replace(/\\/g, "/");
594
+ if (path4.dirname(normalized) !== ".") return false;
595
+ const full = path4.join(contentDir, normalized);
596
+ let text2;
597
+ try {
598
+ text2 = fs2.readFileSync(full, "utf-8").trim();
599
+ } catch {
600
+ return false;
601
+ }
602
+ if (text2.length === 0) return true;
603
+ if (text2.includes("Welcome to your documentation site powered by nrdocs")) return true;
604
+ if (text2.includes("Edit this file to add your documentation content")) return true;
605
+ return false;
606
+ }
592
607
  function findMarkdownFiles(dir, relativeTo) {
593
608
  const results = [];
594
609
  if (!fs2.existsSync(dir)) return results;
@@ -661,7 +676,9 @@ function groupNavEntriesByFolders(files, contentDir, indexPath = "index.md") {
661
676
  }
662
677
  function discoverNavEntries(contentDir, options) {
663
678
  const indexPath = (options?.indexPath ?? "index.md").replace(/\\/g, "/");
664
- const files = findMarkdownFiles(contentDir, contentDir);
679
+ const files = findMarkdownFiles(contentDir, contentDir).filter(
680
+ (f) => !isSkippablePlaceholderIndex(contentDir, f)
681
+ );
665
682
  return groupNavEntriesByFolders(files, contentDir, indexPath);
666
683
  }
667
684
  function navConfigToNavItems(entries, contentDir) {
@@ -7691,8 +7708,9 @@ async function handleNavGenerate(args2) {
7691
7708
  console.error(`Error: No markdown files found in ${loaded.contentDir}`);
7692
7709
  process.exit(10);
7693
7710
  }
7711
+ const pageCount = flattenNavPaths(entries).length;
7694
7712
  if (opts.json) {
7695
- console.log(JSON.stringify({ nav: entries, files: entries.length }, null, 2));
7713
+ console.log(JSON.stringify({ nav: entries, pages: pageCount }, null, 2));
7696
7714
  if (opts.dryRun) return;
7697
7715
  } else if (opts.dryRun) {
7698
7716
  console.log("# Dry run \u2014 content.nav that would be written:\n");
@@ -7701,8 +7719,11 @@ async function handleNavGenerate(args2) {
7701
7719
  }
7702
7720
  generateNavInConfig(docsDir, { generatedBy: "nrdocs nav generate", indexPath });
7703
7721
  if (!opts.json) {
7704
- console.log(`Generated navigation for ${entries.length} page(s) in ${path11.relative(process.cwd(), configPath)}`);
7705
- console.log("Edit the file to reorder or rename entries, then run publish.");
7722
+ console.log(
7723
+ `Updated content.nav (${pageCount} page(s)) in ${path11.relative(process.cwd(), configPath)}`
7724
+ );
7725
+ console.log("Only nrdocs.yml was changed \u2014 no markdown files are created or modified.");
7726
+ console.log("Edit content.nav to reorder, then publish via GitHub Actions.");
7706
7727
  }
7707
7728
  }
7708
7729
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nrdocs",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "CLI for nrdocs - serverless docs publishing for private GitHub repos",
5
5
  "type": "module",
6
6
  "bin": {