diff options
author | Curtis Timson <curt@live.co.uk> | 2018-02-25 02:31:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-25 02:31:48 +0300 |
commit | e52842ad8fb8b2b5f414b6d17af2af4affa97b66 (patch) | |
tree | ca40ceb7409eb01e6b0e33c09d40af18f7b56666 | |
parent | bbb26781412a2c43c25ff8dd39952e235bb23603 (diff) | |
parent | 4f3a6eaabdec5a035a3bbdadd8a26ff110267921 (diff) |
Merge pull request #4 from curttimson/feature/google-analytics
Feature/google analytics
-rw-r--r-- | exampleSite/config.toml | 6 | ||||
-rw-r--r-- | exampleSite/content/post/post.9.md | 8 | ||||
-rw-r--r-- | layouts/_default/single.html | 6 | ||||
-rw-r--r-- | layouts/index.html | 2 | ||||
-rw-r--r-- | layouts/partials/scripts/disqus.html | 19 | ||||
-rw-r--r-- | layouts/partials/scripts/googleanalytics.html | 11 | ||||
-rw-r--r-- | layouts/partials/scripts/index.html (renamed from layouts/partials/scripts.html) | 5 | ||||
-rw-r--r-- | package.json | 2 |
8 files changed, 54 insertions, 5 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8e6d3bc..29419d6 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -4,4 +4,8 @@ baseURL = "http://localhost:1313/" theme = "../.." [params.posts] - foldername = "post"
\ No newline at end of file + foldername = "post" + +[params.settings] + googleanalytics = "UA-113904582-3" + disqus = "hugo-massively"
\ No newline at end of file diff --git a/exampleSite/content/post/post.9.md b/exampleSite/content/post/post.9.md new file mode 100644 index 0000000..8397ee2 --- /dev/null +++ b/exampleSite/content/post/post.9.md @@ -0,0 +1,8 @@ ++++ +title = 'Comments example' +slug = 'comments-example' +image = 'images/pic04.jpg' +date = "2018-02-20T00:00:00" +description = 'Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis magna etiam.' +disqusid = '9' ++++
\ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 298baf0..353c6d4 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -23,6 +23,10 @@ <div class="image main"><img src="{{ .Site.BaseURL }}{{ .Params.image }}" alt="" /></div> {{ end }} {{ .Content }} + + {{ if .Params.disqusid }} + <div id="disqus_thread"></div> + {{ end }} </section> </div> @@ -31,6 +35,6 @@ {{ partial "copyright" . }} </div> - {{ partial "scripts" . }} + {{ partial "scripts/index" . }} </body> </html>
\ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html index 3b2978d..bbc3c4f 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -62,7 +62,7 @@ {{ partial "copyright" . }} </div> - {{ partial "scripts" . }} + {{ partial "scripts/index" . }} </body> </html>
\ No newline at end of file diff --git a/layouts/partials/scripts/disqus.html b/layouts/partials/scripts/disqus.html new file mode 100644 index 0000000..f698609 --- /dev/null +++ b/layouts/partials/scripts/disqus.html @@ -0,0 +1,19 @@ +{{ if and (.Site.Params.Settings.disqus) (.Params.disqusid) }} +<script> + /** + * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS. + * LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/ + + var disqus_config = function () { + this.page.url = {{ .Permalink }}; // Replace PAGE_URL with your page's canonical URL variable + this.page.identifier = {{ .Params.disqusid }}; // Replace PAGE_IDENTIFIER with your page's unique identifier variable + }; + + (function() { // DON'T EDIT BELOW THIS LINE + var d = document, s = d.createElement('script'); + s.src = 'https://{{ .Site.Params.Settings.disqus }}.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + })(); + </script> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/scripts/googleanalytics.html b/layouts/partials/scripts/googleanalytics.html new file mode 100644 index 0000000..98a3c47 --- /dev/null +++ b/layouts/partials/scripts/googleanalytics.html @@ -0,0 +1,11 @@ +{{ if .Site.Params.Settings.googleanalytics }} +<!-- Global site tag (gtag.js) - Google Analytics --> +<script async src="https://www.googletagmanager.com/gtag/js?id=UA-113904582-1"></script> +<script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + + gtag('config', {{ .Site.Params.Settings.googleanalytics }}); +</script> +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts/index.html index 55cf570..f541a6a 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts/index.html @@ -4,4 +4,7 @@ <script src="{{ .Site.BaseURL }}assets/js/jquery.scrolly.min.js"></script> <script src="{{ .Site.BaseURL }}assets/js/skel.min.js"></script> <script src="{{ .Site.BaseURL }}assets/js/util.js"></script> -<script src="{{ .Site.BaseURL }}assets/js/main.js"></script>
\ No newline at end of file +<script src="{{ .Site.BaseURL }}assets/js/main.js"></script> + +{{ partial "scripts/googleanalytics" . }} +{{ partial "scripts/disqus" . }}
\ No newline at end of file diff --git a/package.json b/package.json index 6345c30..1e866ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hugo-theme-massively", - "version": "0.2.0", + "version": "0.3.0", "description": "HTML5 UP theme Massively for Hugo", "main": "index.js", "scripts": { |