decor-6-site/assets/js/main.js

29 lines
587 B
JavaScript
Raw Normal View History

2026-01-05 19:33:15 +01:00
window.onload = function(){
init();
};
function slugify(text) {
return text.trim()
.toLowerCase()
.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-z0-9\s-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-');
}
function addHeadingIds(root) {
root.querySelectorAll('h3, h4').forEach(heading => {
if (!heading.id) {
heading.id = slugify(heading.textContent);
}
});
}
2026-01-05 19:33:15 +01:00
function init(){
let fadeEl = document.getElementById('fade');
if (fadeEl) {
fadeEl.classList.add('loaded');
}
addHeadingIds(document);
2026-01-05 19:33:15 +01:00
}