mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
Updated google analytics to index.hbs and hbs_renderer.rs
This commit is contained in:
parent
e8b88cfa5e
commit
4a634f08da
2 changed files with 16 additions and 0 deletions
|
@ -193,6 +193,9 @@ fn make_data(book: &MDBook) -> Result<serde_json::Map<String, serde_json::Value>
|
|||
data.insert("livereload".to_owned(), json!(livereload));
|
||||
}
|
||||
|
||||
// Add google analytics tag
|
||||
data.insert("google_analytics".to_owned(), json!("INSERT_GA_ID_HERE"));
|
||||
|
||||
let mut chapters = vec![];
|
||||
|
||||
for item in book.iter() {
|
||||
|
|
|
@ -111,6 +111,19 @@
|
|||
<!-- Livereload script (if served using the cli tool) -->
|
||||
{{{livereload}}}
|
||||
|
||||
{{#if google_analytics}}
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{google_analytics}}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
|
||||
<script src="highlight.js"></script>
|
||||
<script src="book.js"></script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue