feat: ATOM feed, subscribe page, remove forum comment link

- Email subscription needs to be fixed
pull/29/head
earnest ma 7 days ago
parent 04b6ff7553
commit 5a58568c8f
Signed by: earnest ma
GPG Key ID: A343F43342EB6E2A

@ -10,7 +10,6 @@ author = "earnest ma"
description = "earnest ma (earne)'s personal website and blog"
favicon = "/favicon.ico"
gitRepoURL = "https://git.earne.link/earnestma/site"
forumURL = "https://discuss.earne.link"
[permalinks]
blog = "/:year/:month/:day/:slug"
@ -53,3 +52,24 @@ blog = "/:year/:month/:day/:slug"
[markup.goldmark.renderer]
unsafe = true
# https://github.com/kaushalmodi/hugo-atom-feed
[mediaTypes."application/atom+xml"]
suffixes = ["xml"]
[outputFormats.Atom]
# https://validator.w3.org/feed/docs/atom.html#whatIsAtom
name = "Atom"
mediaType = "application/atom+xml"
baseName = "atom" # generated file = <baseName>.<mediaType."application/atom+xml".suffixes[0]> = atom.xml
isPlainText = false
rel = "alternate"
isHTML = false
noUgly = true
permalinkable = false
[outputs]
# <domain>/atom.xml
home = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
# <domain>/posts/atom.xml
section = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
# <domain>/tags/mytag/atom.xml, <domain>/categories/mycat/atom.xml
term = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"

@ -18,4 +18,3 @@ aliases = [
<h3 id="latest-posts"><a href="/blog">Latest Posts</a></h3>
{{< partial "recentposts.html" >}}

@ -4,5 +4,6 @@ description = "Some more links to pages on my site."
+++
- [Recipes](/recipes)
- [Subscribe](/subscribe)
- [Support Me](/support)
- [Threads on Mastodon](/threads)

@ -0,0 +1,26 @@
+++
title = "Subscribe"
+++
You can follow my blog through Atom/ RSS, Email, Telegram, and Mastodon.
## Feeds
- [Atom feed](/blog/atom.xml)
- [RSS](/blog/index.xml)
*You can also follow a specific category by appending `index.xml` or `atom.xml` to that category's URL.*
## Email
*Emails are sent about once a month instead of per-post. Of course, I won't send you spam, and you can unsubscribe at any time.*
{{< partial "email.html" >}}
## Telegram
{{< button "https://t.me/+7xEfm5uUdQg0NDNh" "Subscribe via Telegram" >}}
## Mastodon
I also announce new blog posts on [my Mastodon account](https://tech.lgbt/@earnestma), and you can discuss posts there as well.

@ -0,0 +1,122 @@
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
<feed xmlns="http://www.w3.org/2005/Atom"{{ with site.LanguageCode }} xml:lang="{{ . }}"{{ end }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- $title := site.Title -}}
{{- with .Title -}}
{{- if (not (eq . site.Title)) -}}
{{- $title = printf `%s %s %s` . (i18n "feed_title_on" | default "on") site.Title -}}
{{- end -}}
{{- end -}}
{{- if .IsTranslated -}}
{{ $title = printf "%s (%s)" $title (index site.Data.i18n.languages .Lang) }}
{{- end -}}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with (or (.Param "subtitle") (.Param "tagline")) }}
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
{{ end }}
{{ $output_formats := .OutputFormats }}
{{ range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{ with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
{{- range .Translations }}
{{ $output_formats := .OutputFormats }}
{{- $lang := .Lang }}
{{- $langstr := index site.Data.i18n.languages .Lang }}
{{ range $output_formats -}}
{{ with $output_formats.Get .Name }}
{{ printf `<link href=%q rel="alternate" type=%q hreflang=%q title="[%s] %s" />` .Permalink .MediaType.Type $lang $langstr .Name | safeHTML }}
{{- end -}}
{{- end }}
{{- end }}
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ with site.Copyright }}
{{- $copyright := replace . "{year}" now.Year -}} {{/* In case the site.copyright uses a special string "{year}" */}}
{{- $copyright = replace $copyright "&copy;" "©" -}}
<rights>{{ $copyright | plainify }}</rights>
{{- end }}
{{ with .Param "feed" }}
{{/* For this to work, the $icon file should be present in the assets/ directory */}}
{{- $icon := .icon | default "icon.svg" -}}
{{- with resources.Get $icon -}}
<icon>{{ (. | fingerprint).Permalink }}</icon>
{{- end }}
{{/* For this to work, the $logo file should be present in the assets/ directory */}}
{{- $logo := .logo | default "logo.svg" -}}
{{- with resources.Get $logo -}}
<logo>{{ (. | fingerprint).Permalink }}</logo>
{{- end }}
{{ end }}
{{ with site.Author.name -}}
<author>
<name>{{ . }}</name>
{{ with site.Author.email }}
<email>{{ . }}</email>
{{ end -}}
</author>
{{- end }}
{{ with site.Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{- $limit := (cond (le site.Config.Services.RSS.Limit 0) 65536 site.Config.Services.RSS.Limit) }}
{{- $feed_sections := site.Params.feedSections | default site.Params.mainSections -}}
{{/* Range through only the pages with a Type in $feed_sections. */}}
{{- $pages := where .RegularPages "Type" "in" $feed_sections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where site.RegularPages "Type" "in" $feed_sections -}}
{{- end -}}
{{/* Remove the pages that have the disable_feed parameter set to true. */}}
{{- $pages = where $pages ".Params.disable_feed" "!=" true -}}
{{/* Remove the pages that have the unlisted parameter set to true. */}}
{{- $pages = where $pages ".Params.unlisted" "!=" true -}}
{{- range first $limit $pages }}
{{ $page := . }}
<entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" />
{{- range .Translations }}
{{- $link := printf "%s?utm_source=atom_feed" .Permalink | safeHTML }}
{{- printf `<link href=%q rel="alternate" type="text/html" hreflang=%q />` $link .Lang | safeHTML }}
{{- end }}
{{/* rel=related: See https://validator.w3.org/feed/docs/atom.html#link */}}
{{- range first 5 (site.RegularPages.Related .) }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
{{- end }}
{{ with .Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{ with .Params.author -}}
{{- range . -}} <!-- Assuming the author front-matter to be a list -->
<author>
<name>{{ . }}</name>
</author>
{{- end -}}
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ $description1 := .Description | default "" }}
{{ $description := (cond (eq "" $description1) "" (printf "<blockquote>%s</blockquote>" ($description1 | markdownify))) }}
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
{{ with site.Taxonomies }}
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
{{ with $page.Param $taxo }}
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
{{ with site.GetPage (printf "/%s" $taxo) }}
{{ $taxonomy_page := . }}
{{ range $taxo_list }} <!-- Below, assuming pretty URLs -->
<category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</entry>
{{ end }}
</feed>

@ -1,31 +1,14 @@
{{ define "main" }}
<!-- if .Data.Singular -->
<h1>{{ .Title }}</h2>
{{ .Content }}
<ul>
{{ range .Pages }}
<li><i>
{{ if .Params.link }}
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>{{ .Date.Format "Jan 02, 2006" }}</time></i>
<a href="{{ .Permalink }}">{{ .Title }}</a>: <small><a href="{{ .Params.link }}">🔗Link</a></small>
{{ else }}
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>{{ .Date.Format "Jan 02, 2006" }}</time></i>
<a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
</li>
{{ end }}
</ul>
{{ if .Data.Singular }}
{{else}}
{{ if eq .RelPermalink "/blog/" -}}
<small>
<div>
Categories:
{{ range .Site.Taxonomies.categories }}
<a href="{{ .Page.Permalink }}">#{{ .Page.Title }}</a>&nbsp;
{{ end }}
</div>
</small>
{{ end -}}
{{ range .Pages }}
<li><i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>{{ .Date.Format "Jan 02, 2006" }}</time></i>
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}

@ -0,0 +1,28 @@
{{ define "main" }}
<!-- if .Data.Singular -->
<h1>{{ .Title }}</h2>
{{ .Content }}
<div>
Categories:
{{ range .Site.Taxonomies.categories }}
<a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a>&nbsp;
{{ end }}
</div>
<a href="/subscribe"><button>Subscribe</button></a>
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{- range $pages.GroupByPublishDate "2006" }}
<h2>{{- .Key }}</h2>
<ul>
{{ range .Pages }}
<li><i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>{{ .Date.Format "Jan 02" }}</time></i>
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{- end}}
{{ end }}

@ -8,10 +8,9 @@
<ul>
<li>Published on {{ .Date.Format "Jan 02, 2006" }}
{{ if .Lastmod }}{{ if not (eq .Lastmod .Date )}}
<i>(updated {{ dateFormat "2006-01-02" .Lastmod.Local }})</i>
<i>(updated {{ dateFormat "2006-01-02" .Lastmod.Local }})</i>
{{ end }}{{ end }}</li>
<li><a href="{{ .Site.Params.gitRepoURL }}/src/branch/main/content/{{ .File.Path }}">View</a> history or download markdown</li>
<li>Categories: {{ range (.GetTerms "categories") }}<a href="{{ .Permalink }}">#{{ .LinkTitle }}</a> {{ end }}</li>
<li>Categories: {{ range (.GetTerms "categories") }}<a href="{{ .Permalink }}">{{ .LinkTitle }}</a> {{ end }}</li>
</ul>
{{ with .Params.frontImage }}
@ -24,9 +23,19 @@
</content>
<br><hr>
<div align="center">
<p>If you enjoyed reading this post, please consider <a href="/support">supporting me</a> 💜</p>
{{ partial "comment.html" . }}
<div style="padding: 10px; border: 2px solid gray;">
<h4>Subscribe</h4>
{{ partial "email.html" . }}
<small>Emails are sent about once a month instead of per post. Of course, I won't send you
spam, and you can unsubscribe at any time. Otherwise, you can also subscribe via
<a href="/subscribe#feeds">Atom or RSS</a>, <a href="https://t.me/+7xEfm5uUdQg0NDNh">Telegram</a>,
or <a href="https://tech.lgbt/@earnestma">Mastodon</a>.</small>
</div>
<div align="center">
<p style="padding: 10px; border: 2px solid purple;">If you enjoyed reading this post, please consider <a href="/support">supporting me</a> 💜</p>
{{ with .PrevInSection }}<a href="{{ .Permalink }}"><button>Previous post</button></a>{{ end }}
{{ with .NextInSection }}<a href="{{ .Permalink }}"><button>Next post</button></a>{{ end }}

@ -1,5 +0,0 @@
{{ if and .Site.Params.forumURL .Params.forum_id }}
<div id="comment-section">
<p><a href="{{ .Site.Params.forumURL }}/d/{{ .Params.forum_id }}" target="_blank"><button>View the earne.link Discussion!</button></a></p>
</div>
{{ end }}

@ -0,0 +1,12 @@
<form method="post" action="https://ml.earne.link/subscription/form" class="listmonk-form">
<div>
<input type="hidden" name="nonce" />
<p><input type="email" name="email" required placeholder="E-mail" /></p>
<input style="display: none;" id="345ca" type="checkbox" name="l" checked value="345ca683-0f28-4b01-8111-3b16c8840b6f" />
<div class="captcha">
<div class="h-captcha" data-sitekey="8f907217-42dc-439c-8c7e-f07028cf1486"></div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
</div>
<p><input type="submit" value="Subscribe via Email" /></p>
</div>
</form>

@ -1,5 +1,5 @@
<ul>
<li>Copyright {{ .Site.Params.copyrightYear }} {{ .Site.Params.author }}</li>
<li>Copyright {{ .Site.Params.copyrightYear }}, {{ .Site.Params.author }}</li>
<li><i>Any and all opinions expressed here are my own, unless otherwise stated.</i></li>
{{ if .GitInfo }}<li>Last built on {{ now.Format "2006-01-02 15:04:05 -0700" }}: {{ .GitInfo.AbbreviatedHash }}, <a href="{{ .Site.Params.gitRepoURL }}">source code here</a></li>{{ end }}
</ul>

@ -1,7 +1,7 @@
<ul>
{{- range first 10 (where site.RegularPages "Type" "in" site.Params.mainSections) }}
<li>
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time>
<i><time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "Jan 02, 2006" }}</time></i>
{{ printf "--" | markdownify }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>

Loading…
Cancel
Save