Move a bunch of shortcodes and partials back from the platters theme

This commit is contained in:
Eryn Wells 2024-10-08 08:45:44 -07:00
parent 20d53e0df2
commit 3102dc1e56
29 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1 @@
<abbr {{ with .Get "title" }}title="{{ . }}"{{ end }}>{{ .Inner }}</abbr>

View file

@ -0,0 +1 @@
<span class="anagram" data-replacement="{{ with .Get 1 }}{{ . }}{{ end }}">{{ with .Get 0 }}{{ . }}{{ end }}</span>

View file

@ -0,0 +1,5 @@
{{ $id := .Get "id" }}
{{ $mp3 := (.Page.Resources.GetMatch (.Get "mp3")) }}
<audio {{ with $id }}id="{{ . }}"{{ end }}>
{{ with $mp3 }}<source src="{{ . }}" type="audio/mpeg">{{ end }}
</audio>

View file

@ -0,0 +1,9 @@
<!---->{{ if not (.Get "summary") }}
<!---->{{ errorf "missing param 'summary': %s" .Position }}
<!---->{{ else if not (.Get "content") }}{{ warnf "missing param 'content': %s" .Position }}
<!---->{{ end }}
<details {{ if (eq (.Get `openByDefault`) true) }}open="true" {{ end }}>
<summary markdown="span">{{ .Get "summary" | markdownify }}</summary>
{{ .Get "content" | markdownify }}
</details>

View file

@ -0,0 +1,4 @@
{{- $trimmedInner := trim .Inner "\n " -}}
<figure class="code">
{{ $.Page.RenderString $trimmedInner }}
</figure>

View file

@ -0,0 +1,45 @@
{{- $imgs := slice -}}
{{- $class := .Get "class" -}}
{{- $shouldResize := .Get "shouldResize" | default true -}}
{{- $shouldShowTitle := (.Get "shouldShowTitle") | default true -}}
{{- if .Get "name" -}}
{{- $imgs = $imgs | append (.Page.Resources.GetMatch (.Get "name")) -}}
{{- else if .Get "names" -}}
{{- range (split (.Get "names") ",") -}}
{{- $imgs = $imgs | append ($.Page.Resources.GetMatch .) -}}
{{- end -}}
{{- else -}}
{{ errorf "Missing name or names parameter to figures/image" }}
{{- end -}}
{{- if lt (len $imgs) 0 -}}
{{ errorf "No images found for name(s) parameter" }}
{{- end -}}
<figure {{ with $class }}class="{{ . }}"{{ end }}>
<div class=container>
{{ range $img := $imgs }}
{{- $linkedImg := $img -}}
{{ if not $img }}
{{ errorf "Found nil in images list for %s" $.Page.Permalink }}
{{ end }}
{{- if $shouldResize -}}
{{ $linkedImg = $img.Fit "1280x1280" }}
{{- end -}}
{{- $altText := $img.Params.alt | default $img.Title -}}
<a href="{{ $img.RelPermalink }}">
<img src="{{ $linkedImg.RelPermalink }}"
{{- with $altText }} alt="{{ . }}"{{- end }}
{{- with $img.Title }} title="{{ . }}"{{- end }}>
</a>
{{- end }}
</div>
{{ if and $shouldShowTitle -}}
{{- range $imgs -}}
{{- if gt (len .Title) 0 -}}
<figcaption>{{ .Title }}</figcaption>
{{- end -}}
{{- end -}}
{{- end }}
</figure>

View file

@ -0,0 +1,4 @@
{{- $id := .Get "id" -}}
<div class="centered">
<figure class="p5-sketch {{ with .Get "bordered" }}bordered{{ end }}" id="{{ $id }}"></figure>
</div>

View file

@ -0,0 +1,3 @@
{{- $id := .Get "id" -}}
<figure class="railroad-diagram" {{ if $id }}id="{{ $id }}"{{ end }}></figure>
{{ .Inner }}

View file

@ -0,0 +1,12 @@
{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
{{- if not $pc.Disable -}}
{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
{{- $id := .Get "id" | default (.Get 0) -}}
{{- $class := .Get "class" | default (.Get 1) -}}
{{- $title := .Get "title" | default "YouTube Video" }}
<figure {{ with $class }}class="{{ . }}"{{ end }}>
<div class="youtube">
<iframe src="https://{{ $ytHost }}/embed/{{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}?autoplay=1{{ end }}{{ end }}" allowfullscreen frameborder=0 title="{{ $title }}"></iframe>
</div>
</figure>
{{ end -}}

View file

@ -0,0 +1,3 @@
<div class="grid2">
{{ .Inner }}
</div>

View file

@ -0,0 +1,21 @@
{{ $img := dict }}
{{ with .Get "name" }}
{{ $img = $.Page.Resources.GetMatch . }}
{{ else }}
{{ errorf "No name given to img shortcode" }}
{{ end }}
{{/* Space separated list of classes to apply to the <img> tag */}}
{{ $classes := .Get "class" }}
{{ $altText := .Get "alt" | default $img.Params.alt }}
{{ if not $altText }}
{{ warnf "Image doesn't have alt text: %s" $img.RelPermalink }}
{{ end }}
{{ $resizedImg := $img.Fit "1280x1280" }}
<img src="{{ $resizedImg.RelPermalink }}"
width="{{ $resizedImg.Width }}"
height="{{ $resizedImg.Height }}"
alt="{{ $altText }}"
{{ with $classes }}class="{{ . }}"{{ end }}>

View file

@ -0,0 +1 @@
<span lang="{{ .Get 0 }}">{{ .Inner }}</span>{{- "" -}}

View file

@ -0,0 +1,3 @@
{{- $logfile := partial "nethack/log.html" . -}}
{{- $numberOfAscensions := where $logfile "death.cause" "ascended" | len -}}
{{- $numberOfAscensions | lang.FormatNumber 0 -}}

View file

@ -0,0 +1,10 @@
{{ $nethack_data := $.Site.Data.nethack.logfile }}
{{ $logfile := slice }}
{{ range $nethack_data }}
{{ $logfile = $logfile | append .logfile }}
{{ end }}
<ol class="logfile">
<li>
{{ partial "nethack/logentry.html" (index (sort $logfile "score" "desc") 0) }}
</li>
</ol>

View file

@ -0,0 +1,10 @@
{{- $logfile := partial "nethack/log.html" . -}}
<ol class="logfile">
{{ range sort $logfile "end_date" "desc" }}
{{ if ne .death.cause "quit" }}
<li>
{{ partial "nethack/logentry.html" .}}
</li>
{{ end }}
{{ end }}
</ol>

View file

@ -0,0 +1,2 @@
{{- $numberOfEntries := (partial "nethack/log.html" .) | len -}}
{{- $numberOfEntries | lang.FormatNumber 0 -}}

View file

@ -0,0 +1,7 @@
{{- $n := .Get 0 -}}
{{- $logfile := partial "nethack/log.html" . -}}
<ol class="logfile topn">
{{ range first $n (sort $logfile "score" "desc") -}}
<li>{{ partial "nethack/logentry.html" . }}</li>
{{- end }}
</ol>

View file

@ -0,0 +1,9 @@
{{- with $photoPage := $.Page.GetPage (printf "photos/%s" (.Get 0)) -}}
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
{{- $altText := $thumbnail.Params.alt | default .Title -}}
<a class="to-photo-post" href="{{ .RelPermalink }}" title="{{ .Title }}">
<img src="{{ $thumbnail.RelPermalink }}"{{ with $altText }} alt="{{ . }}"{{ end }}>
</a>
{{- else -}}
{{- errorf "No page matching '%s'" (.Get 0) -}}
{{- end -}}

View file

@ -0,0 +1,3 @@
{{- $subreddit := .Get 0 -}}
<a class="hover-only" href="https://reddit.com/r/{{ $subreddit }}"><code class="nobg">r/{{ $subreddit }}</code></a>
{{- "" -}}

View file

@ -0,0 +1,27 @@
<ul>
{{ $pages := union .Site.RegularPages .Site.Sections }}
{{ if .Page.IsHome }}
{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ end }}
{{ $paginator := .Page.Paginate $pages }}
{{ range $index, $page := $paginator.Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date | time.Format ":date_medium" }}</time>
{{ if $page.Draft }}
<span class="draft">draft</span>
{{ end }}
</li>
{{ end }}
</ul>
{{ if gt $paginator.TotalPages 1 }}
<nav class="main-nav">
{{ if $paginator.HasPrev }}
<a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
{{ end }}
{{ if $paginator.HasNext }}
<a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a>
{{ end }}
</nav>
{{ end }}

View file

@ -0,0 +1,18 @@
<header class="flex-date">
{{ .Inner }}
<span class="date">
{{ if .IsNamedParams }}
{{ with .Get "from" }}
<time datetime="{{ . }} ">{{ . }}</time>
{{ end }}
to
{{ with .Get "to" }}
<time datetime="{{ . }}">{{ . }}</time>
{{ else }}
present
{{ end }}
{{ else }}
{{ .Get 0 }}
{{ end }}
</span>
</header>

View file

@ -0,0 +1,14 @@
<header class="flex-date">
<h3>{{ .Get "company" }}: {{ .Get "team" }}</h3>
<span class="date">
{{ with .Get "from" }}
<time datetime="{{ . }} ">{{ . }}</time>
{{ end }}
{{ with .Get "to" }}
<time datetime="{{ . }}">{{ . }}</time>
{{ else }}
present
{{ end }}
</span>
</header>

View file

@ -0,0 +1 @@
<ruby {{ with .Get 1 }}lang="{{ . }}"{{ end }}><span>{{- .Inner }}</span> <rp>(</rp><rt {{ with .Get 2 }}lang="{{ . }}"{{ end }}>{{- .Get 0 -}}</rt><rp>)</rp></ruby>{{- "" -}}

View file

@ -0,0 +1,3 @@
<section {{ with .Get "class" }}class="{{ . }}"{{ end }}>
{{ .Inner }}
</section>