basic simili svelte workflow created

This commit is contained in:
asus
2023-10-27 16:11:42 +02:00
parent ac764c469a
commit 8c84ee4073
13 changed files with 482 additions and 878 deletions

19
scripts/insert_html.js Normal file
View File

@@ -0,0 +1,19 @@
function insert_html() {
let elements = document.getElementsByClassName("insert_html");
for (let element of elements) {
let path = (element.dataset.path);
fetch(path)
.then(response => response.text())
.then(data => element.innerHTML = data)
.catch(error => console.log('Error:', error));
element.classList.replace("insert_html", "inserted_html");
};
}
// create an observer on everytime some HTML is loaded on the whole page (heavy solution...)
const callback = (mutation_list, observer) => insert_html();
const observer = new MutationObserver(callback);
const targetNode = document.body;
const config = { attributes: true, childList: true, subtree: true };
// Start observing the target node for configured mutations
observer.observe(targetNode, config);