Add likes pages

This commit is contained in:
JP Hastings-Spital 2024-05-13 08:12:50 +01:00
parent a5f9b30656
commit 2af4f0e0c7
5 changed files with 113 additions and 2 deletions

6
content/likes/_index.md Normal file
View file

@ -0,0 +1,6 @@
---
title: Likes
emoji: 💙
---
All the sites I've 'liked' since I started recording these via micropub in May 2024.

View file

@ -33,8 +33,8 @@ export default {
"like": {
"name": "Like",
"post": {
"path": "content/notes/{yyyy}-{MM}-{dd}/{slug}/index.md",
"url": "notes/{yyyy}-{MM}-{dd}/{slug}/"
"path": "content/likes/{yyyy}-{MM}-{dd}/{slug}/index.md",
"url": "likes/{yyyy}-{MM}-{dd}/{slug}/"
}
},
"note": {

30
layouts/likes/list.html Normal file
View file

@ -0,0 +1,30 @@
{{ define "main" }}
{{ $paginator := .Paginate .Pages }}
<main class="posts" {{ if eq .Kind "taxonomy" }}data-pagefind-ignore{{ end }}>
{{ partial "generic-list-header.html" . }}
<hgroup class="post-title">
<h1 class="p-name">
{{ with .Params.emoji }}<span data-emoji="{{.}}"></span>{{end}}
<a href="{{ .RelPermalink }}" class="noaccent u-url">{{ title (replace .Title "-" " ") }}</a>
</h1>
{{ partial "alternates.html" . }}
</hgroup>
{{ if .Content }}
<div class="content" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">{{ .Content }}</div>
{{ end }}
{{ range $paginator.Pages.GroupByDate "Jan 2006" }}
<div class="posts-group">
<div class="post-year">{{ .Key }}</div>
{{ range $i, $page := .Pages }}
<a href="{{$page.Params.likeOf}}" target="_blank">{{ partial "page-title.txt" $page }}</a>{{ if lt $i (sub (len .Pages) 1) }}, {{ end }}
{{ end }}
</div>
{{ end }}
{{ partial "pagination-list.html" . }}
</main>
{{ end }}

68
layouts/likes/single.html Normal file
View file

@ -0,0 +1,68 @@
{{ define "main" }}
<main class="post h-entry" data-pagefind-ignore="all">
{{- $ref := partial "reference.obj" (dict "url" .Params.likeOf "references" .Params.references) -}}
<div class="post-info">
<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">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Liked on {{ partial "year-relative-date.html" .Date }}
</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-compass">
<circle cx="12" cy="12" r="10"></circle>
<polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"></polygon>
</svg>
Back to <a href="{{ .Page.Parent.RelPermalink }}">{{ .Page.Parent.Title }}</a>
</p>
<p class="author h-card hidden" aria-hidden="true">
<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"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
<a href="{{ .Site.BaseURL | absURL }}" rel="author" class="p-author u-url">{{ .Site.Author.name }}</a>
</p>
</div>
<article>
<hgroup class="post-title">
<h1 class="p-name">
<a href="{{ $ref.url }}" class="noaccent u-url">{{ $ref.name }}</a>
</h1>
</hgroup>
<div class="post-content e-content">
<p class="reference-to">
{{ partial "reference-to.html" (dict "url" .Params.likeOf "references" .Params.references "svg" "heart" "phrase" "Like of" "mf2" "u-like-of") }}
</p>
<p>This is a page stub recording that I liked something I found online. There's nothing interesting here — so <a href="{{ $ref.url }}" target="_blank">see what I liked</a>!</p>
</div>
</article>
<hr />
<div class="post-info">
{{ 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-calendar">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
<date datetime="{{ dateFormat "2006-01-02T15:04:05-0700" .Date }}" class="dt-published" title="published on {{ dateFormat "Monday Jan 2 2006 at 03:04 MST" .Date }}">
{{ if .Site.Params.dateformNumTime }}
{{ dateFormat .Site.Params.dateformNumTime .Date }}
{{ else }}
{{ dateFormat "2006-01-02 15:04" .Date }}
{{ end }}
</date>
</p>
{{ partial "pagination-single.html" . }}
</div>
</main>
{{ end }}

View file

@ -10,6 +10,13 @@
{{- else -}}
{{- partial "partials/fallback-title.txt" . -}}
{{- end -}}
{{- else if .Params.likeOf -}}
{{- $ref := partial "reference.obj" (dict "url" .Params.likeOf "references" .Params.references) -}}
{{- if $ref -}}
{{ $ref.name }}
{{- else -}}
{{- partial "partials/fallback-title.txt" . -}}
{{- end -}}
{{- else -}}
{{- partial "partials/fallback-title.txt" . -}}
{{- end -}}