Filter for valid link rel values

This commit is contained in:
Will Faught
2025-02-14 21:25:29 -08:00
parent ed4490254c
commit c8e008636d
2 changed files with 25 additions and 10 deletions

View File

@@ -41,19 +41,22 @@
<rss version="2.0" {{ with $language }} xml:lang="{{ . }}" {{ end }} xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
{{ range $page.OutputFormats }}
{{ $kind := not (hasSuffix .Permalink "/paige-search.json") }}
{{ $rel := cond (eq .Rel "canonical") "self" .Rel }}
{{ $suffix := hasSuffix .Permalink "/paige-search.json" }}
{{ if not $suffix }}
{{ $valid := in (slice "alternate" "enclosure" "related" "self" "via") $rel }}
{{ if and $kind $valid }}
<atom:link href="{{ .Permalink }}" hreflang="{{ .Language.LanguageCode }}" rel="{{ $rel }}" type="{{ .MediaType }}"/>
{{ end }}
{{ end }}
{{ range $t := $page.Translations }}
{{ range .OutputFormats }}
{{ $suffix := hasSuffix .Permalink "/paige-search.json" }}
{{ $kind := not (hasSuffix .Permalink "/paige-search.json") }}
{{ $valid := in (slice "alternate" "enclosure" "related" "self" "via") .Rel }}
{{ if not $suffix }}
{{ if and $kind $valid }}
<atom:link href="{{ .Permalink }}" hreflang="{{ $t.Language.LanguageCode }}" rel="{{ .Rel }}" type="{{ .MediaType }}"/>
{{ end }}
{{ end }}