Fix: RSS feeds

This commit is contained in:
hyzen
2026-03-03 01:43:34 +05:30
parent 4ff58e1b6b
commit e9bd7e3074
36 changed files with 301 additions and 36 deletions

View File

@@ -0,0 +1,32 @@
<!doctype html>
<html
class="html"
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
dir="{{ or site.Language.LanguageDirection `ltr` }}"
>
<head>
{{ partial "head.html" . }}
</head>
<body class="body">
<header class="header">
<div class="brand">
<img src="/logo.png" alt="Freedoms4 logo" />
<h1>Freedoms4</h1>
{{- $rssURL := "/index.xml" -}}
{{- with .OutputFormats.Get "rss" -}}
{{- $rssURL = .RelPermalink -}}
{{- end -}}
<a href="{{ $rssURL }}" class="rss-subscribe__link" title="Subscribe via RSS">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="10" height="10" fill="currentColor" aria-hidden="true">
<path d="M6.18 15.64a2.18 2.18 0 0 1 2.18 2.18C8.36 19.01 7.38 20 6.18 20C4.98 20 4 19.01 4 17.82a2.18 2.18 0 0 1 2.18-2.18M4 4.44A15.56 15.56 0 0 1 19.56 20h-2.83A12.73 12.73 0 0 0 4 7.27V4.44m0 5.66a9.9 9.9 0 0 1 9.9 9.9h-2.83A7.07 7.07 0 0 0 4 12.93V10.1z"/>
</svg>
<span>Subscribe</span>
</a>
</div>
{{ partial "header.html" . }}
</header>
<main class="main">{{ block "main" . }}{{ end }}</main>
<footer class="footer">{{ partial "footer.html" . }}</footer>
{{ partial "body/body-end.html" . }}
</body>
</html>

View File

@@ -0,0 +1 @@
<p class="footer__copyright-notice">&copy; 2026 <a href="https://freedoms4.org">freedoms4.org</a></p>

View File

@@ -0,0 +1 @@
{{- /* RSS link moved to header */ -}}

View File

@@ -0,0 +1,6 @@
<nav class="menu language">
<ul class="menu__list language__list">
{{- partial "header/menu.html" (dict "menuID" "main" "page" .) -}} {{- partial
"header/language_selector.html" . -}}
</ul>
</nav>

32
layouts/baseof.html Normal file
View File

@@ -0,0 +1,32 @@
<!doctype html>
<html
class="html"
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
dir="{{ or site.Language.LanguageDirection `ltr` }}"
>
<head>
{{ partial "head.html" . }}
</head>
<body class="body">
<header class="header">
<div class="brand">
<img src="/logo.png" alt="Freedoms4 logo" />
<h1>Freedoms4</h1>
{{- $rssURL := "/index.xml" -}}
{{- with .OutputFormats.Get "rss" -}}
{{- $rssURL = .RelPermalink -}}
{{- end -}}
<a href="{{ $rssURL }}" class="rss-subscribe__link" title="Subscribe via RSS">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="10" height="10" fill="currentColor" aria-hidden="true">
<path d="M6.18 15.64a2.18 2.18 0 0 1 2.18 2.18C8.36 19.01 7.38 20 6.18 20C4.98 20 4 19.01 4 17.82a2.18 2.18 0 0 1 2.18-2.18M4 4.44A15.56 15.56 0 0 1 19.56 20h-2.83A12.73 12.73 0 0 0 4 7.27V4.44m0 5.66a9.9 9.9 0 0 1 9.9 9.9h-2.83A7.07 7.07 0 0 0 4 12.93V10.1z"/>
</svg>
<span>Subscribe</span>
</a>
</div>
{{ partial "header.html" . }}
</header>
<main class="main">{{ block "main" . }}{{ end }}</main>
<footer class="footer">{{ partial "footer.html" . }}</footer>
{{ partial "body/body-end.html" . }}
</body>
</html>

75
layouts/rss.xml Normal file
View File

@@ -0,0 +1,75 @@
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .email }}
{{- $authorEmail = . }}
{{- end }}
{{- end }}
{{- else }}
{{- with site.Author.email }}
{{- $authorEmail = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
{{- end }}
{{- end }}
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
{{- $authorName := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- with site.Author.name }}
{{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
{{- $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>{{ if .IsHome }}{{ .Site.Title }}{{ else if eq .Title "Blogs" }}Blog on {{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>{{ if .IsHome }}Recent updates on {{ .Site.Title }}{{ else if eq .Title "Blogs" }}Recent blog posts on {{ .Site.Title }}{{ else }}Recent content in {{ .Title }} on {{ .Site.Title }}{{ end }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.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 }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
{{ if site.Params.rssFullContent -}}
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
{{- else -}}
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
{{- end }}
</item>
{{- end }}
</channel>
</rss>

View File

@@ -0,0 +1,28 @@
<!doctype html>
<html
class="html"
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
dir="{{ or site.Language.LanguageDirection `ltr` }}"
>
<head>
{{ partial "head.html" . }}
</head>
<body class="body">
<header class="header">
<div class="brand">
<img src="/logo.png" alt="Freedoms4 logo" />
<h1>Freedoms4</h1>
<a href="/index.xml" class="rss-subscribe__link" title="Subscribe via RSS">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="10" height="10" fill="currentColor" aria-hidden="true">
<path d="M6.18 15.64a2.18 2.18 0 0 1 2.18 2.18C8.36 19.01 7.38 20 6.18 20C4.98 20 4 19.01 4 17.82a2.18 2.18 0 0 1 2.18-2.18M4 4.44A15.56 15.56 0 0 1 19.56 20h-2.83A12.73 12.73 0 0 0 4 7.27V4.44m0 5.66a9.9 9.9 0 0 1 9.9 9.9h-2.83A7.07 7.07 0 0 0 4 12.93V10.1z"/>
</svg>
<span>Subscribe</span>
</a>
</div>
{{ partial "header.html" . }}
</header>
<main class="main">{{ block "main" . }}{{ end }}</main>
<footer class="footer">{{ partial "footer.html" . }}</footer>
{{ partial "body/body-end.html" . }}
</body>
</html>