call find_chapter when opening browser
This commit is contained in:
parent
8b49600673
commit
c74c682939
|
@ -1,6 +1,6 @@
|
||||||
#[cfg(feature = "watch")]
|
#[cfg(feature = "watch")]
|
||||||
use super::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 clap::{arg, App, Arg, ArgMatches};
|
||||||
use futures_util::sink::SinkExt;
|
use futures_util::sink::SinkExt;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
|
@ -102,10 +102,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
serve(build_dir, sockaddr, reload_tx, &file_404);
|
serve(build_dir, sockaddr, reload_tx, &file_404);
|
||||||
});
|
});
|
||||||
|
|
||||||
let serving_url = format!("http://{}", address);
|
|
||||||
info!("Serving on: {}", serving_url);
|
|
||||||
|
|
||||||
if open_browser {
|
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);
|
open(serving_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue