rss support RSSNEXT/Follow claim

This commit is contained in:
Weaxs 2024-10-28 22:32:49 +08:00
parent c2db79ee4b
commit 948467b6a7
3 changed files with 32 additions and 18 deletions

View file

@ -159,3 +159,7 @@ forgejoDefaultServer = "https://v8.next.forgejo.org"
# bing = "" # bing = ""
# pinterest = "" # pinterest = ""
# yandex = "" # yandex = ""
[RSSNext]
# feedId = ""
# userId = ""

View file

@ -155,3 +155,7 @@ smartTOCHideUnfocusedChildren = false
# bing = "" # bing = ""
# pinterest = "" # pinterest = ""
# yandex = "" # yandex = ""
[RSSNext]
# feedId = ""
# userId = ""

View file

@ -1,16 +1,16 @@
{{- $pctx := . -}} {{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}} {{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}} {{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}} {{- $pages = $pctx.RegularPages -}}
{{- else -}} {{- else -}}
{{- $pages = $pctx.Pages -}} {{- $pages = $pctx.Pages -}}
{{- end -}} {{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}} {{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}} {{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}} {{- $pages = $pages | first $limit -}}
{{- end -}} {{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
@ -27,6 +27,12 @@
{{- with .OutputFormats.Get "RSS" -}} {{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ if and (.Site.Params.RSSNext.feedId) (.Site.Params.RSSNext.userId) }}
<follow_challenge>
<feedId>{{ .Site.Params.RSSNext.feedId }}</feedId>
<userId>{{ .Site.Params.RSSNext.userId }}</userId>
</follow_challenge>
{{ end }}
{{ range $pages }} {{ range $pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>