working draft of thoughts

This commit is contained in:
2026-11-05 11:58:07 +00:00
parent 5aa828852a
commit e60475cc93
13 changed files with 575 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
{{- if eq .Type "thoughts" }}
{{- $js := resources.Get "js/thoughts.js" | resources.Minify | resources.Fingerprint }}
<script defer src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- end }}

View File

@@ -0,0 +1 @@
{{- return (printf "thought-%s" (.File.ContentBaseName | urlize)) -}}

View File

@@ -0,0 +1,10 @@
{{- /* A thought is the first H1 in the page body. The front matter title is only a formality. */ -}}
{{- $matches := findRE `<h1[^>]*>[\s\S]*?</h1>` .Content 1 -}}
{{- $text := "" -}}
{{- with $matches -}}
{{- $text = index . 0 | plainify | htmlUnescape | strings.TrimSpace -}}
{{- end -}}
{{- if not $text -}}
{{- $text = .Plain | strings.TrimSpace -}}
{{- end -}}
{{- return $text -}}

View File

@@ -0,0 +1,6 @@
<article class="thought-entry" id="{{ partial "thought_anchor.html" . }}">
<div class="thought-entry-body">
<time class="thought-entry-date" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date | time.Format ":date_long" }}</time>
<p class="thought-entry-text">{{ partial "thought_text.html" . }}</p>
</div>
</article>

View File

@@ -0,0 +1,17 @@
{{- $thoughts := where site.RegularPages "Type" "thoughts" -}}
{{- $thoughts = $thoughts.ByDate.Reverse -}}
{{- with first 3 $thoughts -}}
<section class="thoughts-preview" aria-labelledby="thoughts-preview-heading">
<div class="thoughts-preview-header">
<h2 id="thoughts-preview-heading">Thoughts</h2>
<a class="thoughts-all-link" href="{{ "thoughts/" | relLangURL }}">All thoughts <span aria-hidden="true">&rarr;</span></a>
</div>
<div class="thoughts-grid">
{{- range . }}
<a class="thought-card" href="{{ "thoughts/" | relLangURL }}#{{ partial "thought_anchor.html" . }}">
<span class="thought-card-text">{{ partial "thought_text.html" . }}</span>
</a>
{{- end }}
</div>
</section>
{{- end -}}