Author SHA1 Message Date
bbaovanc c23b43342c WIP: finished implementation of Netlify _redirects
TBD will be caddy, not sure whether this is actually a good idea because
including a Caddy file directly from GitHub Actions accessible job
output might be a config injection risk.
2026-07-08 02:18:53 -05:00
bbaovanc 2f6db565a9 WIP: Add redirects in Netlify _redirects style using old guide
Uses this guide: https://honnef.co/articles/generating-netlify-_redirects-from-hugo/

I didn't realize until after doing all this that there's a guide for the
same thing in the official Hugo docs, so I'm about to migrate over to
that.
2026-07-08 01:51:20 -05:00
6 changed files with 52 additions and 27 deletions
+25
View File
@@ -0,0 +1,25 @@
// code block copy to clipboard
window.onload = () => {
document.querySelectorAll(".code-block").forEach(codeBlock => {
const button = codeBlock.querySelector(".code-header > .code-copy-button");
// lang will not be unset because we default it to text
// clone it so it doesn't change the actual DOM element
const codeElem = codeBlock.querySelector("code[data-lang]").cloneNode(true);
// bashsession: remove command output lines
codeElem.querySelectorAll(".go").forEach(e => e.parentNode.removeChild(e));
// bashsession: remove prompt symbol
codeElem.querySelectorAll(".gp").forEach(e => e.parentNode.removeChild(e));
const rawCode = codeElem.innerText;
const originalCopyText = button.innerHTML;
button.onclick = event => {
navigator.clipboard.writeText(rawCode);
// TODO: maybe we could add a fancier indicator, like a flash or something
event.target.innerHTML = "Copied!";
setTimeout(() => {
event.target.innerHTML = originalCopyText;
}, 3000);
}
});
}
-21
View File
@@ -1,21 +0,0 @@
// code block copy to clipboard
async function copy_to_clipboard(button) {
const codeBlock = button.parentElement.parentElement;
// lang will not be unset because we default it to textoriginalCopyText
// clone it so it doesn't change the actual DOM element
const codeElem = codeBlock.querySelector("code[data-lang]").cloneNode(true);
// bashsession: remove command output lines
codeElem.querySelectorAll(".go").forEach(e => e.parentNode.removeChild(e));
// bashsession: remove prompt symbol
codeElem.querySelectorAll(".gp").forEach(e => e.parentNode.removeChild(e));
const rawCode = codeElem.innerText;
await navigator.clipboard.writeText(rawCode);
// TODO: maybe we could add a fancier indicator, like a flash or something
button.innerHTML = "Copied!";
setTimeout(() => {
button.innerHTML = "{{ i18n "copy_to_clipboard" }}";
}, 3000);
}
+17
View File
@@ -21,6 +21,23 @@ taxonomies:
outputs:
page:
- html
home:
- html
- rss
- redirects
outputFormats:
# https://honnef.co/articles/generating-netlify-_redirects-from-hugo/
redirects:
baseName: _redirects
isPlainText: true
mediaType: text/redirects
root: true
mediaTypes:
# https://honnef.co/articles/generating-netlify-_redirects-from-hugo/
text/redirects:
delimeter: ""
privacy:
googleAnalytics:
+1 -2
View File
@@ -5,8 +5,7 @@
<div class="code-block">
<div class="code-block-header">
<pre class="code-block-type">{{ $type }}</pre>
{{/* https://blog.udemy.com/javascript-href/ */}}
<a href="javascript:null" onClick="javascript:copy_to_clipboard(this)" class="code-block-copy-button">
<a href="javascript:void(0)" class="code-block-copy-button">
{{ i18n "copy_to_clipboard" }}
</a>
</div>
+1 -3
View File
@@ -19,11 +19,9 @@
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
{{ end }}
{{ with resources.Get "js/bobatheme.tmpl.js" }}
{{ with resources.ExecuteAsTemplate "js/bobatheme.js" $ . | fingerprint "sha512" }}
{{ with resources.Get "js/bobatheme.js" | fingerprint "sha512" }}
<script defer src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ end }}
{{ if not hugo.IsServer }}
<script defer data-domain="bbaovanc.com" src="https://plausible.bbaovanc.com/js/bobalytics.outbound-links.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
+7
View File
@@ -0,0 +1,7 @@
{{ range hugo.Sites -}}
{{ range $p := .Pages -}}
{{ range .Aliases -}}
{{ . }} {{ $p.RelPermalink }}
{{ end -}}
{{ end -}}
{{ end -}}