Browse Source

Add favicon to config

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
5ce6d41509
3 changed files with 16 additions and 3 deletions
  1. +3
    -0
      src/cmd/build.rs
  2. +7
    -2
      src/config.rs
  3. +6
    -1
      src/page.rs

+ 3
- 0
src/cmd/build.rs View File

@@ -2,6 +2,9 @@
use config:: Config;
use errors::{Result};

use tera::Tera;



pub fn build(config: Config) -> Result<()> {



+ 7
- 2
src/config.rs 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());
}
}



+ 6
- 1
src/page.rs 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> {
//
// }
}




Loading…
Cancel
Save