From c74c6829391502eeff4ae90f7dae2024780bd071 Mon Sep 17 00:00:00 2001 From: josh rotenberg Date: Wed, 11 May 2022 13:14:38 -0700 Subject: [PATCH] call find_chapter when opening browser --- src/cmd/serve.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); }