Simplify feed link rel logic

This commit is contained in:
Will Faught
2025-02-14 15:44:50 -08:00
parent 27b0333b83
commit 42f57108a1
2 changed files with 3 additions and 15 deletions

View File

@@ -63,13 +63,7 @@
<id>{{ $id }}</id>
{{ range $page.OutputFormats }}
{{ $rel := .Rel }}
{{ if eq .Permalink $page.Permalink }}
{{ $rel = "self" }}
{{ else if eq $rel "canonical" }}
{{ $rel = "alternate" }}
{{ end }}
{{ $rel := cond (eq .Rel "canonical") "self" .Rel }}
{{ printf `<link href="%s" rel="%s" type="%s"/>` .Permalink $rel .MediaType | safeHTML }}
{{ end }}
@@ -146,7 +140,7 @@
<id>{{ $id }}</id>
{{ range .OutputFormats }}
{{ $rel := cond (eq .Rel "canonical") "alternate" .Rel }}
{{ $rel := cond (eq .Rel "canonical") "self" .Rel }}
{{ $href := cond (and (eq $rel "alternate") (eq .MediaType.Type "text/html")) $link .Permalink }}

View File

@@ -41,13 +41,7 @@
<rss version="2.0" {{ with $language }} xml:lang="{{ . }}" {{ end }} xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
{{ range $page.OutputFormats }}
{{ $rel := .Rel }}
{{ if eq .Permalink $page.Permalink }}
{{ $rel = "self" }}
{{ else if eq $rel "canonical" }}
{{ $rel = "alternate" }}
{{ end }}
{{ $rel := cond (eq .Rel "canonical") "self" .Rel }}
{{ printf `<link href="%s" rel="%s" type="%s"/>` .Permalink $rel .MediaType | safeHTML }}
{{ end }}