mirror of
https://github.com/getzola/zola
synced 2024-11-10 06:14:19 +00:00
Fix tests
This commit is contained in:
parent
cb2a4b0ee8
commit
9c1b004b13
4 changed files with 9 additions and 27 deletions
|
@ -295,6 +295,9 @@ impl Library {
|
|||
|
||||
// Then once we took care of the sections, we find the pages of each section
|
||||
for (path, page) in self.pages.iter_mut() {
|
||||
if !page.meta.render {
|
||||
continue;
|
||||
}
|
||||
let parent_filename = &index_filename_by_lang[&page.lang];
|
||||
add_translation(&page.file.canonical, path);
|
||||
let mut parent_section_path = page.file.parent.join(parent_filename);
|
||||
|
|
|
@ -115,10 +115,6 @@ impl Page {
|
|||
page.word_count = Some(word_count);
|
||||
page.reading_time = Some(reading_time);
|
||||
|
||||
if !page.meta.render {
|
||||
return Ok(page);
|
||||
}
|
||||
|
||||
let mut slug_from_dated_filename = None;
|
||||
|
||||
let file_path_for_slug = if page.file.name == "index" {
|
||||
|
@ -927,25 +923,4 @@ Bonjour le monde"#
|
|||
assert_eq!(page.slug, "hello");
|
||||
assert_eq!(page.permalink, "http://a-website.com/bonjour/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_without_physical_path() {
|
||||
let config = Config::default();
|
||||
let content = r#"
|
||||
+++
|
||||
render = false
|
||||
+++
|
||||
Hello world
|
||||
"#
|
||||
.to_string();
|
||||
|
||||
let res = Page::parse(Path::new("hello.md"), &content, &config, &PathBuf::new());
|
||||
assert!(res.is_ok());
|
||||
let page = res.unwrap();
|
||||
println!("{:#?}", page);
|
||||
assert_eq!(page.slug, "");
|
||||
assert_eq!(page.path, "");
|
||||
assert_eq!(page.permalink, "");
|
||||
assert_eq!(page.raw_content, "Hello world\n".to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -692,6 +692,10 @@ impl Site {
|
|||
|
||||
/// Renders a single content page
|
||||
pub fn render_page(&self, page: &Page) -> Result<()> {
|
||||
if !page.meta.render {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let output = page.render_html(&self.tera, &self.config, &self.library.read().unwrap())?;
|
||||
let content = self.inject_livereload(output);
|
||||
let components: Vec<&str> = page.path.split('/').collect();
|
||||
|
@ -1087,7 +1091,7 @@ impl Site {
|
|||
}
|
||||
|
||||
// Copy any asset we found previously into the same directory as the index.html
|
||||
self.copy_assets(§ion.file.path.parent().unwrap(), §ion.assets, &output_path)?;
|
||||
self.copy_assets(section.file.path.parent().unwrap(), §ion.assets, &output_path)?;
|
||||
|
||||
if render_pages {
|
||||
section
|
||||
|
|
|
@ -44,7 +44,7 @@ fn can_parse_site() {
|
|||
|
||||
let posts_section = library.sections.get(&posts_path.join("_index.md")).unwrap();
|
||||
assert_eq!(posts_section.subsections.len(), 2);
|
||||
assert_eq!(posts_section.pages.len(), 11); // 12 with 1 draft == 11
|
||||
assert_eq!(posts_section.pages.len(), 10); // 11 with 1 draft == 10
|
||||
assert_eq!(posts_section.ancestors, vec![index_section.file.relative.clone()]);
|
||||
|
||||
// Make sure we remove all the pwd + content from the sections
|
||||
|
|
Loading…
Reference in a new issue