Skip to content

Commit 9c1b004

Browse files
committed
Fix tests
1 parent cb2a4b0 commit 9c1b004

4 files changed

Lines changed: 9 additions & 27 deletions

File tree

components/content/src/library.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ impl Library {
295295

296296
// Then once we took care of the sections, we find the pages of each section
297297
for (path, page) in self.pages.iter_mut() {
298+
if !page.meta.render {
299+
continue;
300+
}
298301
let parent_filename = &index_filename_by_lang[&page.lang];
299302
add_translation(&page.file.canonical, path);
300303
let mut parent_section_path = page.file.parent.join(parent_filename);

components/content/src/page.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ impl Page {
115115
page.word_count = Some(word_count);
116116
page.reading_time = Some(reading_time);
117117

118-
if !page.meta.render {
119-
return Ok(page);
120-
}
121-
122118
let mut slug_from_dated_filename = None;
123119

124120
let file_path_for_slug = if page.file.name == "index" {
@@ -927,25 +923,4 @@ Bonjour le monde"#
927923
assert_eq!(page.slug, "hello");
928924
assert_eq!(page.permalink, "http://a-website.com/bonjour/");
929925
}
930-
931-
#[test]
932-
fn page_without_physical_path() {
933-
let config = Config::default();
934-
let content = r#"
935-
+++
936-
render = false
937-
+++
938-
Hello world
939-
"#
940-
.to_string();
941-
942-
let res = Page::parse(Path::new("hello.md"), &content, &config, &PathBuf::new());
943-
assert!(res.is_ok());
944-
let page = res.unwrap();
945-
println!("{:#?}", page);
946-
assert_eq!(page.slug, "");
947-
assert_eq!(page.path, "");
948-
assert_eq!(page.permalink, "");
949-
assert_eq!(page.raw_content, "Hello world\n".to_string());
950-
}
951926
}

components/site/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ impl Site {
692692

693693
/// Renders a single content page
694694
pub fn render_page(&self, page: &Page) -> Result<()> {
695+
if !page.meta.render {
696+
return Ok(());
697+
}
698+
695699
let output = page.render_html(&self.tera, &self.config, &self.library.read().unwrap())?;
696700
let content = self.inject_livereload(output);
697701
let components: Vec<&str> = page.path.split('/').collect();
@@ -1087,7 +1091,7 @@ impl Site {
10871091
}
10881092

10891093
// Copy any asset we found previously into the same directory as the index.html
1090-
self.copy_assets(&section.file.path.parent().unwrap(), &section.assets, &output_path)?;
1094+
self.copy_assets(section.file.path.parent().unwrap(), &section.assets, &output_path)?;
10911095

10921096
if render_pages {
10931097
section

components/site/tests/site.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn can_parse_site() {
4444

4545
let posts_section = library.sections.get(&posts_path.join("_index.md")).unwrap();
4646
assert_eq!(posts_section.subsections.len(), 2);
47-
assert_eq!(posts_section.pages.len(), 11); // 12 with 1 draft == 11
47+
assert_eq!(posts_section.pages.len(), 10); // 11 with 1 draft == 10
4848
assert_eq!(posts_section.ancestors, vec![index_section.file.relative.clone()]);
4949

5050
// Make sure we remove all the pwd + content from the sections

0 commit comments

Comments
 (0)