Fix for google-analytics

This commit is contained in:
Mathieu David 2017-05-19 01:13:45 +02:00
parent 70383d0a25
commit 2e812db13c
2 changed files with 9 additions and 4 deletions

View File

@ -29,8 +29,6 @@ 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 {
@ -75,7 +73,6 @@ impl MDBook {
livereload: None,
create_missing: true,
google_analytics: None,
}
}
@ -492,6 +489,14 @@ impl MDBook {
None
}
pub fn get_google_analytics_id(&self) -> Option<String> {
if let Some(htmlconfig) = self.config.get_html_config() {
return htmlconfig.get_google_analytics_id();
}
None
}
// Construct book
fn parse_summary(&mut self) -> Result<(), Box<Error>> {
// When append becomes stable, use self.content.append() ...

View File

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