From 3b8a95eb8ff54f435b82f996cb113cbd84bc5318 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 11 Mar 2019 20:25:28 +0100 Subject: [PATCH] Generate assets before rendering templates --- components/site/src/lib.rs | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 60d9afca..1d3c27e6 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -536,6 +536,26 @@ impl Site { /// Deletes the `public` directory and builds the site pub fn build(&self) -> Result<()> { self.clean()?; + + // Generate/move all assets before rendering any content + if let Some(ref theme) = self.config.theme { + let theme_path = self.base_path.join("themes").join(theme); + if theme_path.join("sass").exists() { + self.compile_sass(&theme_path)?; + } + } + + if self.config.compile_sass { + self.compile_sass(&self.base_path)?; + } + + self.process_images()?; + self.copy_static_directories()?; + + if self.config.build_search_index { + self.build_search_index()?; + } + // Render aliases first to allow overwriting self.render_aliases()?; self.render_sections()?; @@ -570,24 +590,6 @@ impl Site { self.render_robots()?; self.render_taxonomies()?; - if let Some(ref theme) = self.config.theme { - let theme_path = self.base_path.join("themes").join(theme); - if theme_path.join("sass").exists() { - self.compile_sass(&theme_path)?; - } - } - - if self.config.compile_sass { - self.compile_sass(&self.base_path)?; - } - - self.process_images()?; - self.copy_static_directories()?; - - if self.config.build_search_index { - self.build_search_index()?; - } - Ok(()) }