diff options
author | Yue Yang <g1enyy0ung@gmail.com> | 2021-05-26 20:03:55 +0300 |
---|---|---|
committer | Yue Yang <g1enyy0ung@gmail.com> | 2021-05-26 20:03:55 +0300 |
commit | 4435bdc8690229ed8022a833c3771a5ac0a451a2 (patch) | |
tree | dfb068fec1707f673e9dda1949794d3f3c4840b0 | |
parent | 8c25e47e4214570747f190590430ea3ace2cf4b6 (diff) |
Move Disqus to partials
-rw-r--r-- | layouts/_default/single.html | 21 | ||||
-rw-r--r-- | layouts/partials/back.html | 21 | ||||
-rw-r--r-- | layouts/partials/disqus.html | 23 |
3 files changed, 25 insertions, 40 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 14fe506..e93bbbe 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -112,26 +112,7 @@ {{ if .Site.DisqusShortname }} <article class="ui segment post-disqus-area" data-html2canvas-ignore> - <div id="disqus_thread"></div> - <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 = '{{ .RelPermalink }}'; // 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.DisqusShortname }}' + '.disqus.com/embed.js'; - s.setAttribute('data-timestamp', +new Date()); - (d.head || d.body).appendChild(s); - })(); - </script> - <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> + {{ partial "disqus.html" (dict "Context" . "Identifier" .RelPermalink) }} </article> {{ end }} diff --git a/layouts/partials/back.html b/layouts/partials/back.html index af36320..695f7d2 100644 --- a/layouts/partials/back.html +++ b/layouts/partials/back.html @@ -32,26 +32,7 @@ {{ if and .Site.DisqusShortname }} <div class="sixteen wide mobile eight wide tablet eight wide computer column dream-column"> <article class="ui segment"> - <div id="disqus_thread"></div> - <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 = '/'; // 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.DisqusShortname }}' + '.disqus.com/embed.js'; - s.setAttribute('data-timestamp', +new Date()); - (d.head || d.body).appendChild(s); - })(); - </script> - <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> + {{ partial "disqus.html" (dict "Context" . "Identifier" "/") }} </article> </div> {{ end }} diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html new file mode 100644 index 0000000..328b62a --- /dev/null +++ b/layouts/partials/disqus.html @@ -0,0 +1,23 @@ +<div id="disqus_thread"></div> +<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 = {{ .Context.Permalink }} // Replace PAGE_URL with your page's canonical URL variable + this.page.identifier = {{ .Identifier }} // 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://' + {{ .Context.Site.DisqusShortname }} + '.disqus.com/embed.js' + s.setAttribute('data-timestamp', +new Date()) + ;(d.head || d.body).appendChild(s) + })() +</script> +<!-- prettier-ignore --> +<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> |