Hugo site now

This commit is contained in:
Miguel Jacq 2026-01-06 09:51:05 +11:00
parent aceb297d4f
commit 995092af42
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
34 changed files with 1309 additions and 85 deletions

View file

@ -1,60 +0,0 @@
(function(){
// Copy-to-clipboard for code blocks
function setupCopyButtons(){
document.querySelectorAll('[data-copy-target]').forEach(function(btn){
btn.addEventListener('click', async function(){
var sel = btn.getAttribute('data-copy-target');
var el = document.querySelector(sel);
if(!el) return;
var text = el.innerText || el.textContent || '';
try{
await navigator.clipboard.writeText(text.trim());
var old = btn.innerHTML;
btn.innerHTML = 'Copied';
btn.classList.add('btn-success');
btn.classList.remove('btn-outline-secondary');
setTimeout(function(){
btn.innerHTML = old;
btn.classList.remove('btn-success');
btn.classList.add('btn-outline-secondary');
}, 1200);
}catch(e){
// Fallback
var ta = document.createElement('textarea');
ta.value = text.trim();
document.body.appendChild(ta);
ta.select();
try{ document.execCommand('copy'); }catch(_){}
document.body.removeChild(ta);
}
});
});
}
// Asciinema embed helper:
// Put <div class="asciicast" data-asciinema-id="12345"></div>
// Or provide a self-hosted player by swapping the script URL.
function setupAsciinema(){
document.querySelectorAll('.asciicast[data-asciinema-id]').forEach(function(el){
var id = el.getAttribute('data-asciinema-id');
if(!id || id === 'REPLACE_ME'){
el.innerHTML = '<div class="alert alert-warning mb-0">Add your asciinema id here: <code>data-asciinema-id</code>.</div>';
return;
}
// Avoid injecting twice
if(document.getElementById('asciinema-embed-'+id)) return;
var s = document.createElement('script');
s.src = 'https://asciinema.org/a/' + encodeURIComponent(id) + '.js';
s.id = 'asciinema-embed-'+id;
s.async = true;
// The script replaces a placeholder div with the player if it's directly after it.
el.appendChild(s);
});
}
document.addEventListener('DOMContentLoaded', function(){
setupCopyButtons();
setupAsciinema();
});
})();