Skip to content

Commit e682831

Browse files
committed
docs(pages): center footer, add click-to-copy on all code blocks
Made-with: Cursor
1 parent e63fb54 commit e682831

1 file changed

Lines changed: 60 additions & 3 deletions

File tree

docs/_layouts/default.html

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,43 @@
217217
.site-footer {
218218
border-top: 1px solid #d0d7de;
219219
background: #f6f8fa;
220-
padding: 1.2rem 2rem;
220+
padding: 1.4rem 2rem;
221221
font-size: 0.8rem;
222222
color: #57606a;
223+
text-align: center;
223224
}
224225
.site-footer-owner a,
225226
.site-footer-credits a { color: #0969da; }
227+
.site-footer-credits { display: block; margin-top: 0.2rem; }
228+
229+
/* ── Copy button ── */
230+
.code-block-wrap {
231+
position: relative;
232+
}
233+
.copy-btn {
234+
position: absolute;
235+
top: 8px;
236+
right: 8px;
237+
background: #e6edf3;
238+
border: 1px solid #d0d7de;
239+
border-radius: 5px;
240+
padding: 3px 9px;
241+
font-size: 11px;
242+
font-family: "SFMono-Regular", Consolas, monospace;
243+
color: #57606a;
244+
cursor: pointer;
245+
opacity: 0;
246+
transition: opacity 0.15s, background 0.15s;
247+
line-height: 1.6;
248+
user-select: none;
249+
}
250+
.code-block-wrap:hover .copy-btn { opacity: 1; }
251+
.copy-btn.copied {
252+
background: #dafbe1;
253+
border-color: #2ea043;
254+
color: #116329;
255+
opacity: 1;
256+
}
226257

227258
/* ── Screenshot ── */
228259
.screenshot-wrap {
@@ -287,10 +318,9 @@
287318
<footer class="site-footer">
288319
<span class="site-footer-owner">
289320
<a href="https://github.com/TMHSDigital/subenum">subenum</a> is maintained by
290-
<a href="https://github.com/TMHSDigital">TMHSDigital</a>.
321+
<a href="https://github.com/TMHSDigital">TMHSDigital</a>
291322
</span>
292323
<span class="site-footer-credits">
293-
&nbsp;&middot;&nbsp;
294324
<a href="{{ '/CONTRIBUTING.html' | relative_url }}">Contributing</a>
295325
&nbsp;&middot;&nbsp;
296326
<a href="https://github.com/TMHSDigital/subenum/blob/main/SECURITY.md">Security</a>
@@ -300,5 +330,32 @@
300330
</footer>
301331
</main>
302332

333+
<script>
334+
// Click-to-copy for all code blocks
335+
document.querySelectorAll('pre').forEach(function(pre) {
336+
var wrap = document.createElement('div');
337+
wrap.className = 'code-block-wrap';
338+
pre.parentNode.insertBefore(wrap, pre);
339+
wrap.appendChild(pre);
340+
341+
var btn = document.createElement('button');
342+
btn.className = 'copy-btn';
343+
btn.textContent = 'copy';
344+
wrap.appendChild(btn);
345+
346+
btn.addEventListener('click', function() {
347+
var code = pre.querySelector('code');
348+
var text = code ? code.innerText : pre.innerText;
349+
navigator.clipboard.writeText(text).then(function() {
350+
btn.textContent = 'copied!';
351+
btn.classList.add('copied');
352+
setTimeout(function() {
353+
btn.textContent = 'copy';
354+
btn.classList.remove('copied');
355+
}, 2000);
356+
});
357+
});
358+
});
359+
</script>
303360
</body>
304361
</html>

0 commit comments

Comments
 (0)