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 /// Should `mdbook build` create files referenced from SUMMARY.md if they
/// don't exist /// don't exist
pub create_missing: bool, pub create_missing: bool,
pub google_analytics: Option<String>,
} }
impl MDBook { impl MDBook {
@ -75,7 +73,6 @@ impl MDBook {
livereload: None, livereload: None,
create_missing: true, create_missing: true,
google_analytics: None,
} }
} }
@ -492,6 +489,14 @@ impl MDBook {
None 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 // Construct book
fn parse_summary(&mut self) -> Result<(), Box<Error>> { fn parse_summary(&mut self) -> Result<(), Box<Error>> {
// When append becomes stable, use self.content.append() ... // 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 // 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)); data.insert("google_analytics".to_owned(), json!(ga));
} }