From 976785d7a90e88f5a5967c9b82997942f593e9eb Mon Sep 17 00:00:00 2001 From: Danielle De Leo Date: Wed, 1 Apr 2026 12:54:04 -0400 Subject: [PATCH] Fix: Use deterministic IDs for code block copy buttons --- layouts/_default/_markup/render-codeblock.html | 2 +- layouts/shortcodes/ghcode.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index b75e16ac..6ac4e79f 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -1,5 +1,5 @@ {{ $result := transform.HighlightCodeBlock . }} -{{ $codeBlockId := printf "id-%x" (now.UnixNano) }} +{{ $codeBlockId := printf "cb-%d" .Ordinal }} {{ $lines := split $result.Wrapped "\n" }} {{ $isSingleLine := eq (len $lines) 1 }} diff --git a/layouts/shortcodes/ghcode.html b/layouts/shortcodes/ghcode.html index 0bcafb13..27113af7 100644 --- a/layouts/shortcodes/ghcode.html +++ b/layouts/shortcodes/ghcode.html @@ -1,6 +1,6 @@ {{ $file := .Get 0 }} {{ $params := .Get 1 }} -{{ $codeBlockId := printf "id-%x" (now.UnixNano) }} +{{ $codeBlockId := printf "gh-%d" .Ordinal }} {{ with try (resources.GetRemote $file) }} {{ with .Err }} {{ errorf "%s" . }}