Skip to content

Commit

Permalink
refactor integration code
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelliao committed Jan 5, 2024
1 parent 62ac4fd commit 4337753
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 5 additions & 4 deletions source/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ site:
base-url: https://github.com/michaelliao/gitsite/blob/main/source
# display git link for quick edit:
link: true
comment:
disqus:
name: gitsite
google:
analytics: G-5Z40K7NBL5
contact:
name: Michael Liao
github: https://github.com/michaelliao/gitsite
twitter: https://twitter.com/liaoxuefeng
books:
index-marker: true

search:
# none = no search
# browser = flex search in browser
# google = google site search
type: browser
integration:
disqus-comment: gitsite
google-analytics: G-5Z40K7NBL5

build:
# copy special files under root dir (ignore if not found):
Expand Down
12 changes: 12 additions & 0 deletions themes/default/__base__.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<meta name="description" content="{{ site.description }}">
<meta name="keywords" content="{{ site.keywords }}">
<title>{% block title %} title {% endblock %}</title>

{% if site.integration and site.integration.googleAnalytics %}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.integration.googleAnalytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '{{ site.integration.googleAnalytics }}');
</script>
{% endif %}

<script>
// global status:
window.gs_status = {
Expand Down
4 changes: 2 additions & 2 deletions themes/default/__comment__.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- comment -->
{% if site.comment and site.comment.disqus and site.comment.disqus.name %}
{% if site.integration and site.integration.disqusComment %}
<hr class="gsc-border mt-4">
<div class="mb-4"></div>
<div id="disqus_thread"></div>
Expand All @@ -10,7 +10,7 @@
};
(function () {
var d = document, s = d.createElement('script');
s.src = 'https://{{ site.comment.disqus.name }}.disqus.com/embed.js';
s.src = 'https://{{ site.integration.disqusComment }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
Expand Down

0 comments on commit 4337753

Please sign in to comment.