From ca99bb020423f027e34bccc495dad1176cef84a5 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 1 Nov 2017 14:29:27 +1100 Subject: [PATCH] Expose to templates whether or not a page is draft Useful if you are, e.g., generating an index of blog posts. --- components/content/src/page.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/content/src/page.rs b/components/content/src/page.rs index 5880817f..aa385c15 100644 --- a/components/content/src/page.rs +++ b/components/content/src/page.rs @@ -203,7 +203,7 @@ impl Default for Page { impl ser::Serialize for Page { fn serialize(&self, serializer: S) -> StdResult where S: ser::Serializer { - let mut state = serializer.serialize_struct("page", 17)?; + let mut state = serializer.serialize_struct("page", 18)?; state.serialize_field("content", &self.content)?; state.serialize_field("title", &self.meta.title)?; state.serialize_field("description", &self.meta.description)?; @@ -222,6 +222,7 @@ impl ser::Serialize for Page { state.serialize_field("previous", &self.previous)?; state.serialize_field("next", &self.next)?; state.serialize_field("toc", &self.toc)?; + state.serialize_field("draft", &self.is_draft())?; state.end() } }