Add microformats for calendar

This commit is contained in:
JP Hastings-Spital 2023-12-24 11:41:22 +00:00
parent 6c5126bff0
commit 7fa32125a7
4 changed files with 31 additions and 9 deletions

View file

@ -1,5 +1,5 @@
{{ define "main" }} {{ define "main" }}
<main class="post h-entry"> <main class="post h-event">
{{ $timing := index .Params.timings 0 -}} {{ $timing := index .Params.timings 0 -}}
{{ range .Params.timings -}} {{ range .Params.timings -}}
{{ if (time.AsTime .starts).Before time.Now -}} {{ if (time.AsTime .starts).Before time.Now -}}
@ -11,7 +11,7 @@
<hgroup class="post-title"> <hgroup class="post-title">
<h1 class="p-name"> <h1 class="p-name">
{{ with .Params.emoji }}<span data-emoji="{{.}}"></span>{{end}} {{ with .Params.emoji }}<span data-emoji="{{.}}"></span>{{end}}
<a href="{{ .Permalink }}" class="noaccent u-url">{{ .Title | markdownify }}</a> <a href="{{ .Permalink }}" class="noaccent">{{ .Title | markdownify }}</a>
</h1> </h1>
</hgroup> </hgroup>
@ -29,7 +29,7 @@
</figure> </figure>
{{ end }} {{ end }}
<div class="post-content e-content" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}"> <div class="post-content p-description" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">
{{ .Content }} {{ .Content }}
</div> </div>
</article> </article>
@ -39,6 +39,14 @@
<div class="post-info"> <div class="post-info">
{{ partial "tags.html" .Params.tags }} {{ partial "tags.html" .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-map-pin">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
<circle cx="12" cy="10" r="3"></circle>
</svg>
At <a href="{{ partial "geolink.html" .Params.location }}" class="p-location h-geo" target="_blank">{{ .Params.location.name }}</a>
</p>
<p> <p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect> <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
@ -46,7 +54,7 @@
<line x1="8" y1="2" x2="8" y2="6"></line> <line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line> <line x1="3" y1="10" x2="21" y2="10"></line>
</svg> </svg>
On {{ partial "year-relative-date.html" (time.AsTime $timing.starts) }} On {{ partial "year-relative-date.html" (slice (time.AsTime $timing.starts) "dt-start") }}
</p> </p>
<p> <p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock">
@ -54,10 +62,10 @@
<polyline points="12 6 12 12 16 14"></polyline> <polyline points="12 6 12 12 16 14"></polyline>
</svg> </svg>
{{ $starts := time.AsTime $timing.starts }} {{ $starts := time.AsTime $timing.starts }}
{{ $duration := time.ParseDuration ((strings.Substr $timing.duration 2) | strings.ToLower) }} {{ $duration := ((strings.Substr $timing.duration 2) | strings.ToLower) }}
From {{ $starts.Format "15:04" }} until {{ $starts.Add $duration | dateFormat "15:04 (MST)" }} From {{ $starts.Format "15:04" }} until {{ $starts.Add (time.ParseDuration $duration) | dateFormat "15:04 (MST)" }} (<span class="dt-duration">{{ $duration }}</span>)
</p> </p>
{{ if .Params.attending }} {{ if .Params.attending }}
<p class="attending"> <p class="attending">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user-check"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="8.5" cy="7" r="4"></circle><polyline points="17 11 19 13 23 9"></polyline></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user-check"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="8.5" cy="7" r="4"></circle><polyline points="17 11 19 13 23 9"></polyline></svg>
@ -74,6 +82,13 @@
</p> </p>
{{ end }} {{ end }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
More info on <a href="{{.Params.link}}" class="u-url" target="_blank">{{ (urls.Parse .Params.link).Host }}</a>
</p>
</div> </div>
<hr /> <hr />

View file

@ -0,0 +1 @@
http://www.openstreetmap.org/?mlat={{.latitude}}&mlon={{.longitude}}&zoom=18&layers=M

View file

@ -1 +1,4 @@
<time timestamp="{{ . }}" title="{{ time . | dateFormat "2006-01-02 03:04 MST" }}">{{ time . | dateFormat "January 2" }}{{ if ne (time . | dateFormat "2006") (now | dateFormat "2006") }}, {{ time . | dateFormat "2006" }}{{ end }}</time> {{- $date := . -}}
{{- $extraClass := slice -}}
{{ if reflect.IsSlice . -}}{{ $date = index . 0 }}{{ $extraClass = index . 1 }}{{ end -}}
<time class="{{ with $extraClass }}{{.}}{{ end }}" timestamp="{{ $date }}" title="{{ time $date | dateFormat "2006-01-02 15:04 MST" }}">{{ time $date | dateFormat "January 2" }}{{ if ne (time $date | dateFormat "2006") (now | dateFormat "2006") }}, {{ time $date | dateFormat "2006" }}{{ end }}</time>

View file

@ -1,4 +1,7 @@
Add single.html for Calendar {cm:2023-12-24} Add single.html for Calendar {cm:2023-12-24}
Support repeating calendar events Support repeating calendar events
Handle long lines {cm:2023-12-24} Handle long lines {cm:2023-12-24}
Ensure ICS files have CRLF endings {cm:2023-12-22} Ensure ICS files have CRLF endings {cm:2023-12-22}
Add microformats {cm:2023-12-24}
Add lat & long to h-event p-location
Debug why h-event doesn't seem to be showing