{{ .Description | plainify | htmlUnescape }}
+{{ partial "thought_text.html" . }}
+diff --git a/assets/css/extended/thoughts.css b/assets/css/extended/thoughts.css new file mode 100644 index 0000000..0948972 --- /dev/null +++ b/assets/css/extended/thoughts.css @@ -0,0 +1,232 @@ +/* Home thoughts preview */ +.thoughts-preview { + margin: calc(var(--gap) * 0.5) 0 calc(var(--gap) * 2); +} + +.thoughts-preview-header { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: var(--gap); + margin-bottom: var(--content-gap); +} + +.thoughts-preview-header h2 { + font-size: 20px; + font-weight: 600; + color: var(--primary); +} + +.thoughts-all-link { + flex-shrink: 0; + color: var(--secondary); + font-size: 13px; + text-decoration: none; +} + +.thoughts-all-link:hover, +.thoughts-all-link:focus-visible { + color: var(--standout); +} + +.thoughts-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: var(--gap); +} + +.thought-card { + position: relative; + display: flex; + flex-direction: column; + min-width: 0; + min-height: 30px; + padding: calc(var(--gap) * 0.75) var(--gap); + color: inherit; + background: var(--entry); + border: 1px solid var(--border); + border-radius: var(--radius); + text-decoration: none; + transition: + transform 0.25s ease, + border-color 0.25s ease; +} + +.thought-card:hover, +.thought-card:focus-visible { + transform: translateY(-2px); + border-color: var(--tertiary); +} + +.thought-card:focus-visible { + outline: 2px solid var(--standout); + outline-offset: 2px; +} + +.thought-card-text { + display: block; + font-weight: bold; + overflow: hidden; + color: var(--primary); + font-size: 18px; + line-height: 1.5; + text-overflow: ellipsis; + white-space: nowrap; +} + +.thought-card-meta { + display: block; + margin-top: auto; + padding-top: 0.6rem; + color: var(--secondary); + font-size: 12px; +} + +/* Thoughts timeline */ +.thought-timeline { + position: relative; + margin-top: var(--content-gap); + padding-left: 34px; +} + +.thought-timeline::before { + content: ""; + position: absolute; + top: 10px; + bottom: 10px; + left: 10px; + width: 2px; + background: var(--border); + border-radius: 2px; +} + +.thought-entry { + position: relative; + margin-bottom: var(--gap); + scroll-margin-top: calc(var(--header-height) + var(--gap)); +} + +.thought-entry::before { + content: ""; + position: absolute; + top: 22px; + left: -30px; + width: 10px; + height: 10px; + background: var(--standout); + border: 2px solid var(--code-bg); + border-radius: 50%; + box-sizing: content-box; +} + +[data-theme="dark"] .thought-entry::before { + border-color: var(--theme); +} + +.thought-entry-body { + padding: var(--content-gap); + background: var(--entry); + border: 1px solid var(--border); + border-radius: var(--radius); + transition: border-color 0.25s ease; +} + +.thought-entry:target .thought-entry-body { + border-color: var(--standout); + box-shadow: 0 0 0 1px var(--standout); +} + +.thought-entry-date { + display: block; + margin-bottom: 0.4rem; + color: var(--secondary); + font-size: 13px; +} + +.thought-entry-text { + color: var(--primary); + font-size: 18px; + font-weight: bold; + line-height: 1.5; + overflow-wrap: anywhere; +} + +.thought-timeline-more { + display: flex; + justify-content: center; + margin: calc(var(--gap) * 1.5) 0 var(--gap); +} + +.thought-load-more { + padding: 0.75rem 1.25rem; + color: var(--theme); + font: inherit; + font-size: 14px; + line-height: 1; + background: var(--primary); + border: 1px solid var(--primary); + border-radius: 999px; + cursor: pointer; + transition: + background 0.2s ease, + border-color 0.2s ease; +} + +.thought-load-more:hover, +.thought-load-more:focus-visible { + background: var(--standout); + border-color: var(--standout); +} + +.thought-load-more:focus-visible { + outline: 2px solid var(--standout); + outline-offset: 3px; +} + +.thought-load-more:disabled { + cursor: wait; + opacity: 0.65; +} + +.thought-empty { + color: var(--secondary); +} + +@media screen and (max-width: 768px) { + .thoughts-grid { + grid-template-columns: 1fr; + } + + .thought-card { + min-height: 0; + } + + .thought-timeline { + padding-left: 26px; + } + + .thought-entry::before { + left: -22px; + } + + .thought-entry-body { + padding: calc(var(--content-gap) * 0.85); + } + + .thought-entry-text { + font-size: 16px; + } +} + +@media (prefers-reduced-motion: reduce) { + .thought-card, + .thought-entry-body, + .thought-load-more { + transition: none; + } + + .thought-card:hover, + .thought-card:focus-visible { + transform: none; + } +} diff --git a/assets/js/thoughts.js b/assets/js/thoughts.js new file mode 100644 index 0000000..e12f94c --- /dev/null +++ b/assets/js/thoughts.js @@ -0,0 +1,87 @@ +(() => { + const timeline = document.getElementById("thought-timeline"); + const more = document.querySelector(".thought-timeline-more"); + const button = document.querySelector(".thought-load-more"); + if (!timeline || !button) return; + + const defaultLabel = button.textContent.trim(); + + async function loadPage(url) { + const response = await fetch(url, { credentials: "same-origin" }); + if (!response.ok) { + throw new Error(`Could not load ${url}: ${response.status}`); + } + + const html = await response.text(); + const doc = new DOMParser().parseFromString(html, "text/html"); + const nextTimeline = doc.getElementById("thought-timeline"); + const nextButton = doc.querySelector(".thought-load-more"); + + if (nextTimeline) { + timeline.append(...Array.from(nextTimeline.children)); + } + + if (nextButton && nextButton.dataset.next) { + button.dataset.next = nextButton.dataset.next; + return true; + } + + button.remove(); + if (more) more.remove(); + return false; + } + + async function loadOlder() { + if (button.disabled || !button.dataset.next) return; + + const next = button.dataset.next; + button.disabled = true; + button.textContent = "Loading…"; + + try { + await loadPage(next); + } catch (error) { + console.error(error); + window.location.href = next; + return; + } + + if (document.body.contains(button)) { + button.disabled = false; + button.textContent = defaultLabel; + } + } + + button.addEventListener("click", loadOlder); + + // A link to an older thought (for example from the RSS feed) may point to an + // entry that has not been loaded yet. Keep loading pages until it exists. + const hash = decodeURIComponent(window.location.hash.slice(1)); + if (hash && !document.getElementById(hash) && button.dataset.next) { + (async () => { + let next = button.dataset.next; + + while (next && !document.getElementById(hash)) { + button.disabled = true; + button.textContent = "Loading…"; + + try { + if (!(await loadPage(next))) break; + } catch (error) { + console.error(error); + break; + } + + next = button.dataset.next; + } + + if (document.body.contains(button)) { + button.disabled = false; + button.textContent = defaultLabel; + } + + const target = document.getElementById(hash); + if (target) target.scrollIntoView({ block: "start" }); + })(); + } +})(); diff --git a/content/thoughts/test.md b/content/thoughts/test.md new file mode 100644 index 0000000..ec0ff9b --- /dev/null +++ b/content/thoughts/test.md @@ -0,0 +1,6 @@ +--- +title: thought1 +date: 2026-09-20T18:34:00 +draft: false +--- +# this really is a feature, huh? diff --git a/content/thoughts/test2.md b/content/thoughts/test2.md new file mode 100644 index 0000000..9870ff6 --- /dev/null +++ b/content/thoughts/test2.md @@ -0,0 +1,6 @@ +--- +title: thought2 +date: 2026-09-20T19:34:00 +draft: false +--- +# This is a really long test thought to see what happens when things go into 2 lines and i go off on a tangent diff --git a/layouts/_partials/extend_head.html b/layouts/_partials/extend_head.html new file mode 100644 index 0000000..014301b --- /dev/null +++ b/layouts/_partials/extend_head.html @@ -0,0 +1,4 @@ +{{- if eq .Type "thoughts" }} +{{- $js := resources.Get "js/thoughts.js" | resources.Minify | resources.Fingerprint }} + +{{- end }} diff --git a/layouts/_partials/thought_anchor.html b/layouts/_partials/thought_anchor.html new file mode 100644 index 0000000..8dd0fd6 --- /dev/null +++ b/layouts/_partials/thought_anchor.html @@ -0,0 +1 @@ +{{- return (printf "thought-%s" (.File.ContentBaseName | urlize)) -}} diff --git a/layouts/_partials/thought_text.html b/layouts/_partials/thought_text.html new file mode 100644 index 0000000..cf13bf5 --- /dev/null +++ b/layouts/_partials/thought_text.html @@ -0,0 +1,10 @@ +{{- /* A thought is the first H1 in the page body. The front matter title is only a formality. */ -}} +{{- $matches := findRE `
{{ partial "thought_text.html" . }}
+{{ .Description | plainify | htmlUnescape }}
+No thoughts yet.
+{{- end }} {{- end }} diff --git a/themes/PaperMod b/themes/PaperMod index d376885..a8d4d49 160000 --- a/themes/PaperMod +++ b/themes/PaperMod @@ -1 +1 @@ -Subproject commit d3768854d00ad003b0a8dbdba254ce9224377a01 +Subproject commit a8d4d492a5e60767c8f077f86cf24a2b85c8bf8e