From ddc9103480d1b8059182ddf2607c99fd570bc227 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 21 Jan 2025 16:42:12 -0800 Subject: [PATCH] Disable links to empty chapters in book (#2589) --- README.md | 5 ++--- crates/generate-book/src/main.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6635196b35..5fd19ac992 100644 --- a/README.md +++ b/README.md @@ -583,9 +583,8 @@ in your editor of choice so that I may include them here. Quick Start ----------- -See [the installation section](#installation) for how to install `just` on your -computer. Try running `just --version` to make sure that it's installed -correctly. +See the installation section for how to install `just` on your computer. Try +running `just --version` to make sure that it's installed correctly. For an overview of the syntax, check out [this cheatsheet](https://cheatography.com/linux-china/cheat-sheets/justfile/). diff --git a/crates/generate-book/src/main.rs b/crates/generate-book/src/main.rs index 4c6a13c161..058fbc7b9f 100644 --- a/crates/generate-book/src/main.rs +++ b/crates/generate-book/src/main.rs @@ -185,13 +185,20 @@ fn main() -> Result { HeadingLevel::H5 => 4, HeadingLevel::H6 => 5, }; - writeln!( + + write!( summary, - "{}- [{}]({filename}.md)", + "{}- [{}](", " ".repeat(indent * 4), chapter.title(), )?; + if chapter.events.len() > 3 { + write!(summary, "{filename}.md")?; + } + + writeln!(summary, ")")?; + filenames.insert(filename); }