From 32bae0f8ae32077d7b99605e5af65b5c7fe0eb89 Mon Sep 17 00:00:00 2001 From: Ole Kristian Losvik Date: Sat, 25 Jul 2026 21:32:39 +0200 Subject: [PATCH] fix(collector): a root README.md is the home page, not a broken `/.` slug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildTargetPath renamed every README.md to `.md`, which for a top-level README produced `.md` → slug `/.`. A README at the collection root now maps to index.md (slug = target, e.g. `/`), matching the function's own stated intent and making a repo's README the natural home in the zero-config `**/*.md` setup. Nested READMEs are unchanged. Co-Authored-By: Claude Opus 4.8 --- .changeset/root-readme-home.md | 8 ++++++++ packages/lectio-docs/src/collector/collect.ts | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/root-readme-home.md diff --git a/.changeset/root-readme-home.md b/.changeset/root-readme-home.md new file mode 100644 index 0000000..651534a --- /dev/null +++ b/.changeset/root-readme-home.md @@ -0,0 +1,8 @@ +--- +"@eventuras/lectio-docs": patch +--- + +A `README.md` at the collection root now becomes the home page (`/`) instead of +a broken `/.` slug — so a repo's top-level README is the natural landing page, +which is what the zero-config `**/*.md` setup wants. Nested READMEs are +unchanged (still named after their parent directory). diff --git a/packages/lectio-docs/src/collector/collect.ts b/packages/lectio-docs/src/collector/collect.ts index 65d05a2..95343ef 100644 --- a/packages/lectio-docs/src/collector/collect.ts +++ b/packages/lectio-docs/src/collector/collect.ts @@ -108,11 +108,13 @@ function buildTargetPath(file: string, source: DocSource, outputDir: string): st const fileName = basename(file); const fileDir = dirname(file); - // For glob patterns like "libs/*/README.md", use the parent directory name - // as the file name: libs/event-sdk/README.md → /libraries/event-sdk.md + // README.md is renamed so it acts as an index page. A README at the + // collection root is the site's home (index.md → the target itself, e.g. "/"); + // a nested one is named after its parent directory, so + // libs/event-sdk/README.md → /libraries/event-sdk. if (fileName.toLowerCase() === 'readme.md') { const parentDir = basename(fileDir); - const targetName = `${parentDir}.md`; + const targetName = parentDir === '.' ? 'index.md' : `${parentDir}.md`; return join(outputDir, source.target, targetName); }