fix: make copy button copy raw markdown

This commit is contained in:
swaits committed 2025-10-07 16:34:20 -07:00
1 parent 5d6f929cc4
commit e1c6604432
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -231,7 +231,7 @@
{{ block "main" . }}{{ end }} {{ block "main" . }}{{ end }}
<p class="license">Licensed under <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 1.0</a> • Copyright © 2025 Stephen Waits</p> <p class="license">Licensed under <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 1.0</a> • Copyright © 2025 Stephen Waits</p>
<script> <script>
function copyCoC(){var t=document.querySelector('.coc-box').innerText;navigator.clipboard.writeText(t).then(function(){alert('Copied!')});} function copyCoC(){var t=document.querySelector('.coc-box').getAttribute('data-raw-content');navigator.clipboard.writeText(t).then(function(){alert('Copied!')});}
function updateThemeBtn(){var d=window.matchMedia('(prefers-color-scheme: dark)').matches;var t=document.body.dataset.theme;var dark=t=='dark'||(t==''&&d)||(!t&&d);document.getElementById('theme-btn').textContent=dark?'☀︎':'☾';} function updateThemeBtn(){var d=window.matchMedia('(prefers-color-scheme: dark)').matches;var t=document.body.dataset.theme;var dark=t=='dark'||(t==''&&d)||(!t&&d);document.getElementById('theme-btn').textContent=dark?'☀︎':'☾';}
function toggleTheme(){var d=window.matchMedia('(prefers-color-scheme: dark)').matches;var t=document.body.dataset.theme;var dark=t=='dark'||(t==''&&d)||(!t&&d);document.body.dataset.theme=dark?'light':'dark';updateThemeBtn();} function toggleTheme(){var d=window.matchMedia('(prefers-color-scheme: dark)').matches;var t=document.body.dataset.theme;var dark=t=='dark'||(t==''&&d)||(!t&&d);document.body.dataset.theme=dark?'light':'dark';updateThemeBtn();}
updateThemeBtn(); updateThemeBtn();
+1 -1
View File
@@ -1,7 +1,7 @@
{{ define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end }} {{ define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end }}
{{ define "main" }} {{ define "main" }}
<div class="coc-box"> <div class="coc-box" data-raw-content="{{ .RawContent }}">
<button class="copy-btn" onclick="copyCoC()">[copy]</button> <button class="copy-btn" onclick="copyCoC()">[copy]</button>
{{ .Content }} {{ .Content }}
</div> </div>
+1 -1
View File
@@ -2,7 +2,7 @@
{{ define "main" }} {{ define "main" }}
{{ $latest := index (where .Site.RegularPages "Section" "versions").ByDate.Reverse 0 }} {{ $latest := index (where .Site.RegularPages "Section" "versions").ByDate.Reverse 0 }}
<div class="coc-box"> <div class="coc-box" data-raw-content="{{ $latest.RawContent }}">
<button class="copy-btn" onclick="copyCoC()">[copy]</button> <button class="copy-btn" onclick="copyCoC()">[copy]</button>
{{ $latest.Content }} {{ $latest.Content }}
</div> </div>