Added google_analytics so it can be inserted into handlebars

This commit is contained in:
Michael-F-Bryan 2017-05-16 13:24:05 +08:00
parent ada1f29b34
commit 94dce4f796
2 changed files with 6 additions and 1 deletions

View File

@ -36,6 +36,8 @@ pub struct MDBook {
/// Should `mdbook build` create files referenced from SUMMARY.md if they
/// don't exist
pub create_missing: bool,
pub google_analytics: Option<String>,
}
impl MDBook {
@ -84,6 +86,7 @@ impl MDBook {
livereload: None,
create_missing: true,
google_analytics: None,
}
}

View File

@ -194,7 +194,9 @@ fn make_data(book: &MDBook) -> Result<serde_json::Map<String, serde_json::Value>
}
// Add google analytics tag
data.insert("google_analytics".to_owned(), json!("INSERT_GA_ID_HERE"));
if let Some(ref ga) = book.google_analytics {
data.insert("google_analytics".to_owned(), json!(ga));
}
let mut chapters = vec![];