From 5ce6d41509243489a62d328ac5c0968dece90fbf Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 6 Dec 2016 21:48:23 +0900 Subject: [PATCH] Add favicon to config --- src/cmd/build.rs | 3 +++ src/config.rs | 9 +++++++-- src/page.rs | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index f261454..c874dcc 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -2,6 +2,9 @@ use config:: Config; use errors::{Result}; +use tera::Tera; + + pub fn build(config: Config) -> Result<()> { diff --git a/src/config.rs b/src/config.rs index 9ccaaea..7cc0c95 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,6 +12,8 @@ use errors::{Result, ErrorKind}; pub struct Config { pub title: String, pub base_url: String, + + pub favicon: Option, } impl Default for Config { @@ -19,6 +21,8 @@ impl Default for Config { Config { title: "".to_string(), base_url: "".to_string(), + + favicon: None, } } } @@ -33,9 +37,10 @@ impl Config { for (key, value) in value.iter() { if key == "title" { config.title = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); - } - if key == "base_url" { + } else if key == "base_url" { config.base_url = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); + } else if key == "favicon" { + config.favicon = Some(value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string()); } } diff --git a/src/page.rs b/src/page.rs index 02b689d..3aedecf 100644 --- a/src/page.rs +++ b/src/page.rs @@ -5,10 +5,11 @@ use std::default::Default; // use pulldown_cmark as cmark; use regex::Regex; use toml::{Parser, Value as TomlValue}; -use tera::{Value, to_value}; +use tera::{Tera, Value, to_value, Context}; use errors::{Result}; use errors::ErrorKind::InvalidFrontMatter; +use config::Config; lazy_static! { @@ -178,6 +179,10 @@ impl Page { Ok(page) } + +// pub fn render_html(&self, tera: &Tera, config: &Config) -> Result { +// +// } }