This adds the ability to redirect URLs with `#` fragments. This is useful when section headers get renamed or moved to other pages. This works both for deleted pages and existing pages. The implementation requires the use of JavaScript in order to manipulate the location. (Ideally this would be handled on the server side.) This also makes it so that deleted page redirects preserve the fragment ID. Previously if you had a deleted page redirect, and the user went to something like `page.html#foo`, it would redirect to `bar.html` without the fragment. I think preserving the fragment is probably a better behavior. If the new page doesn't have the fragment ID, then no harm is really done. This is technically an open redirect, but I don't think that there is too much danger with preserving a fragment ID?
51 lines
1.4 KiB
TOML
51 lines
1.4 KiB
TOML
[book]
|
|
title = "mdBook test book"
|
|
description = "A demo book to test and validate changes"
|
|
authors = ["YJDoc2"]
|
|
language = "en"
|
|
|
|
[rust]
|
|
edition = "2018"
|
|
|
|
[output.html]
|
|
mathjax-support = true
|
|
hash-files = true
|
|
|
|
[output.html.playground]
|
|
editable = true
|
|
line-numbers = true
|
|
|
|
[output.html.search]
|
|
limit-results = 20
|
|
use-boolean-and = true
|
|
boost-title = 2
|
|
boost-hierarchy = 2
|
|
boost-paragraph = 1
|
|
expand = true
|
|
heading-split-level = 2
|
|
|
|
[output.html.redirect]
|
|
"/format/config.html" = "../prefix.html"
|
|
|
|
# This is a source without a fragment, and one with a fragment that goes to
|
|
# the same place. The redirect with the fragment is not necessary, since that
|
|
# is the default behavior.
|
|
"/pointless-fragment.html" = "prefix.html"
|
|
"/pointless-fragment.html#foo" = "prefix.html#foo"
|
|
|
|
"/rename-page-and-fragment.html" = "prefix.html"
|
|
"/rename-page-and-fragment.html#orig" = "prefix.html#new"
|
|
|
|
"/rename-page-fragment-elsewhere.html" = "prefix.html"
|
|
"/rename-page-fragment-elsewhere.html#orig" = "suffix.html#new"
|
|
|
|
# Rename fragment on an existing page.
|
|
"/prefix.html#orig" = "prefix.html#new"
|
|
# Rename fragment on an existing page to another page.
|
|
"/prefix.html#orig-new-page" = "suffix.html#new"
|
|
|
|
"/full-url-with-fragment.html" = "https://www.rust-lang.org/#fragment"
|
|
|
|
"/full-url-with-fragment-map.html" = "https://www.rust-lang.org/"
|
|
"/full-url-with-fragment-map.html#a" = "https://www.rust-lang.org/#new1"
|
|
"/full-url-with-fragment-map.html#b" = "https://www.rust-lang.org/#new2"
|