working draft of thoughts
This commit is contained in:
4
layouts/_partials/extend_head.html
Normal file
4
layouts/_partials/extend_head.html
Normal 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 }}
|
||||
1
layouts/_partials/thought_anchor.html
Normal file
1
layouts/_partials/thought_anchor.html
Normal file
@@ -0,0 +1 @@
|
||||
{{- return (printf "thought-%s" (.File.ContentBaseName | urlize)) -}}
|
||||
10
layouts/_partials/thought_text.html
Normal file
10
layouts/_partials/thought_text.html
Normal 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 -}}
|
||||
6
layouts/_partials/thought_timeline_entry.html
Normal file
6
layouts/_partials/thought_timeline_entry.html
Normal 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>
|
||||
17
layouts/_partials/thoughts_preview.html
Normal file
17
layouts/_partials/thoughts_preview.html
Normal 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">→</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 -}}
|
||||
Reference in New Issue
Block a user