From e42fa46d477e2bb1d6c2102f4510c1d3ae894009 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 16 Dec 2023 05:40:59 -0600 Subject: [PATCH] some bits that might be important --- layouts/_default/index.rss.xml | 47 ++++++++++++ layouts/partials/article-meta/basic.html | 93 ++++++++++++++++++++++++ layouts/partials/author-extra.html | 34 +++++++++ layouts/partials/functions/warnings.html | 6 ++ 4 files changed, 180 insertions(+) create mode 100644 layouts/_default/index.rss.xml create mode 100644 layouts/partials/article-meta/basic.html create mode 100644 layouts/partials/author-extra.html create mode 100644 layouts/partials/functions/warnings.html diff --git a/layouts/_default/index.rss.xml b/layouts/_default/index.rss.xml new file mode 100644 index 0000000..7e84c40 --- /dev/null +++ b/layouts/_default/index.rss.xml @@ -0,0 +1,47 @@ +{{- $pctx := . -}} +{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- $pages := slice -}} +{{- if or $.IsHome $.IsSection -}} +{{- $pages = $pctx.RegularPages -}} +{{- else -}} +{{- $pages = $pctx.Pages -}} +{{- end -}} +{{- $limit := .Site.Config.Services.RSS.Limit -}} +{{- if ge $limit 1 -}} +{{- $pages = $pages | first $limit -}} +{{- end -}} +{{- printf "" | safeHTML }} + + + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + Recent newsletters {{ if ne .Title .Site.Title }}{{ with .Title }}of {{.}} {{ end }}{{ end }}at {{ .Site.Title }} + Hugo -- gohugo.io{{ with .Site.LanguageCode }} + {{.}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} + {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} + {{.}}{{end}}{{ if not .Date.IsZero }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "RSS" -}} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end -}} + {{ range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + {{ .Content | safeHTML }} + {{ range ( where .Site.RegularPages ".RelPermalink" .RelPermalink | first 1 ) }} + {{- $images := .Resources.ByType "image" -}} + {{- $featured := $images.GetMatch "*feature*" -}} + {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} + {{- with $featured -}} + + {{- end -}} + {{ end }} + + {{ end }} + + diff --git a/layouts/partials/article-meta/basic.html b/layouts/partials/article-meta/basic.html new file mode 100644 index 0000000..0cd6229 --- /dev/null +++ b/layouts/partials/article-meta/basic.html @@ -0,0 +1,93 @@ +{{/* Determine the correct context and scope */}} +{{/* This allows for different logic depending on where the partial is called */}} +{{ $context := . }} +{{ $scope := default nil }} + +{{ if (reflect.IsMap . ) }} +{{ $context = .context }} +{{ $scope = cond (not .scope) nil .scope }} +{{ end }} + +{{ with $context }} +{{ $meta := newScratch }} + +{{/* Gather partials for this context */}} +{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }} +{{ $meta.Add "partials" (slice (partial "meta/date.html" .Date)) }} +{{ end }} + +{{ if and (.Params.showDateUpdated | default (.Site.Params.article.showDateUpdated | default false)) (ne (partial +"functions/date.html" .Date) (partial "functions/date.html" .Lastmod)) }} +{{ $meta.Add "partials" (slice (partial "meta/date-updated.html" .Lastmod)) }} +{{ end }} + +{{ if and (.Params.showWordCount | default (.Site.Params.article.showWordCount | default false)) (ne .WordCount 0) }} +{{ $meta.Add "partials" (slice (partial "meta/word-count.html" .)) }} +{{ end }} + +{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) +}} +{{ $meta.Add "partials" (slice (partial "meta/reading-time.html" .)) }} +{{ end }} + +{{ if and (not .Params.externalURL) (.Params.showViews | default (.Site.Params.article.showViews | default false)) }} +{{ $meta.Add "partials" (slice (partial "meta/views.html" .)) }} +{{ end }} + +{{ if and (not .Params.externalURL) (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }} +{{ $meta.Add "partials" (slice (partial "meta/likes.html" .)) }} +{{ end }} + +{{ if and (eq $scope "single") (not .Params.externalURL) (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }} +{{ $meta.Add "partials" (slice (partial "meta/likes_button.html" .)) }} +{{ end }} + +{{ if and (eq $scope "single") (.Params.showEdit | default (.Site.Params.article.showEdit | default false)) }} +{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }} +{{ end }} + + +
+ {{/* Output partials */}} + {{ with ($meta.Get "partials") }} + {{ delimit . "·" }} + {{ end }} + + {{/* Output draft label */}} + {{ if and (eq $scope "single") (and .Draft .Site.Params.article.showDraftLabel) }} + {{ partial "badge.html" (i18n "article.draft" | emojify) }} + {{ end }} +
+ +{{ if .Params.showAuthorsBadges | default (.Site.Params.article.showAuthorsBadges | default false) }} +
+ {{ range $taxonomy, $terms := .Site.Taxonomies }} + {{ if (eq $taxonomy "authors")}} + {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} + {{ range $i, $a := $context.GetTerms $taxonomy }} + {{ if not (eq $i 0) }} ,  {{ end }}
{{ $a.LinkTitle }}
+ {{ end }} + {{ end }} + {{ end }} + {{ end }} +
+{{ end }} + +{{/* Output taxonomies */}} +{{ if .Params.showTaxonomies | default (.Site.Params.article.showTaxonomies | default false) }} +
+ {{ range $taxonomy, $terms := .Site.Taxonomies }} + {{ if and (not (eq $taxonomy "authors")) (not (eq $taxonomy "series"))}} + {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} + {{ range $context.GetTerms $taxonomy }} + + {{ partial "badge.html" .LinkTitle }} + + {{ end }} + {{ end }} + {{ end }} + {{ end }} +
+{{ end }} + +{{ end }} diff --git a/layouts/partials/author-extra.html b/layouts/partials/author-extra.html new file mode 100644 index 0000000..8f8cf04 --- /dev/null +++ b/layouts/partials/author-extra.html @@ -0,0 +1,34 @@ +
+ {{ with .data.image }} + {{ $authorImage := resources.Get . }} + {{ if $authorImage }} + {{ $authorImage := $authorImage.Fill "192x192" }} + + {{ end }} + {{ end }} +
+ {{ $link := .link}} + {{ with .data.name | markdownify | emojify }} +
+ {{ i18n "author.byline_title" | markdownify | emojify }} +
+ + {{ . }} + + {{ end }} + {{ with .data.bio | markdownify | emojify }} +
{{ . }}
+ {{ end }} +
+
+ {{ range .data.social }} + {{ range $name, $link := . }} + {{ partial "icon.html" $name }} + {{ end }} + {{ end }} +
+
+
+
diff --git a/layouts/partials/functions/warnings.html b/layouts/partials/functions/warnings.html new file mode 100644 index 0000000..7f7fc01 --- /dev/null +++ b/layouts/partials/functions/warnings.html @@ -0,0 +1,6 @@ +