Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stat counter #72

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- '!master' # excludes master
- '!main' # excludes main
- '**' # matches every branch
branches-ignore:
- 'master' # excludes master
- 'main' # excludes main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

File renamed without changes.
19 changes: 19 additions & 0 deletions assets/js/projects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Filterizr from 'filterizr'
import { insertScript } from '../core'

document.addEventListener('DOMContentLoaded', () => {
// ================== Project cards =====================

// setup project filter buttons
const projectCardHolder = document.getElementById('project-card-holder')
if (projectCardHolder != null && projectCardHolder.children.length !== 0) {
// eslint-disable-next-line no-new
new Filterizr('.filtr-projects', {
layout: 'sameWidth',
controlsSelector: '.project-filtr-control'
})
}
})

// dynamically insert github buttons script.
insertScript('github-buttons', 'https://buttons.github.io/buttons.js')
37 changes: 29 additions & 8 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ markup:
endLevel: 6
ordered: false

# Enable Google Analytics
# .Site.Config.Services.GoogleAnalytics.ID: UA-10503049-6
analytics:
enable: true
services:
google:
id: UA-10503049-6
# Enable global emoji support
enableEmoji: true

# At least HTML and JSON are required for the main HTML content and
# client-side JavaScript search
outputs:
home:
- HTML
- RSS
- JSON

# Site parameters
params:

# Background image of the landing page
background: /images/site/background2.jpg
hero-background: /images/site/blue-bg.jpg
Expand All @@ -77,6 +79,17 @@ params:
enable: true
flags:
enable: true
# Enable Google Analytics
analytics:
enabled: true
services:
google:
id: UA-10503049-6
statcounter:
project: 10096606
security: 2eda6207
invisible: 1

# Provide logos for your site. The inverted logo will be used in the initial
# transparent navbar and the main logo will be used in the non-transparent navbar.
# It will default to the theme logos if not provided.
Expand Down Expand Up @@ -116,4 +129,12 @@ module:
- source: ./node_modules/@fontsource/mulish/files
target: static/files
- source: ./node_modules/katex/dist/fonts
target: static/fonts
target: static/fonts

privacy:
googleAnalytics:
disable: false
respectDoNotTrack: true
statcounter:
disable: false
respectDoNotTrack: true
85 changes: 85 additions & 0 deletions layouts/partials/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!-- Add Analytics if enabled in configuration -->
{{ with site.Params.features.analytics }}
{{ if or .enable .enabled }}

{{ with .services }}
<!-- Google Analytics -->
{{ with .google }}
{{ $privacyConfig:= dict (slice "Site" "Config" "Privacy" "GoogleAnalytics") $.Site.Config.Privacy.GoogleAnalytics }}
{{ $analyticsConfig := dict (slice "Site" "Config" "Services" "GoogleAnalytics" "ID") .id }}
{{ template "_internal/google_analytics.html" (merge $privacyConfig $analyticsConfig) }}
{{ end }}

<!-- Counter.dev -->
{{ with .counterDev }}
<script src="https://cdn.counter.dev/script.js"
data-id="{{ .id }}"
data-utcoffset="1"
></script>
{{ end }}

<!-- GoatCounter -->
{{ with .goatCounter }}
{{ with .code }}
<script data-goatcounter="https://{{ . }}.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
{{ else }}
<script data-goatcounter="https://{{ .instance }}/count" async src="https://{{ .instance }}/count.js"></script>
{{ end }}
{{ end }}

<!-- Piwik/Matomo -->
{{ with .matomo }}
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ .instance }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ .siteId }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{{ end }}

{{ with .cloudflare }}
<!-- Cloudflare Web Analytics -->
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "{{ .token }}"}'
></script>
<!-- End Cloudflare Web Analytics -->
{{ end }}

{{ with .umami }}
<!-- Umami analytics -->
<script defer src='{{ or .scheme "https" }}://{{ or .instance "analytics.eu.umami.is" }}/script.js' data-website-id="{{ .id }}"></script>
<!-- End Umami analytics -->
{{end}}

{{ with .statcounter }}
<script type="text/javascript">
console.log("Statcounter enabled");
var sc_project = {{ .project }};
var sc_invisible = {{ .invisible }};
var sc_security = "{{ .security }}";
var scJsHost = (("https:" == document.location.protocol) ?
"https://www.statcounter.com/js/" : "https://www.statcounter.com/js/");
</script>
<noscript>
<div class="statcounter"><a title="web counter" href="https://statcounter.com/" target="_blank"><img class="statcounter"
src="https://c.statcounter.com/{{ .project }}/0/{{ .security }}/{{ .invisible }}/" alt="web counter"
referrerPolicy="no-referrer-when-downgrade"></a></div>
<!-- End of Statcounter Code -->
</noscript>
{{ end }}
{{ end }}
{{ end }}
{{ end }}

<!-- Keep backwards compatibility and consistency with HUGO defaults -->
{{ if .Site.Config.Services.GoogleAnalytics.ID }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
19 changes: 19 additions & 0 deletions layouts/partials/cards/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="post-card">
<a href="{{ .RelPermalink | relLangURL }}" class="post-card-link">
<div class="card">
<div class="card-head">
<img class="card-img-top" src='{{ partial "helpers/get-hero.html" . }}' />

</div>
<div class="card-body">
<h5 class="card-title">{{ .Title }}</h5>
<p class="card-text post-summary">{{ .Summary }}</p>
<p class="reading-time"><strong>Reading Time:</strong> {{ .ReadingTime }} minutes</p>
</div>
<div class="card-footer">
<span class="float-left">{{ .Date.Format "January 2, 2006" }}</span>
<a href="{{ .RelPermalink | relLangURL }}" class="float-right btn btn-outline-info btn-sm">Read</a>
</div>
</div>
</a>
</div>
1 change: 0 additions & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,4 @@ <h5>Site Details:</h5>
</div>
</div>
</div>
{{ partial "helpers/statcounter.html" }}
</footer>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Default Statcounter code for Davidgs blog
https://davidgs.com/ -->
<script type="text/javascript" nonce="GfYXQKOc0WQSIBpKTPZjc9Dn/oDf7swy+RvK9FWKM9Q=">
<!-- <script type="text/javascript" nonce="GfYXQKOc0WQSIBpKTPZjc9Dn/oDf7swy+RvK9FWKM9Q=">
var sc_project = 10096606;
var sc_invisible = 1;
var sc_security = "2eda6207";
Expand All @@ -9,7 +9,6 @@
<noscript>
<div class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"><img
class="statcounter" src="https://c.statcounter.com/10096606/0/2eda6207/1/" alt="Web Analytics"></a></div>
<!-- Added some foo! -->
</noscript>
</noscript> -->

<!-- End of Statcounter Code -->
1 change: 0 additions & 1 deletion themes/hugo-video
Submodule hugo-video deleted from bc3ef0
File renamed without changes.
File renamed without changes.
Loading