From 9b3a38fa163f8e8997b06c31bffc6878007f6054 Mon Sep 17 00:00:00 2001 From: Jannik Menzel Date: Fri, 20 Jun 2025 21:46:09 +0200 Subject: [PATCH] updated header, footer and feed js --- assets/js/main.js | 15 +++++-- layouts/_partials/footer.html | 81 +++++++++++++++++++++------------- layouts/_partials/head.html | 20 +++++++++ layouts/_partials/scripts.html | 15 ------- 4 files changed, 82 insertions(+), 49 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index b4ad436..183cd01 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,5 +1,3 @@ -// noinspection JSUnresolvedReference - /* ======================== Darkmode ======================== */ @@ -62,6 +60,8 @@ window.toggleDetails = function (element) { /* ======================== News Feed ======================== */ +let lastColumnCount = null; + function renderFeedEntries(data) { const container = document.getElementById('feed'); if (!container) return; @@ -71,6 +71,7 @@ function renderFeedEntries(data) { if (isInFeedSection) { const computedStyle = window.getComputedStyle(container); const columnCount = computedStyle.getPropertyValue('grid-template-columns').split(' ').length; + lastColumnCount = columnCount; maxItems = columnCount === 3 ? 3 : 4; } else { maxItems = data.items.length; @@ -119,6 +120,14 @@ fetch('https://api.rss2json.com/v1/api.json?rss_url=https://toot.kif.rocks/@ifsr .then(data => { renderFeedEntries(data); window.addEventListener('resize', () => { - renderFeedEntries(data); + const container = document.getElementById('feed'); + if (!container) return; + + const computedStyle = window.getComputedStyle(container); + const columnCount = computedStyle.getPropertyValue('grid-template-columns').split(' ').length; + + if (columnCount !== lastColumnCount) { + renderFeedEntries(data); + } }); }); \ No newline at end of file diff --git a/layouts/_partials/footer.html b/layouts/_partials/footer.html index c8934a8..eeab750 100644 --- a/layouts/_partials/footer.html +++ b/layouts/_partials/footer.html @@ -1,36 +1,55 @@ \ No newline at end of file diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html index 55eb157..d1dda05 100644 --- a/layouts/_partials/head.html +++ b/layouts/_partials/head.html @@ -3,10 +3,12 @@ + + + + {{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }} + + + {{ partial "scripts.html" . }} {{ partial "event-calendar.html" . }} diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html index 96746eb..41a7460 100644 --- a/layouts/_partials/scripts.html +++ b/layouts/_partials/scripts.html @@ -1,18 +1,3 @@ - - {{ if .IsHome }}