From ac3ced828b3e90ffa7c4d3abee10ce346bf41707 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 5 Feb 2020 09:13:14 +0100 Subject: [PATCH] Multiple slugification strategies (#929) --- CHANGELOG.md | 4 +- Cargo.lock | 153 +++++++++--------- components/config/src/config.rs | 50 +++++- components/library/src/content/page.rs | 25 +-- components/library/src/taxonomies/mod.rs | 9 +- components/rendering/benches/all.rs | 12 +- components/rendering/src/markdown.rs | 4 +- components/rendering/tests/markdown.rs | 5 +- components/site/tests/site.rs | 16 +- components/templates/src/global_fns/mod.rs | 5 +- components/utils/Cargo.toml | 5 +- components/utils/src/site.rs | 21 ++- components/utils/src/slugs.rs | 122 ++++++-------- .../getting-started/configuration.md | 32 +++- src/cmd/serve.rs | 81 ++++------ 15 files changed, 300 insertions(+), 244 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57e619f9..fa942a38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,8 @@ ### Breaking - Remove `toc` variable in section/page context and pass it to `page.toc` and `section.toc` instead so they are accessible everywhere -- [Slugification](https://en.wikipedia.org/wiki/Slug_(web_publishing)#Slug) of page paths is now optional. By default, every path will be slugified as it is happening right now. -To keep non-ASCII characters, set `slugify_paths = true` in your config. +- [Slugification](https://en.wikipedia.org/wiki/Slug_(web_publishing)#Slug) of paths, taxonomies and anchors is now optional. By default, everything will still be slugified like in previous versions. +See documentation for information on how to disable it. ### Other - Add zenburn syntax highlighting theme diff --git a/Cargo.lock b/Cargo.lock index 5771c774..ce409d2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "aho-corasick" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -45,7 +45,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -373,7 +373,7 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -387,11 +387,11 @@ version = "2.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "rust-stemmers 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -438,7 +438,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -466,7 +466,7 @@ dependencies = [ "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "errors 0.1.0", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "tera 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -624,11 +624,11 @@ name = "globset" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "bstr 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -654,7 +654,7 @@ dependencies = [ "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -726,7 +726,7 @@ dependencies = [ [[package]] name = "hyper" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -740,9 +740,9 @@ dependencies = [ "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -755,10 +755,10 @@ dependencies = [ "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -769,9 +769,9 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -795,7 +795,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -826,7 +826,7 @@ dependencies = [ "image 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "tera 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", ] @@ -930,7 +930,7 @@ dependencies = [ "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "rendering 0.1.0", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -998,7 +998,7 @@ dependencies = [ "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_codegen 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1100,8 +1100,8 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1112,9 +1112,9 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.27 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1257,7 +1257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "open" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1265,7 +1265,7 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.26" +version = "0.10.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1273,7 +1273,7 @@ dependencies = [ "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1283,10 +1283,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.53" +version = "0.9.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1298,7 +1298,7 @@ name = "parse-zoneinfo" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1386,15 +1386,15 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pin-project-internal 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pin-project-internal" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1696,12 +1696,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1738,7 +1738,7 @@ dependencies = [ "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1759,7 +1759,7 @@ dependencies = [ "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1772,7 +1772,7 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1915,7 +1915,7 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1929,7 +1929,7 @@ name = "serde_urlencoded" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1993,7 +1993,7 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2086,10 +2086,10 @@ dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "plist 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2122,7 +2122,7 @@ dependencies = [ "mockito 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "tera 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2153,9 +2153,9 @@ dependencies = [ "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "unic-segment 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2207,7 +2207,7 @@ dependencies = [ [[package]] name = "tokio" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2219,14 +2219,15 @@ dependencies = [ "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-macros" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2237,7 +2238,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2250,7 +2251,7 @@ dependencies = [ "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2346,7 +2347,7 @@ name = "unicode-normalization" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2389,7 +2390,9 @@ name = "utils" version = "0.1.0" dependencies = [ "errors 0.1.0", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tera 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2454,7 +2457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2639,15 +2642,15 @@ dependencies = [ "errors 0.1.0", "front_matter 0.1.0", "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-staticfile 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "open 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "open 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rebuild 0.1.0", "site 0.1.0", "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2655,7 +2658,7 @@ dependencies = [ [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744" "checksum ammonia 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e266e1f4be5ffa05309f650e2586fe1d3ae6034eb24025a7ae1dfecc330823a" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" @@ -2699,7 +2702,7 @@ dependencies = [ "checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" +"checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum elasticlunr-rs 2.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f66a620976c38dbbbcd6355910432cef8b0911b3af86332029752379f0ff7924" "checksum encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" @@ -2739,7 +2742,7 @@ dependencies = [ "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf49cfb32edee45d890537d9057d1b02ed55f53b7b6a30bae83a38c9231749e" +"checksum hyper 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1c527bbc634be72aa7ba31e4e4def9bbb020f5416916279b7c705cd838893e" "checksum hyper-staticfile 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "241e2c25e6221c5bfaea5034cbf09879e30a443ad7ec674116091bab47207a5b" "checksum hyper-tls 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" @@ -2769,7 +2772,7 @@ dependencies = [ "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" "checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" -"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" +"checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" "checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2789,10 +2792,10 @@ dependencies = [ "checksum onig 4.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8518fcb2b1b8c2f45f0ad499df4fda6087fc3475ca69a185c173b8315d2fb383" "checksum onig_sys 69.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388410bf5fa341f10e58e6db3975f4bea1ac30247dd79d37a9e5ced3cb4cc3b0" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum open 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "94b424e1086328b0df10235c6ff47be63708071881bead9e76997d9291c0134b" -"checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" +"checksum open 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dfa632621d66502e1e9298c038d903090fc810a33cc1e6a02958fa0be65e3fb" +"checksum openssl 0.10.27 (registry+https://github.com/rust-lang/crates.io-index)" = "e176a45fedd4c990e26580847a525e39e16ec32ac78957dbf62ded31b3abfd6f" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" +"checksum openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)" = "1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986" "checksum parse-zoneinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "feece9d0113b400182a7d00adcff81ccf29158c49c5abd11e2eed8589bf6ff07" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" @@ -2804,8 +2807,8 @@ dependencies = [ "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -"checksum pin-project 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "75fca1c4ff21f60ca2d37b80d72b63dab823a9d19d3cda3a81d18bc03f0ba8c5" -"checksum pin-project-internal 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6544cd4e4ecace61075a6ec78074beeef98d58aa9a3d07d053d993b2946a90d6" +"checksum pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" +"checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" "checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" @@ -2839,9 +2842,9 @@ dependencies = [ "checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" +"checksum regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" +"checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0e798e19e258bf6c30a304622e3e9ac820e483b06a1857a026e1f109b113fe4" "checksum rust-stemmers 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e46a2036019fdb888131db7a4c847a1063a7493f971ed94ea82c67eada63ca54" @@ -2860,14 +2863,14 @@ dependencies = [ "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -"checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" +"checksum serde_json 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "21b01d7f0288608a01dca632cf1df859df6fd6ffa885300fc275ce2ba6221953" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" "checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slotmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c46a3482db8f247956e464d783693ece164ca056e6e67563ee5505bdb86452cd" "checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" -"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" +"checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum string_cache 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" "checksum string_cache_codegen 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" @@ -2886,8 +2889,8 @@ dependencies = [ "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b7c2cfc4742bd8a32f2e614339dd8ce30dbcf676bb262bd63a2327bc5df57d" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c1fc73332507b971a5010664991a441b5ee0de92017f5a0e8b00fd684573045b" -"checksum tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "50a61f268a3db2acee8dcab514efc813dc6dbe8a00e86076f935f94304b59a7a" +"checksum tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b" +"checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c" "checksum tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828" "checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" "checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" diff --git a/components/config/src/config.rs b/components/config/src/config.rs index 6319afd8..210f60ef 100644 --- a/components/config/src/config.rs +++ b/components/config/src/config.rs @@ -12,6 +12,7 @@ use crate::highlighting::THEME_SET; use crate::theme::Theme; use errors::{bail, Error, Result}; use utils::fs::read_file_with_error; +use utils::slugs::SlugifyStrategy; // We want a default base url for tests static DEFAULT_BASE_URL: &str = "http://a-website.com"; @@ -23,6 +24,24 @@ pub enum Mode { Check, } +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Slugify { + pub paths: SlugifyStrategy, + pub taxonomies: SlugifyStrategy, + pub anchors: SlugifyStrategy, +} + +impl Default for Slugify { + fn default() -> Self { + Slugify { + paths: SlugifyStrategy::On, + taxonomies: SlugifyStrategy::On, + anchors: SlugifyStrategy::On, + } + } +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(default)] pub struct Language { @@ -35,7 +54,7 @@ pub struct Language { } impl Default for Language { - fn default() -> Language { + fn default() -> Self { Language { code: String::new(), rss: false, search: false } } } @@ -75,7 +94,7 @@ impl Taxonomy { } impl Default for Taxonomy { - fn default() -> Taxonomy { + fn default() -> Self { Taxonomy { name: String::new(), paginate_by: None, @@ -130,8 +149,6 @@ pub struct Config { /// key into different language. translations: HashMap, - /// Whether to slugify page and taxonomy URLs (disable for UTF-8 URLs) - pub slugify_paths: bool, /// Whether to highlight all code blocks found in markdown files. Defaults to false pub highlight_code: bool, /// Which themes to use for code highlighting. See Readme for supported themes @@ -171,6 +188,9 @@ pub struct Config { pub link_checker: LinkChecker, + /// The setup for which slugification strategies to use for paths, taxonomies and anchors + pub slugify: Slugify, + /// All user params set in [extra] in the config pub extra: HashMap, @@ -356,7 +376,6 @@ impl Default for Config { title: None, description: None, theme: None, - slugify_paths: true, highlight_code: false, highlight_theme: "base16-ocean-dark".to_string(), default_language: "en".to_string(), @@ -374,6 +393,7 @@ impl Default for Config { extra_syntaxes: Vec::new(), extra_syntax_set: None, link_checker: LinkChecker::default(), + slugify: Slugify::default(), extra: HashMap::new(), build_timestamp: Some(1), } @@ -382,7 +402,7 @@ impl Default for Config { #[cfg(test)] mod tests { - use super::{Config, Theme}; + use super::{Config, SlugifyStrategy, Theme}; #[test] fn can_import_valid_config() { @@ -619,4 +639,22 @@ skip_prefixes = [ vec!["http://[2001:db8::]/", "https://www.example.com/path",] ); } + + #[test] + fn slugify_strategies() { + let config_str = r#" +title = "My site" +base_url = "example.com" + +[slugify] +paths = "on" +taxonomies = "safe" +anchors = "off" + "#; + + let config = Config::parse(config_str).unwrap(); + assert_eq!(config.slugify.paths, SlugifyStrategy::On); + assert_eq!(config.slugify.taxonomies, SlugifyStrategy::Safe); + assert_eq!(config.slugify.anchors, SlugifyStrategy::Off); + } } diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 31882dbe..0c653357 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -19,7 +19,7 @@ use utils::templates::render_template; use crate::content::file_info::FileInfo; use crate::content::has_anchor; use crate::content::ser::SerializingPage; -use utils::slugs::maybe_slugify_paths; +use utils::slugs::slugify_paths; lazy_static! { // Based on https://regex101.com/r/H2n38Z/1/tests @@ -161,24 +161,24 @@ impl Page { page.slug = { if let Some(ref slug) = page.meta.slug { - maybe_slugify_paths(&slug.trim(), config.slugify_paths) + slugify_paths(slug, config.slugify.paths) } else if page.file.name == "index" { if let Some(parent) = page.file.path.parent() { if let Some(slug) = slug_from_dated_filename { - maybe_slugify_paths(&slug, config.slugify_paths) + slugify_paths(&slug, config.slugify.paths) } else { - maybe_slugify_paths( + slugify_paths( parent.file_name().unwrap().to_str().unwrap(), - config.slugify_paths, + config.slugify.paths, ) } } else { - maybe_slugify_paths(&page.file.name, config.slugify_paths) + slugify_paths(&page.file.name, config.slugify.paths) } } else if let Some(slug) = slug_from_dated_filename { - maybe_slugify_paths(&slug, config.slugify_paths) + slugify_paths(&slug, config.slugify.paths) } else { - maybe_slugify_paths(&page.file.name, config.slugify_paths) + slugify_paths(&page.file.name, config.slugify.paths) } }; @@ -379,6 +379,7 @@ mod tests { use super::Page; use config::{Config, Language}; use front_matter::InsertAnchor; + use utils::slugs::SlugifyStrategy; #[test] fn test_can_parse_a_valid_page() { @@ -448,7 +449,7 @@ Hello world"#; +++ Hello world"#; let mut config = Config::default(); - config.slugify_paths = true; + config.slugify.paths = SlugifyStrategy::On; let res = Page::parse(Path::new("start.md"), content, &config, &PathBuf::new()); assert!(res.is_ok()); let page = res.unwrap(); @@ -465,7 +466,7 @@ Hello world"#; +++ Hello world"#; let mut config = Config::default(); - config.slugify_paths = false; + config.slugify.paths = SlugifyStrategy::Safe; let res = Page::parse(Path::new("start.md"), content, &config, &PathBuf::new()); assert!(res.is_ok()); let page = res.unwrap(); @@ -531,7 +532,7 @@ Hello world"#; #[test] fn can_make_slug_from_non_slug_filename() { let mut config = Config::default(); - config.slugify_paths = true; + config.slugify.paths = SlugifyStrategy::On; let res = Page::parse(Path::new(" file with space.md"), "+++\n+++", &config, &PathBuf::new()); assert!(res.is_ok()); @@ -543,7 +544,7 @@ Hello world"#; #[test] fn can_make_path_from_utf8_filename() { let mut config = Config::default(); - config.slugify_paths = false; + config.slugify.paths = SlugifyStrategy::Safe; let res = Page::parse(Path::new("日本.md"), "+++\n++++", &config, &PathBuf::new()); assert!(res.is_ok()); let page = res.unwrap(); diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index cd49a7f1..036f4b9b 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -11,7 +11,7 @@ use utils::templates::render_template; use crate::content::SerializingPage; use crate::library::Library; use crate::sorting::sort_pages_by_date; -use utils::slugs::maybe_slugify_paths; +use utils::slugs::slugify_paths; #[derive(Debug, Clone, PartialEq, Serialize)] pub struct SerializedTaxonomyItem<'a> { @@ -70,7 +70,7 @@ impl TaxonomyItem { }) .collect(); let (mut pages, ignored_pages) = sort_pages_by_date(data); - let slug = maybe_slugify_paths(name, config.slugify_paths); + let slug = slugify_paths(name, config.slugify.taxonomies); let permalink = if taxonomy.lang != config.default_language { config.make_permalink(&format!("/{}/{}/{}", taxonomy.lang, taxonomy.name, slug)) } else { @@ -235,6 +235,7 @@ mod tests { use crate::content::Page; use crate::library::Library; use config::{Config, Language, Taxonomy as TaxonomyConfig}; + use utils::slugs::SlugifyStrategy; #[test] fn can_make_taxonomies() { @@ -565,7 +566,7 @@ mod tests { #[test] fn can_make_utf8_taxonomies() { let mut config = Config::default(); - config.slugify_paths = false; + config.slugify.taxonomies = SlugifyStrategy::Safe; config.languages.push(Language { rss: false, code: "fr".to_string(), @@ -598,7 +599,7 @@ mod tests { #[test] fn can_make_slugified_taxonomies_in_multiple_languages() { let mut config = Config::default(); - config.slugify_paths = true; + config.slugify.taxonomies = SlugifyStrategy::On; config.languages.push(Language { rss: false, code: "fr".to_string(), diff --git a/components/rendering/benches/all.rs b/components/rendering/benches/all.rs index 40451709..ea16e63f 100644 --- a/components/rendering/benches/all.rs +++ b/components/rendering/benches/all.rs @@ -86,8 +86,7 @@ fn bench_render_content_with_highlighting(b: &mut test::Bencher) { tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = - RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); b.iter(|| render_content(CONTENT, &context).unwrap()); } @@ -98,8 +97,7 @@ fn bench_render_content_without_highlighting(b: &mut test::Bencher) { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = false; - let context = - RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); b.iter(|| render_content(CONTENT, &context).unwrap()); } @@ -110,8 +108,7 @@ fn bench_render_content_no_shortcode(b: &mut test::Bencher) { let mut config = Config::default(); config.highlight_code = false; let permalinks_ctx = HashMap::new(); - let context = - RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); b.iter(|| render_content(&content2, &context).unwrap()); } @@ -122,8 +119,7 @@ fn bench_render_shortcodes_one_present(b: &mut test::Bencher) { tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); let config = Config::default(); let permalinks_ctx = HashMap::new(); - let context = - RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); b.iter(|| render_shortcodes(CONTENT, &context)); } diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index 5a36a41f..067427d5 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -12,7 +12,7 @@ use config::highlighting::{get_highlighter, SYNTAX_SET, THEME_SET}; use errors::{Error, Result}; use front_matter::InsertAnchor; use utils::site::resolve_internal_link; -use utils::slugs::maybe_slugify_anchors; +use utils::slugs::slugify_anchors; use utils::vec::InsertMany; use self::cmark::{Event, LinkType, Options, Parser, Tag}; @@ -305,7 +305,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> ResultL'écologie et vous\n"); @@ -880,4 +881,4 @@ fn stops_with_an_error_on_an_empty_link() { assert!(res.is_err()); assert_eq!(res.unwrap_err().to_string(), expected); -} \ No newline at end of file +} diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index 77a50708..94dddd7f 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -686,14 +686,14 @@ fn can_ignore_markdown_content() { #[test] fn check_site() { - let (mut site, _tmp_dir, _public) = build_site("test_site"); + let (mut site, _tmp_dir, _public) = build_site("test_site"); - assert_eq!( - site.config.link_checker.skip_anchor_prefixes, - vec!["https://github.com/rust-lang/rust/blob/"] - ); - assert_eq!(site.config.link_checker.skip_prefixes, vec!["http://[2001:db8::]/"]); + assert_eq!( + site.config.link_checker.skip_anchor_prefixes, + vec!["https://github.com/rust-lang/rust/blob/"] + ); + assert_eq!(site.config.link_checker.skip_prefixes, vec!["http://[2001:db8::]/"]); - site.config.enable_check_mode(); - site.load().expect("link check test_site"); + site.config.enable_check_mode(); + site.load().expect("link check test_site"); } diff --git a/components/templates/src/global_fns/mod.rs b/components/templates/src/global_fns/mod.rs index 077a9fb6..dd3b0538 100644 --- a/components/templates/src/global_fns/mod.rs +++ b/components/templates/src/global_fns/mod.rs @@ -346,6 +346,7 @@ mod tests { use config::{Config, Taxonomy as TaxonomyConfig}; use library::{Library, Taxonomy, TaxonomyItem}; + use utils::slugs::SlugifyStrategy; #[test] fn can_add_cachebust_to_url() { @@ -390,7 +391,7 @@ mod tests { #[test] fn can_get_taxonomy() { let mut config = Config::default(); - config.slugify_paths = true; + config.slugify.taxonomies = SlugifyStrategy::On; let taxo_config = TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), @@ -468,7 +469,7 @@ mod tests { #[test] fn can_get_taxonomy_url() { let mut config = Config::default(); - config.slugify_paths = true; + config.slugify.taxonomies = SlugifyStrategy::On; let taxo_config = TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index ee6ebd3e..e1f88945 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -5,13 +5,16 @@ authors = ["Vincent Prouillet "] edition = "2018" [dependencies] -errors = { path = "../errors" } tera = "1" unicode-segmentation = "1.2" walkdir = "2" toml = "0.5" serde = "1" +serde_derive = "1" slug = "0.1" +percent-encoding = "2" + +errors = { path = "../errors" } [dev-dependencies] tempfile = "3" diff --git a/components/utils/src/site.rs b/components/utils/src/site.rs index d80b87d9..26e0f8ac 100644 --- a/components/utils/src/site.rs +++ b/components/utils/src/site.rs @@ -1,3 +1,4 @@ +use percent_encoding::percent_decode; use std::collections::HashMap; use std::hash::BuildHasher; use unicode_segmentation::UnicodeSegmentation; @@ -33,12 +34,15 @@ pub fn resolve_internal_link( // Then we remove any potential anchor // parts[0] will be the file path and parts[1] the anchor if present let parts = clean_link.split('#').collect::>(); - match permalinks.get(parts[0]) { + // If we have slugification turned off, we might end up with some escaped characters so we need + // to decode them first + let decoded = &*percent_decode(parts[0].as_bytes()).decode_utf8_lossy(); + match permalinks.get(decoded) { Some(p) => { if parts.len() > 1 { Ok(ResolvedInternalLink { permalink: format!("{}#{}", p, parts[1]), - md_path: Some(parts[0].to_string()), + md_path: Some(decoded.to_string()), anchor: Some(parts[1].to_string()), }) } else { @@ -81,6 +85,19 @@ mod tests { assert_eq!(res.anchor, Some("hello".to_string())); } + #[test] + fn can_resolve_escaped_internal_links() { + let mut permalinks = HashMap::new(); + permalinks.insert( + "pages/about space.md".to_string(), + "https://vincent.is/about%20space/".to_string(), + ); + let res = resolve_internal_link("@/pages/about%20space.md#hello", &permalinks).unwrap(); + assert_eq!(res.permalink, "https://vincent.is/about%20space/#hello"); + assert_eq!(res.md_path, Some("pages/about space.md".to_string())); + assert_eq!(res.anchor, Some("hello".to_string())); + } + #[test] fn errors_resolve_inexistant_internal_link() { let res = resolve_internal_link("@/pages/about.md#hello", &HashMap::new()); diff --git a/components/utils/src/slugs.rs b/components/utils/src/slugs.rs index c90aea6c..6e44e12e 100644 --- a/components/utils/src/slugs.rs +++ b/components/utils/src/slugs.rs @@ -1,3 +1,16 @@ +use serde_derive::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum SlugifyStrategy { + /// Classic slugification, the default + On, + /// No slugification, only remove unsafe characters for filepaths/urls + Safe, + /// Nothing is changed, hope for the best! + Off, +} + fn strip_chars(s: &str, chars: &str) -> String { let mut sanitized_string = s.to_string(); sanitized_string.retain(|c| !chars.contains(c)); @@ -6,37 +19,23 @@ fn strip_chars(s: &str, chars: &str) -> String { fn strip_invalid_paths_chars(s: &str) -> String { // NTFS forbidden characters : https://gist.github.com/doctaphred/d01d05291546186941e1b7ddc02034d3 - // Also we need to trim . from the end of filename + // Also we need to trim whitespaces and `.` from the end of filename let trimmed = s.trim_end_matches(|c| c == ' ' || c == '.'); - let cleaned = trimmed.replace(" ", "_"); - // And () [] since they are not allowed in markdown links - strip_chars(&cleaned, "<>:/|?*#()[]\n\"\\\r\t") + strip_chars(&trimmed, r#"<>:"/\|?*"#) } -fn strip_invalid_anchors_chars(s: &str) -> String { - // spaces are not valid in markdown links - let cleaned = s.replace(" ", "_"); - // https://tools.ietf.org/html/rfc3986#section-3.5 - strip_chars(&cleaned, "\"#%<>[\\]()^`{|}") -} - -pub fn maybe_slugify_paths(s: &str, slugify: bool) -> String { - if slugify { - // ASCII slugification - slug::slugify(s) - } else { - // Only remove forbidden characters - strip_invalid_paths_chars(s) +pub fn slugify_paths(s: &str, strategy: SlugifyStrategy) -> String { + match strategy { + SlugifyStrategy::On => slug::slugify(s), + SlugifyStrategy::Safe => strip_invalid_paths_chars(s), + SlugifyStrategy::Off => s.to_string(), } } -pub fn maybe_slugify_anchors(s: &str, slugify: bool) -> String { - if slugify { - // ASCII slugification - slug::slugify(s) - } else { - // Only remove forbidden characters - strip_invalid_anchors_chars(s) +pub fn slugify_anchors(s: &str, strategy: SlugifyStrategy) -> String { + match strategy { + SlugifyStrategy::On => slug::slugify(s), + SlugifyStrategy::Safe | SlugifyStrategy::Off => s.replace(|c: char| c.is_ascii_whitespace(), "_"), } } @@ -45,61 +44,44 @@ mod tests { use super::*; #[test] - fn strip_invalid_paths_chars_works() { + fn can_slugify_paths() { let tests = vec![ - // no newlines - ("test\ntest", "testtest"), - // no whitespaces - ("test ", "test"), - ("t est ", "t_est"), - // invalid NTFS - ("test .", "test"), - ("test. ", "test"), - ("test#test/test?test", "testtesttesttest"), - // Invalid CommonMark chars in links - ("test (hey)", "test_hey"), - ("test (hey", "test_hey"), - ("test hey)", "test_hey"), - ("test [hey]", "test_hey"), - ("test [hey", "test_hey"), - ("test hey]", "test_hey"), - // UTF-8 - ("日本", "日本"), + // input, (on, safe, off) + ("input", ("input", "input", "input")), + ("test ", ("test", "test", "test ")), + ("tes t", ("tes-t", "tes t", "tes t")), + // Invalid NTFS + ("dot. ", ("dot", "dot", "dot. ")), + ("日本", ("ri-ben", "日本", "日本")), + ("héhé", ("hehe", "héhé", "héhé")), + ("test (hey)", ("test-hey", "test (hey)", "test (hey)")), ]; - for (input, expected) in tests { - assert_eq!(strip_invalid_paths_chars(&input), expected); + for (input, (on, safe, off)) in tests { + assert_eq!(on, slugify_paths(input, SlugifyStrategy::On)); + assert_eq!(safe, slugify_paths(input, SlugifyStrategy::Safe)); + assert_eq!(off, slugify_paths(input, SlugifyStrategy::Off)); } } #[test] - fn strip_invalid_anchors_chars_works() { + fn can_slugify_anchors() { let tests = vec![ - ("日本", "日本"), - // Some invalid chars get removed - ("test#", "test"), - ("test<", "test"), - ("test%", "test"), - ("test^", "test"), - ("test{", "test"), - ("test|", "test"), - ("test(", "test"), - // Spaces are replaced by `_` - ("test hey", "test_hey"), + // input, (on, safe, off) + ("input", ("input", "input", "input")), + ("test ", ("test", "test_", "test_")), + ("tes t", ("tes-t", "tes_t", "tes_t")), + // Invalid NTFS + ("dot. ", ("dot", "dot._", "dot._")), + ("日本", ("ri-ben", "日本", "日本")), + ("héhé", ("hehe", "héhé", "héhé")), + ("test (hey)", ("test-hey", "test_(hey)", "test_(hey)")), ]; - for (input, expected) in tests { - assert_eq!(strip_invalid_anchors_chars(&input), expected); + for (input, (on, safe, off)) in tests { + assert_eq!(on, slugify_anchors(input, SlugifyStrategy::On)); + assert_eq!(safe, slugify_anchors(input, SlugifyStrategy::Safe)); + assert_eq!(off, slugify_anchors(input, SlugifyStrategy::Off)); } } - - #[test] - fn maybe_slugify_paths_enabled() { - assert_eq!(maybe_slugify_paths("héhé", true), "hehe"); - } - - #[test] - fn maybe_slugify_paths_disabled() { - assert_eq!(maybe_slugify_paths("héhé", false), "héhé"); - } } diff --git a/docs/content/documentation/getting-started/configuration.md b/docs/content/documentation/getting-started/configuration.md index 01786c0b..6a5465a8 100644 --- a/docs/content/documentation/getting-started/configuration.md +++ b/docs/content/documentation/getting-started/configuration.md @@ -27,10 +27,6 @@ default_language = "en" # The site theme to use. theme = "" -# Slugify paths for compatibility with ASCII-only URLs produced by Zola < 0.9 -# Enabling this setting removes non-English (UTF8) characters in URLs -slugify_paths = false - # When set to "true", all code blocks are highlighted. highlight_code = false @@ -113,6 +109,18 @@ skip_anchor_prefixes = [ "https://caniuse.com/", ] +# Various slugification strategies, see below for details +# Defauls to everything being a slug +[slugify] +paths = "on" +taxonomies = "on" +anchors = "on" + +# Optional translation object. Keys should be language codes. +[translations] + +# You can put any kind of data here. The data +# will be accessible in all templates. [extra] ``` @@ -158,3 +166,19 @@ Zola currently has the following highlight themes available: Zola uses the Sublime Text themes, making it very easy to add more. If you want a theme not listed above, please open an issue or a pull request on the [Zola repo](https://github.com/getzola/zola). + +## Slugification strategies + +By default, Zola will turn every path, taxonomies and anchors to a slug, an ASCII representation with no special characters. +You can however change that strategy for each kind of item, if you want UTF-8 characters in your URLs for example. There are 3 strategies: + +- `on`: the default one, everything is turned into a slug +- `safe`: characters that cannot exist in files on Windows (`<>:"/\|?*`) or Unix (`/`) are removed, everything else stays +- `off`: nothing is changed, your site might not build on some OS and/or break various URL parsers + +Since there are no filename issues with anchors, the `safe` and `off` strategies are identical in their case: the only change +is space being replaced by `_` since a space is not valid in an anchor. + +Note that if you are using a strategy other than the default, you will have to manually escape whitespace and Markdown +tokens to be able to link to your pages. For example an internal link to a file named `some space.md` will need to be +written like `some%20space.md` in your Markdown files. \ No newline at end of file diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index d3b4aa42..ce00717e 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -405,6 +405,25 @@ pub fn serve( } }; + let recreate_site = || match create_new_site( + root_dir, + interface, + port, + output_dir, + base_url, + config_file, + include_drafts, + ) { + Ok((s, _)) => { + rebuild_done_handling(&broadcaster, Ok(()), "/x.js"); + Some(s) + } + Err(e) => { + console::error(&format!("{}", e)); + None + } + }; + loop { match rx.recv() { Ok(event) => { @@ -444,32 +463,17 @@ pub fn serve( console::info( "-> Themes changed. The whole site will be reloaded.", ); - site = create_new_site( - root_dir, - interface, - port, - output_dir, - base_url, - config_file, - include_drafts, - ) - .unwrap() - .0; - rebuild_done_handling(&broadcaster, Ok(()), "/x.js"); + + if let Some(s) = recreate_site() { + site = s; + } } ChangeKind::Config => { console::info("-> Config changed. The whole site will be reloaded. The browser needs to be refreshed to make the changes visible."); - site = create_new_site( - root_dir, - interface, - port, - output_dir, - base_url, - config_file, - include_drafts, - ) - .unwrap() - .0; + + if let Some(s) = recreate_site() { + site = s; + } } } console::report_elapsed_time(start); @@ -507,32 +511,17 @@ pub fn serve( console::info( "-> Themes changed. The whole site will be reloaded.", ); - site = create_new_site( - root_dir, - interface, - port, - output_dir, - base_url, - config_file, - include_drafts, - ) - .unwrap() - .0; - rebuild_done_handling(&broadcaster, Ok(()), "/x.js"); + + if let Some(s) = recreate_site() { + site = s; + } } (ChangeKind::Config, _) => { console::info("-> Config changed. The whole site will be reloaded. The browser needs to be refreshed to make the changes visible."); - site = create_new_site( - root_dir, - interface, - port, - output_dir, - base_url, - config_file, - include_drafts, - ) - .unwrap() - .0; + + if let Some(s) = recreate_site() { + site = s; + } } }; console::report_elapsed_time(start);