From 8b49600673765a56b5d6414cf580d4ac63778eb3 Mon Sep 17 00:00:00 2001 From: josh rotenberg Date: Tue, 10 May 2022 11:19:23 -0700 Subject: [PATCH] call first_chapter --- src/cmd/watch.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 78ae1968..2effd29f 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -1,3 +1,4 @@ +use crate::first_chapter; use crate::{get_book_dir, open}; use clap::{arg, App, Arg, ArgMatches}; use mdbook::errors::Result; @@ -45,7 +46,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> { if args.is_present("open") { book.build()?; - open(book.build_dir_for("html").join("index.html")); + match first_chapter(&book) + .map(|path| book.build_dir_for("html").join(path).with_extension("html")) + { + Some(path) if Path::new(&path).exists() => open(path), + _ => warn!("No chapter available to open"), + } } trigger_on_change(&book, |paths, book_dir| {