Add favicon to config

This commit is contained in:
Vincent Prouillet 2016-12-06 21:48:23 +09:00
parent a6e421c5e4
commit 5ce6d41509
3 changed files with 16 additions and 3 deletions

View file

@ -2,6 +2,9 @@
use config:: Config;
use errors::{Result};
use tera::Tera;
pub fn build(config: Config) -> Result<()> {

View file

@ -12,6 +12,8 @@ use errors::{Result, ErrorKind};
pub struct Config {
pub title: String,
pub base_url: String,
pub favicon: Option<String>,
}
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());
}
}

View file

@ -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<String> {
//
// }
}