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 = ""
# pinterest = ""
# yandex = ""
[RSSNext]
# feedId = ""
# userId = ""

View file

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

View file

@ -1,16 +1,16 @@
{{- $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 }}
{{- 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 eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
@ -27,6 +27,12 @@
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- 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 }}
<item>
<title>{{ .Title }}</title>