Open kleinesfilmroellchen opened 2 years ago
I know it's not exactly what you're looking for, but here's a suggestion. If you only need a single link "out" of the book, you can add something like this to your books' theme/index.hbs
files ...
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<!-- Start extra link above the ToC -->
<a class='part-title' href='https://github.com/'>All The Things!</a>
<hr/>
<!-- End extra link above the ToC -->
{{#toc}}{{/toc}}
I'm using this idea at work, where in my spare time (hah!) I'm writing a collection of "books" about different topics under a common field. (Can't be more specific, sorry.) My plan is for each of the books to have a link "up" to a static index page which contains a list of links to each of the books. Each book's content is tracked in its own git repo, and will be hosted on GitHub Pages, with each book having a random hostname because the repos are in a private organization. The index page will be the only thing with an easy-to-remember hostname, because it'll be on an internal web server.
@kg4zow I don't actually need external links in the TOC, I wanted to replace them anyways after setting up the mdbook. This issue is just about better error behavior, if you would like this to be a feature then it's a separate question I believe.
I guess the question is whether external URLs should be allowed in the summary file. (I'd say no?)
@ISSOtm Agreed, no allowing external URLs. Again, this issue is about improving the error, not making it go away.
I suppose URLs that contain a scheme should be rejected? Other than that, I'm not sure exactly what to filter on, actually.
@ISSOtm sounds like a good solution; no need to accept explicit file://
URLs.
Given #1640, should this be an error, or a warning? The latter makes more sense if we're going for path sanitization.
Both sounds fine to me; you're more familiar with the error/warning split in mdbook than me so please choose whatever you think is better.
I'm not really, but I'd expect errors to fail the build while warnings not.
I converted some old Markdown documentation to use mdbook. My SUMMARY-like file (that I renamed) was previously pointing at online links (not that that's a good idea, but bear with me), so it looked something like this:
When putting this file into the correct directory the following happens when init-ing on these existing files:
A follow-on bug is that there is still a
book.toml
created. However,mdbook build
is not any better off:(OS error says: Syntax for file name, directory name or storage medium identifier is incorrect)
Both of these lead me to believe that it's trying to interpret the URLs as file system paths without verifying them. Replacing the URLs by the respective local files makes things work. While URLs should of course not be supported, it would be good to have a descriptive user-facing error like "Chapter XYZ links to a URL. Please point it to a valid file instead." Also, no half-baked
book.toml
should be created.