basic simili svelte workflow created
This commit is contained in:
16
scripts/build.sh
Normal file
16
scripts/build.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define the file to watch
|
||||
file_to_watch="./"
|
||||
|
||||
# Watch for modification events on the file continuously, with a minimum interval of 1s
|
||||
last_modified=0
|
||||
while read -r directory events filename; do
|
||||
current_time=$(date +%s) # Get the current time in seconds
|
||||
|
||||
if [ "$current_time" -gt "$last_modified" ]; then
|
||||
last_modified=$current_time
|
||||
echo "$current_time - The file $filename was modified."
|
||||
fi
|
||||
done < <(inotifywait -q --monitor --event modify "$file_to_watch")
|
||||
|
||||
19
scripts/insert_html.js
Normal file
19
scripts/insert_html.js
Normal 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);
|
||||
Reference in New Issue
Block a user