divyam.dev/layouts/_default/baseof.html
Divyam Ahuja bf8b466229
Some checks are pending
Deploy Hugo site to Pages / build (push) Waiting to run
Deploy Hugo site to Pages / deploy (push) Blocked by required conditions
UI enhancements: homepage de-duplication, copy code button, article links on projects, reading time
2026-11-10 02:02:31 +05:30

43 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html lang="{{ site.Language.Locale | default "en" }}">
<head>
{{- partial "head.html" . -}}
</head>
<body>
<div class="site-wrapper">
{{- partial "header.html" . -}}
<main>
{{- block "main" . }}{{ end -}}
</main>
</div>
{{- partial "footer.html" . -}}
<script>
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('pre').forEach(pre => {
const btn = document.createElement('button');
btn.className = 'copy-code-btn';
btn.type = 'button';
btn.setAttribute('aria-label', 'Copy code to clipboard');
btn.innerText = 'copy';
btn.addEventListener('click', async () => {
const codeEl = pre.querySelector('code');
const text = codeEl ? codeEl.innerText : pre.innerText;
try {
await navigator.clipboard.writeText(text);
btn.innerText = 'copied!';
btn.classList.add('copied');
setTimeout(() => {
btn.innerText = 'copy';
btn.classList.remove('copied');
}, 2000);
} catch (err) {
btn.innerText = 'failed';
}
});
pre.appendChild(btn);
});
});
</script>
</body>
</html>