mirror of
https://github.com/robbieandrew/robbieandrew.github.io.git
synced 2025-10-06 07:12:40 +02:00
11 lines
424 B
JavaScript
11 lines
424 B
JavaScript
// Replace the innerHTML of any tag with attribute data-include with the specified file
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
document.querySelectorAll("[data-include]").forEach(el => {
|
|
const file = el.getAttribute("data-include");
|
|
fetch(file)
|
|
.then(response => response.text())
|
|
.then(data => el.innerHTML = data)
|
|
.catch(error => console.error(`Error loading ${file}:`, error));
|
|
});
|
|
});
|