Skip to content

Conversation

@joshrotenberg
Copy link
Contributor

@joshrotenberg joshrotenberg commented Dec 29, 2021

Add a function to find the first displayable chapter, and use it when attempting to open the browser in the build, watch and serve command line commands.

Fixes #1713.

@ehuss
Copy link
Contributor

ehuss commented Dec 31, 2021

I think an error would be fine, but if you want to try opening the first non-draft chapter, I think something like the following could work:

if let Some(first) = book.iter().filter_map(|item| match item {
    BookItem::Chapter(Chapter{path: Some(path), ..}) => Some(path),
    _ => None
}).next() {
    let path = book.build_dir_for("html").join(first).with_extension("html");
    dbg!(path);
}

Just keep in mind that the open option is used in multiple commands (build, serve, watch).

@ehuss
Copy link
Contributor

ehuss commented Mar 27, 2022

Just checking in to see if you are still interested in completing this?

@joshrotenberg
Copy link
Contributor Author

Sorry, it fell off my list. I'll pick it back up this week.

@joshrotenberg joshrotenberg marked this pull request as ready for review May 11, 2022 20:18
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit f878266 into rust-lang:master May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mdBook fails to open the web browser upon mdbook build --open, if the first link in the summary is a draft chapter (or no links exist in the summary)

2 participants