mirror of
https://github.com/getzola/zola
synced 2024-12-05 01:49:12 +00:00
parent
5f90ad1d33
commit
c67655e29f
8 changed files with 25 additions and 8 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 0.17.1 (unreleased)
|
||||
|
||||
- Fix bugs with colocated directories in the root `content` directory
|
||||
|
||||
## 0.17.0 (2023-02-16)
|
||||
|
||||
### Breaking
|
||||
|
|
|
@ -77,6 +77,7 @@ impl FileInfo {
|
|||
val.push('/');
|
||||
val
|
||||
});
|
||||
|
||||
components.pop();
|
||||
// also set parent_path to grandparent instead
|
||||
parent = parent.parent().unwrap().to_path_buf();
|
||||
|
|
|
@ -157,7 +157,7 @@ impl Page {
|
|||
}
|
||||
} else {
|
||||
let mut path = if page.file.components.is_empty() {
|
||||
if page.file.name == "index" {
|
||||
if page.file.name == "index" && page.file.colocated_path.is_none() {
|
||||
String::new()
|
||||
} else {
|
||||
page.slug.clone()
|
||||
|
|
|
@ -277,8 +277,8 @@ impl Site {
|
|||
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,
|
||||
// content/index.md is always invalid, but content/colocated/index.md is ok
|
||||
None => page.file.colocated_path.is_none(),
|
||||
};
|
||||
|
||||
if is_invalid {
|
||||
|
@ -472,9 +472,6 @@ 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 =
|
||||
|
|
|
@ -21,7 +21,7 @@ fn can_parse_site() {
|
|||
let library = site.library.read().unwrap();
|
||||
|
||||
// Correct number of pages (sections do not count as pages, draft are ignored)
|
||||
assert_eq!(library.pages.len(), 33);
|
||||
assert_eq!(library.pages.len(), 34);
|
||||
let posts_path = path.join("content").join("posts");
|
||||
|
||||
// Make sure the page with a url doesn't have any sections
|
||||
|
@ -39,7 +39,7 @@ fn can_parse_site() {
|
|||
// And that the sections are correct
|
||||
let index_section = library.sections.get(&path.join("content").join("_index.md")).unwrap();
|
||||
assert_eq!(index_section.subsections.len(), 5);
|
||||
assert_eq!(index_section.pages.len(), 3);
|
||||
assert_eq!(index_section.pages.len(), 4);
|
||||
assert!(index_section.ancestors.is_empty());
|
||||
|
||||
let posts_section = library.sections.get(&posts_path.join("_index.md")).unwrap();
|
||||
|
@ -221,6 +221,13 @@ fn can_build_site_without_live_reload() {
|
|||
"robots.txt",
|
||||
"Sitemap: https://replace-this-with-your-url.com/sitemap.xml"
|
||||
));
|
||||
|
||||
// And
|
||||
assert!(file_contains!(
|
||||
public,
|
||||
"colocated-assets/index.html",
|
||||
"Assets in root content directory"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
4
docs/content/hello/index.md
Normal file
4
docs/content/hello/index.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
+++
|
||||
+++
|
||||
|
||||
Hello
|
3
test_site/content/colocated-assets/index.md
Normal file
3
test_site/content/colocated-assets/index.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
+++
|
||||
title = "Assets in root content directory"
|
||||
+++
|
|
@ -1,6 +1,7 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
{% block content %}
|
||||
{{ page.title | safe }}
|
||||
{{ page.content | safe }}
|
||||
{{ page.relative_path | safe }}
|
||||
{{ page.toc }}
|
||||
|
|
Loading…
Reference in a new issue