Skip to content

Commit 79289a6

Browse files
fix main.js header and footer
1 parent 569cb6c commit 79289a6

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

js/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,23 @@ document.addEventListener('DOMContentLoaded', () => {
5555
});
5656
}
5757

58+
const resolveToRoot = (url) => {
59+
if (/^https?:\/\//i.test(url)) return url;
60+
return url.startsWith('/') ? url : `/${url}`;
61+
};
62+
5863
const loadHTML = (selector, url, callback) => {
5964
const element = document.querySelector(selector);
6065
if (element) {
61-
fetch(url)
66+
const finalUrl = resolveToRoot(url);
67+
fetch(finalUrl, { cache: 'no-store' })
6268
.then(response => response.ok ? response.text() : Promise.reject('File not found.'))
6369
.then(data => {
6470
element.innerHTML = data;
6571
if (callback) callback();
6672
})
6773
.catch(error => {
68-
console.error(`Failed to load ${url}:`, error);
74+
console.error(`Failed to load ${finalUrl}:`, error);
6975
});
7076
}
7177
};

news/2023_11/getting-ready-to-range-20.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ <h3>The Future Of Range Engine 2.0</h3>
7373
const icons = document.querySelectorAll('i');
7474
icons.forEach(icon => { icon.setAttribute('translate', 'no'); });
7575
</script>
76-
<script src="../../js/main.js" defer></script>
76+
<script src="/js/main.js" defer></script>
7777
</body>
7878
</html>

news/2023_11/range-engine-15-is-out.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ <h3>Getting Ready To Range 2.0</h3>
7171
const icons = document.querySelectorAll('i');
7272
icons.forEach(icon => { icon.setAttribute('translate', 'no'); });
7373
</script>
74-
<script src="../../js/main.js" defer></script>
74+
<script src="/js/main.js" defer></script>
7575
</body>
7676
</html>

news/2023_12/the-future-of-range-engine-16.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ <h3>Getting Ready To Range 2.0</h3>
7272
const icons = document.querySelectorAll('i');
7373
icons.forEach(icon => { icon.setAttribute('translate', 'no'); });
7474
</script>
75-
<script src="../../js/main.js" defer></script>
75+
<script src="/js/main.js" defer></script>
7676
</body>
7777
</html>

news/2024_03/range-engine-15a-is-out.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ <h3>The Future Of Range Engine 1.6</h3>
7777
const icons = document.querySelectorAll('i');
7878
icons.forEach(icon => { icon.setAttribute('translate', 'no'); });
7979
</script>
80-
<script src="../../js/main.js" defer></script>
80+
<script src="/js/main.js" defer></script>
8181
</body>
8282
</html>

0 commit comments

Comments
 (0)