Skip to content

Commit c2cd888

Browse files
author
OpenClaw Sync
committed
Fix copy button: use wrapper div, fix 8GB RAM
1 parent ed2304d commit c2cd888

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

_posts/2026-03-11-nixclaw-declarative-ai-agents-on-nixos.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ curl -s https://mattermost.fitzsky.com/api/v4/teams \
5959

6060
## The VM
6161

62-
In Proxmox, create a VM with UEFI (OVMF), q35 machine type, VirtIO SCSI, and QEMU agent enabled. I gave mine 256GB disk, 10 CPU threads, and 4GB RAM. That's probably overkill for what amounts to a gateway process, but I had the headroom.
62+
In Proxmox, create a VM with UEFI (OVMF), q35 machine type, VirtIO SCSI, and QEMU agent enabled. I gave mine 256GB disk, 10 CPU threads, and 8GB RAM. That's probably overkill for what amounts to a gateway process, but I had the headroom.
6363

6464
Boot the NixOS 25.11 minimal ISO. At the boot menu, pick "Linux LTS" — that's a kernel option in the boot menu, not a separate ISO.
6565

assets/css/main.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,16 @@ main {
405405
.highlight .gd { color: #e06c75; } /* diff deleted */
406406
.highlight .gi { color: #98c379; } /* diff inserted */
407407

408-
/* Copy button */
408+
/* Code block wrapper + copy button */
409+
.code-wrapper {
410+
position: relative;
411+
margin: 1.25rem 0;
412+
}
413+
414+
.code-wrapper pre {
415+
margin: 0;
416+
}
417+
409418
.copy-btn {
410419
position: absolute;
411420
top: 0.6rem;
@@ -425,8 +434,7 @@ main {
425434
z-index: 2;
426435
}
427436

428-
.highlight:hover .copy-btn,
429-
pre:hover .copy-btn {
437+
.code-wrapper:hover .copy-btn {
430438
opacity: 1;
431439
}
432440

@@ -476,10 +484,9 @@ pre:hover .copy-btn {
476484

477485
/* Highlight wrapper from Rouge */
478486
.post-content div.highlight {
479-
position: relative;
480487
margin: 1.25rem 0;
481488
border-radius: var(--radius);
482-
overflow: visible;
489+
overflow: hidden;
483490
}
484491

485492
.post-content div.highlight pre {

assets/js/main.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
// Code block copy button
22
document.addEventListener('DOMContentLoaded', () => {
3-
document.querySelectorAll('.post-content .highlight, .post-content > pre').forEach(el => {
4-
// Avoid duplicates: if this pre is inside a .highlight we already processed, skip
5-
if (el.tagName === 'PRE' && el.closest('.highlight')) return;
6-
7-
const container = el;
8-
container.style.position = 'relative';
9-
container.style.overflow = 'visible';
3+
document.querySelectorAll('.post-content pre.highlight, .post-content > pre').forEach(pre => {
4+
// Create a wrapper div for positioning
5+
const wrapper = document.createElement('div');
6+
wrapper.className = 'code-wrapper';
7+
pre.parentNode.insertBefore(wrapper, pre);
8+
wrapper.appendChild(pre);
109

1110
const btn = document.createElement('button');
1211
btn.className = 'copy-btn';
1312
btn.textContent = 'Copy';
1413
btn.setAttribute('aria-label', 'Copy code to clipboard');
1514

1615
btn.addEventListener('click', async () => {
17-
const code = container.querySelector('code');
18-
const text = code ? code.textContent : container.textContent;
16+
const code = pre.querySelector('code');
17+
const text = code ? code.textContent : pre.textContent;
1918

2019
try {
2120
await navigator.clipboard.writeText(text.trim());
@@ -31,7 +30,7 @@ document.addEventListener('DOMContentLoaded', () => {
3130
}
3231
});
3332

34-
container.appendChild(btn);
33+
wrapper.appendChild(btn);
3534
});
3635

3736
// Back to top button
@@ -42,16 +41,13 @@ document.addEventListener('DOMContentLoaded', () => {
4241
topBtn.textContent = '↑';
4342
document.body.appendChild(topBtn);
4443

45-
const toggleTopBtn = () => {
44+
window.addEventListener('scroll', () => {
4645
if (window.scrollY > 400) {
4746
topBtn.classList.add('visible');
4847
} else {
4948
topBtn.classList.remove('visible');
5049
}
51-
};
52-
53-
window.addEventListener('scroll', toggleTopBtn, { passive: true });
54-
toggleTopBtn();
50+
}, { passive: true });
5551

5652
topBtn.addEventListener('click', (e) => {
5753
e.preventDefault();

0 commit comments

Comments
 (0)