From 76a42a9cea48ee1713b5b0318b09f9bd0bcba0cd Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 8 May 2026 17:54:15 +0200 Subject: fix: guard against double JS execution and fix partial page context Co-Authored-By: Claude Sonnet 4.6 --- assets/js/contribution-graph.js | 3 +++ layouts/partials/contribution-graph.html | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/js/contribution-graph.js b/assets/js/contribution-graph.js index ccf4a7f..cd6dfdc 100644 --- a/assets/js/contribution-graph.js +++ b/assets/js/contribution-graph.js @@ -1,6 +1,9 @@ (function () { 'use strict'; + if (window._contribGraphLoaded) return; + window._contribGraphLoaded = true; + var MONTHS = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var I18N = { diff --git a/layouts/partials/contribution-graph.html b/layouts/partials/contribution-graph.html index 5dde2b4..dc95811 100644 --- a/layouts/partials/contribution-graph.html +++ b/layouts/partials/contribution-graph.html @@ -1,5 +1,6 @@ {{- $cellSize := .cellSize | default 8 -}} -{{- $lang := .page.Lang | default "en" -}} +{{- $page := .page -}} +{{- $lang := $page.Lang | default "en" -}} {{- $label := i18n "contrib_widget_label" -}} {{- $heading := i18n "contrib_heading" -}} @@ -15,5 +16,8 @@ > -{{- $js := resources.Get "js/contribution-graph.js" | minify -}} - +{{- if not ($page.Scratch.Get "contrib-graph-js-loaded") -}} + {{- $page.Scratch.Set "contrib-graph-js-loaded" true -}} + {{- $js := resources.Get "js/contribution-graph.js" | minify -}} + +{{- end -}} -- cgit v1.2.3