diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index bafbfd52..04ee556c 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -1,6 +1,6 @@ #[cfg(feature = "watch")] use super::watch; -use crate::{get_book_dir, open}; +use crate::{first_chapter, get_book_dir, open}; use clap::{arg, App, Arg, ArgMatches}; use futures_util::sink::SinkExt; use futures_util::StreamExt; @@ -102,10 +102,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> { serve(build_dir, sockaddr, reload_tx, &file_404); }); - let serving_url = format!("http://{}", address); - info!("Serving on: {}", serving_url); - if open_browser { + let serving_url = match first_chapter(&book).map(|path| path.with_extension("html")) { + Some(path) => format!("http://{}/{}", address, path.display()), + _ => format!("http://{}", address), + }; + info!("Serving on: {}", serving_url); open(serving_url); }