2017-05-22 11:28:43 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use tera::Tera;
|
|
|
|
|
|
|
|
use front_matter::InsertAnchor;
|
|
|
|
|
|
|
|
|
|
|
|
/// All the information from the gutenberg site that is needed to render HTML from markdown
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Context<'a> {
|
|
|
|
pub tera: &'a Tera,
|
|
|
|
pub highlight_code: bool,
|
|
|
|
pub highlight_theme: String,
|
2017-06-16 04:00:48 +00:00
|
|
|
pub current_page_permalink: String,
|
2017-05-22 11:28:43 +00:00
|
|
|
pub permalinks: &'a HashMap<String, String>,
|
|
|
|
pub insert_anchor: InsertAnchor,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Context<'a> {
|
2017-06-16 04:00:48 +00:00
|
|
|
pub fn new(
|
|
|
|
tera: &'a Tera,
|
2017-07-01 07:47:41 +00:00
|
|
|
highlight_code: bool,
|
|
|
|
highlight_theme: String,
|
2017-06-16 04:00:48 +00:00
|
|
|
current_page_permalink: &str,
|
|
|
|
permalinks: &'a HashMap<String, String>,
|
|
|
|
insert_anchor: InsertAnchor,
|
|
|
|
) -> Context<'a> {
|
2017-05-22 11:28:43 +00:00
|
|
|
Context {
|
|
|
|
tera,
|
2017-06-16 04:00:48 +00:00
|
|
|
current_page_permalink: current_page_permalink.to_string(),
|
2017-05-22 11:28:43 +00:00
|
|
|
permalinks,
|
|
|
|
insert_anchor,
|
2017-07-01 07:47:41 +00:00
|
|
|
highlight_code,
|
|
|
|
highlight_theme,
|
2017-05-22 11:28:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn should_insert_anchor(&self) -> bool {
|
|
|
|
self.insert_anchor != InsertAnchor::None
|
|
|
|
}
|
|
|
|
}
|