mirror of
https://github.com/getzola/zola
synced 2024-11-10 06:14:19 +00:00
parent
bb171009a1
commit
ee4cbb649a
8 changed files with 94 additions and 37 deletions
|
@ -10,7 +10,7 @@ for breaking changes with libsass: look for "beginning in Dart Sass"
|
|||
This will error if 2 values are set
|
||||
- Code blocks content are no longer included in the search index
|
||||
- Remove built-ins shortcodes
|
||||
|
||||
- Having a file called `index.md` in a folder with a `_index.md` is now an error
|
||||
|
||||
### Other
|
||||
|
||||
|
|
46
Cargo.lock
generated
46
Cargo.lock
generated
|
@ -230,9 +230,9 @@ checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.12.3"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f"
|
||||
checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
|
@ -637,9 +637,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.86"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579"
|
||||
checksum = "b61a7545f753a88bcbe0a70de1fcc0221e10bfc752f576754fa91e663db1622e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
|
@ -649,9 +649,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.86"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70"
|
||||
checksum = "f464457d494b5ed6905c63b0c4704842aba319084a0a3561cdc1359536b53200"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
|
@ -664,15 +664,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.86"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c"
|
||||
checksum = "43c7119ce3a3701ed81aca8410b9acf6fc399d2629d057b87e2efa4e63a3aaea"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.86"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5"
|
||||
checksum = "65e07508b90551e610910fa648a1878991d367064997a596135b86df30daf07e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2968,11 +2968,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.13"
|
||||
version = "0.11.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c"
|
||||
checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"base64 0.21.0",
|
||||
"bytes 1.3.0",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
|
@ -3162,9 +3162,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.7.0"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c"
|
||||
checksum = "645926f31b250a2dca3c232496c2d898d91036e45ca0e97e0e2390c54e11be36"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
|
@ -3175,9 +3175,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.6.1"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556"
|
||||
checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
|
@ -3235,9 +3235,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.16"
|
||||
version = "0.9.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92b5b431e8907b50339b51223b97d102db8d987ced36f6e4d03621db9316c834"
|
||||
checksum = "8fb06d4b6cdaef0e0c51fa881acb721bed3c924cfaa71d9c94a3b771dfdf6567"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa 1.0.5",
|
||||
|
@ -3699,9 +3699,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.10"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -3838,9 +3838,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.8"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
|
||||
checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
|
|
|
@ -157,7 +157,11 @@ impl Page {
|
|||
}
|
||||
} else {
|
||||
let mut path = if page.file.components.is_empty() {
|
||||
page.slug.clone()
|
||||
if page.file.name == "index" {
|
||||
String::new()
|
||||
} else {
|
||||
page.slug.clone()
|
||||
}
|
||||
} else {
|
||||
format!("{}/{}", page.file.components.join("/"), page.slug)
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ pub mod sass;
|
|||
pub mod sitemap;
|
||||
pub mod tpls;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs::{remove_dir_all, remove_file};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
|
@ -179,6 +179,12 @@ impl Site {
|
|||
.collect();
|
||||
allowed_index_filenames.push("_index.md".to_string());
|
||||
|
||||
// We will insert colocated pages (those with a index.md filename)
|
||||
// at the end to detect pages that are actually errors:
|
||||
// when there is both a _index.md and index.md in the same folder
|
||||
let mut pages = Vec::new();
|
||||
let mut components = HashSet::new();
|
||||
|
||||
loop {
|
||||
let entry: DirEntry = match dir_walker.next() {
|
||||
None => break,
|
||||
|
@ -242,8 +248,9 @@ impl Site {
|
|||
for index_file in index_files {
|
||||
let section =
|
||||
Section::from_file(index_file.path(), &self.config, &self.base_path)?;
|
||||
components.extend(section.file.components.clone());
|
||||
|
||||
// if the section is drafted we can skip the enitre dir
|
||||
// if the section is drafted we can skip the entire dir
|
||||
if section.meta.draft && !self.include_drafts {
|
||||
dir_walker.skip_current_dir();
|
||||
continue;
|
||||
|
@ -253,20 +260,38 @@ impl Site {
|
|||
}
|
||||
} else {
|
||||
let page = Page::from_file(path, &self.config, &self.base_path)?;
|
||||
|
||||
// should we skip drafts?
|
||||
if page.meta.draft && !self.include_drafts {
|
||||
continue;
|
||||
}
|
||||
pages_insert_anchors.insert(
|
||||
page.file.path.clone(),
|
||||
self.find_parent_section_insert_anchor(&page.file.parent.clone(), &page.lang),
|
||||
);
|
||||
self.add_page(page, false)?;
|
||||
pages.push(page);
|
||||
}
|
||||
}
|
||||
self.create_default_index_sections()?;
|
||||
|
||||
for page in pages {
|
||||
// should we skip drafts?
|
||||
if page.meta.draft && !self.include_drafts {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We are only checking it on load and not in add_page since we have access to
|
||||
// all the components there.
|
||||
if page.file.filename == "index.md" {
|
||||
let is_invalid = match page.components.last() {
|
||||
Some(last) => components.contains(last),
|
||||
// content/index.md is always invalid
|
||||
None => true,
|
||||
};
|
||||
|
||||
if is_invalid {
|
||||
bail!("We can't have a page called `index.md` in the same folder as an index section in {:?}", page.file.parent);
|
||||
}
|
||||
}
|
||||
|
||||
pages_insert_anchors.insert(
|
||||
page.file.path.clone(),
|
||||
self.find_parent_section_insert_anchor(&page.file.parent.clone(), &page.lang),
|
||||
);
|
||||
self.add_page(page, false)?;
|
||||
}
|
||||
|
||||
{
|
||||
let library = self.library.read().unwrap();
|
||||
let collisions = library.find_path_collisions();
|
||||
|
@ -446,6 +471,9 @@ impl Site {
|
|||
}
|
||||
}
|
||||
|
||||
// We can't have a page called index.md when there is a _index.md in the same folder
|
||||
if page.file.filename == "index.md" {}
|
||||
|
||||
self.permalinks.insert(page.file.relative.clone(), page.permalink.clone());
|
||||
if render_md {
|
||||
let insert_anchor =
|
||||
|
|
18
components/site/tests/invalid.rs
Normal file
18
components/site/tests/invalid.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
mod common;
|
||||
|
||||
use site::Site;
|
||||
use std::env;
|
||||
|
||||
#[test]
|
||||
fn errors_on_index_md_page_in_section() {
|
||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||
path.push("test_sites_invalid");
|
||||
path.push("indexmd");
|
||||
let config_file = path.join("config.toml");
|
||||
let mut site = Site::new(&path, &config_file).unwrap();
|
||||
let res = site.load();
|
||||
assert!(res.is_err());
|
||||
let err = res.unwrap_err();
|
||||
assert!(format!("{:?}", err)
|
||||
.contains("We can't have a page called `index.md` in the same folder as an index section"));
|
||||
}
|
3
test_sites_invalid/indexmd/config.toml
Normal file
3
test_sites_invalid/indexmd/config.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
title = "My Integration Testing site"
|
||||
base_url = "https://replace-this-with-your-url.com"
|
||||
|
2
test_sites_invalid/indexmd/content/_index.md
Normal file
2
test_sites_invalid/indexmd/content/_index.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
+++
|
||||
+++
|
2
test_sites_invalid/indexmd/content/index.md
Normal file
2
test_sites_invalid/indexmd/content/index.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
+++
|
||||
+++
|
Loading…
Reference in a new issue