diff --git a/CHANGELOG.md b/CHANGELOG.md index d8784113..c305c188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `zola serve` now properly returns a 404 - Fix `zola serve` having issues with config files in separate dir - Fix code blocks content not being escaped when not using syntax highlighting +- Add missing `draft` attribute to the `section` variable in templates ## 0.14.0 (2021-07-19) diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 6d82a151..c8bcd0aa 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -103,10 +103,6 @@ impl Page { Page { file: FileInfo::new_page(file_path, base_path), meta, ..Self::default() } } - pub fn is_draft(&self) -> bool { - self.meta.draft - } - /// Parse a page given the content of the .md file /// Files without front matter or with invalid front matter are considered /// erroneous diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index 77a293df..b506a677 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -167,7 +167,7 @@ impl<'a> SerializingPage<'a> { word_count: page.word_count, reading_time: page.reading_time, assets: &page.serialized_assets, - draft: page.is_draft(), + draft: page.meta.draft, lang: &page.lang, lighter, heavier, @@ -233,7 +233,7 @@ impl<'a> SerializingPage<'a> { word_count: page.word_count, reading_time: page.reading_time, assets: &page.serialized_assets, - draft: page.is_draft(), + draft: page.meta.draft, lang: &page.lang, lighter: None, heavier: None, @@ -253,6 +253,7 @@ pub struct SerializingSection<'a> { relative_path: &'a str, content: &'a str, permalink: &'a str, + draft: bool, ancestors: Vec<&'a str>, title: &'a Option, description: &'a Option, @@ -292,6 +293,7 @@ impl<'a> SerializingSection<'a> { SerializingSection { relative_path: §ion.file.relative, ancestors, + draft: section.meta.draft, content: §ion.content, permalink: §ion.permalink, title: §ion.meta.title, @@ -329,6 +331,7 @@ impl<'a> SerializingSection<'a> { SerializingSection { relative_path: §ion.file.relative, ancestors, + draft: section.meta.draft, content: §ion.content, permalink: §ion.permalink, title: §ion.meta.title, diff --git a/components/rendering/src/codeblock/highlight.rs b/components/rendering/src/codeblock/highlight.rs index 106a984c..bdf4e8ff 100644 --- a/components/rendering/src/codeblock/highlight.rs +++ b/components/rendering/src/codeblock/highlight.rs @@ -1,13 +1,13 @@ use std::fmt::Write; use config::highlighting::{SyntaxAndTheme, CLASS_STYLE}; -use tera::escape_html; use syntect::easy::HighlightLines; use syntect::highlighting::{Color, Theme}; use syntect::html::{ - styled_line_to_highlighted_html, line_tokens_to_classed_spans, ClassStyle, IncludeBackground, + line_tokens_to_classed_spans, styled_line_to_highlighted_html, ClassStyle, IncludeBackground, }; use syntect::parsing::{ParseState, ScopeStack, SyntaxReference, SyntaxSet}; +use tera::escape_html; /// Not public, but from syntect::html fn write_css_color(s: &mut String, c: Color) {