diff options
| author | Drew DeVault <sir@cmpwn.com> | 2023-06-22 09:41:23 +0200 |
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2023-06-22 09:41:23 +0200 |
| commit | 754d955e7c035574629d726b93de3df982e4022d (patch) | |
| tree | 69d40d503f5ffe4e82baa42b4c4a1361107801f1 | |
| parent | a3af7fbdeaf59da4630674639217f63d42a77411 (diff) | |
| download | writefreesoftware.org-754d955e7c035574629d726b93de3df982e4022d.tar.xz | |
Set up RSS feed properly
| -rw-r--r-- | config.toml | 3 | ||||
| -rw-r--r-- | layouts/blog/list.html | 44 | ||||
| -rw-r--r-- | layouts/blog/rss.xml | 41 | ||||
| -rw-r--r-- | layouts/blog/single.html | 1 | ||||
| -rw-r--r-- | layouts/partials/head.html | 3 |
5 files changed, 90 insertions, 2 deletions
diff --git a/config.toml b/config.toml index cfc2bd1..82bbefd 100644 --- a/config.toml +++ b/config.toml @@ -2,9 +2,10 @@ baseURL = 'https://writefreesoftware.org' languageCode = 'en-US' title = 'Write Free Software' theme = ["github.com/onweru/compose"] +rssLimit = 10 [outputs] - home = ["HTML", "RSS","JSON"] + home = ["HTML", "RSS", "JSON"] [languages] [languages.en] diff --git a/layouts/blog/list.html b/layouts/blog/list.html new file mode 100644 index 0000000..d1b8f3b --- /dev/null +++ b/layouts/blog/list.html @@ -0,0 +1,44 @@ +{{ define "main" }} +{{- $pages := where site.RegularPages "Section" site.Params.blogDir }} +<div class="wrap pt-2 mt-2"> + {{- $paginator := .Paginate $pages -}} + {{- $size := $paginator.PageSize }} + {{- $scratch := newScratch }} + {{- range $index, $value := $paginator.Pages }} + {{ if isset .Params "image" }} + {{ $scratch.Set "image" .Params.image }} + {{ else }} + {{ $scratch.Set "image" "thumbnail.svg" }} + {{ end }} + {{ $image := $scratch.Get "image" }} + {{ $bg := (absURL (printf "images/%s" $image)) }} + {{- if in $image "https://" }} + {{- $bg = $image }} + {{- end }} + <article class = 'article mb-2'> + <a href = '{{ $value.Permalink }}' {{ if eq $index 0 }} class = 'grid-reverse' {{ end }}> + <div class = 'article_thumb' style='background-image: url({{ $bg }})'></div> + <div class = 'article_meta {{ if eq $index 0 }} center_y {{ end }}'> + <time class = 'post_date'>{{ dateFormat "January 02, 2006" $value.Date }}</time> + <h3 class = 'article_title'>{{ $value.Title }}</h3> + <div class = 'article_excerpt {{ if eq $index 0 }} visible {{ end }}'> + <p>{{ $value.Summary | truncate 100 }}</p> + </div> + </div> + </a> + </article> + {{- if and (eq $index 0) (gt $size 1) }}<div class = 'grid-2 article_showcase'>{{ end }} + {{- if and (eq $index (add $size -1)) (gt $size 1) }}</div>{{ end }} + {{- end }} +</div> +<p> + <a href="/blog/index.xml">RSS feed ยป</a> +</p> +<!-- <a href = '{{ absURL (printf "post/%s" "") }}' class = 'post_nav'> + <span class = 'post_next'>View Archive + <svg class="icon icon_scale"> + <use xlink:href="#double-arrow"></use> + </svg> + </span> +</a> --> +{{ end }} diff --git a/layouts/blog/rss.xml b/layouts/blog/rss.xml new file mode 100644 index 0000000..a917e33 --- /dev/null +++ b/layouts/blog/rss.xml @@ -0,0 +1,41 @@ +{{- $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 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>Drew DeVault's blog</title> + <link>https://drewdevault.com</link> + <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description> + <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} + <language>{{.}}</language>{{end}}{{ with .Site.Author.email }} + <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} + <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} + <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} + <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} + {{ with .OutputFormats.Get "RSS" }} + {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} + {{ end }} + {{ range $pages }} + {{- if .OutputFormats.Get "HTML" -}} + <item> + <title>{{ .Title }}</title> + <link>{{ .Permalink }}</link> + <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} + <guid>{{ .Permalink }}</guid> + <description>{{- .Content | html -}}</description> + </item> + {{- end -}} + {{ end }} + </channel> +</rss> diff --git a/layouts/blog/single.html b/layouts/blog/single.html index a81ad10..d8901ef 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -19,7 +19,6 @@ {{ partialCached "share" . }} </div> <div> - {{ template "_internal/disqus.html" . }} </div> </div> </div> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 960fb39..02cf31a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -6,6 +6,9 @@ <link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" title="{{ .Language.LanguageName }}"> {{ end }} {{ end }} +{{ range .AlternativeOutputFormats -}} +{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} +{{ end -}} {{- hugo.Generator }} {{- $t := .Title }} {{- $s := site.Title }} |
