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 config:: Config;
use errors::{Result}; use errors::{Result};
use tera::Tera;
pub fn build(config: Config) -> Result<()> { pub fn build(config: Config) -> Result<()> {

View file

@ -12,6 +12,8 @@ use errors::{Result, ErrorKind};
pub struct Config { pub struct Config {
pub title: String, pub title: String,
pub base_url: String, pub base_url: String,
pub favicon: Option<String>,
} }
impl Default for Config { impl Default for Config {
@ -19,6 +21,8 @@ impl Default for Config {
Config { Config {
title: "".to_string(), title: "".to_string(),
base_url: "".to_string(), base_url: "".to_string(),
favicon: None,
} }
} }
} }
@ -33,9 +37,10 @@ impl Config {
for (key, value) in value.iter() { for (key, value) in value.iter() {
if key == "title" { if key == "title" {
config.title = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); config.title = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string();
} } else if key == "base_url" {
if key == "base_url" {
config.base_url = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); 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 pulldown_cmark as cmark;
use regex::Regex; use regex::Regex;
use toml::{Parser, Value as TomlValue}; use toml::{Parser, Value as TomlValue};
use tera::{Value, to_value}; use tera::{Tera, Value, to_value, Context};
use errors::{Result}; use errors::{Result};
use errors::ErrorKind::InvalidFrontMatter; use errors::ErrorKind::InvalidFrontMatter;
use config::Config;
lazy_static! { lazy_static! {
@ -178,6 +179,10 @@ impl Page {
Ok(page) Ok(page)
} }
// pub fn render_html(&self, tera: &Tera, config: &Config) -> Result<String> {
//
// }
} }