Skip to content

Commit e415382

Browse files
committed
feat(layouts): Add CDATA tag for description in RSS feed
1 parent e09d38c commit e415382

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

layouts/partials/essentials/head.html

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<meta charset="utf-8" />
22
{{ $title := "" }}
33
{{ if .IsHome }}
4-
{{ $title = printf "%s" .Site.Params.homepageTitle }}
4+
{{ $title = printf "%s" .Site.Params.homepageTitle }}
55
{{ else }}
6-
{{ $type := .Type }}
7-
{{ $product := .Params.product }}
8-
9-
{{ if (and (eq $type "neuromorphic-hardware") $product) }}
10-
{{ $title = printf "A Look at %s - %s - %s" .Page.Title "Neuromorphic Chip" .Site.Title}}
11-
{{ else }}
12-
{{ $title = printf "%s - %s" .Page.Title .Site.Title }}
13-
{{ end }}
6+
{{ $type := .Type }}
7+
{{ $product := .Params.product }}
8+
9+
{{ if (and (eq $type "neuromorphic-hardware") $product) }}
10+
{{ $title = printf "A Look at %s - %s - %s" .Page.Title "Neuromorphic Chip" .Site.Title}}
11+
{{ else }}
12+
{{ $title = printf "%s - %s" .Page.Title .Site.Title }}
13+
{{ end }}
1414
{{ end }}
1515

1616

@@ -22,6 +22,44 @@
2222

2323
<link rel="canonical" href="{{ .Permalink }}" />
2424

25+
{{- /* RSS Discovery Links - Single Best Feed Strategy */ -}}
26+
{{- $feed := "" -}}
27+
{{- $feedTitle := "" -}}
28+
{{- $feedProviderPage := "" -}}
29+
30+
{{- /* Determine the page that provides the feed (either the section page or the home page) */ -}}
31+
{{- if .IsPage -}}
32+
{{- $feedProviderPage = .Parent -}}
33+
{{- else if .IsSection -}}
34+
{{- $feedProviderPage = . -}}
35+
{{- else if .IsHome -}}
36+
{{- $feedProviderPage = . -}}
37+
{{- end -}}
38+
39+
{{- /* Check if the identified provider page has an RSS feed and it's not the homepage (unless we are on the homepage) */ -}}
40+
{{- if and $feedProviderPage ($feedProviderPage.OutputFormats.Get "rss") -}}
41+
{{- $homeFeedPermalink := (site.Home.OutputFormats.Get "rss").Permalink -}}
42+
{{- $specificFeed := $feedProviderPage.OutputFormats.Get "rss" -}}
43+
{{- if or (ne $specificFeed.Permalink $homeFeedPermalink) .IsHome -}}
44+
{{- $feed = $specificFeed -}}
45+
{{- $feedTitle = printf "%s | %s" $feedProviderPage.Title site.Title -}}
46+
{{- end -}}
47+
{{- end -}}
48+
49+
{{- /* Fallback to the homepage feed if no specific feed was found */ -}}
50+
{{- if not $feed -}}
51+
{{- with site.Home.OutputFormats.Get "rss" -}}
52+
{{- $feed = . -}}
53+
{{- $feedTitle = printf "%s | RSS Feed" site.Title -}}
54+
{{- end -}}
55+
{{- end -}}
56+
57+
{{- /* Render the single link tag */ -}}
58+
{{- with $feed -}}
59+
<link rel="alternate" type="application/rss+xml" title="{{ $feedTitle }}" href="{{ .Permalink }}">
60+
{{- end -}}
61+
62+
2563
<!-- favicon -->
2664
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
2765
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
@@ -44,4 +82,3 @@
4482
{{ if .Params.math }}
4583
{{ partial "helpers/katex.html" . }}
4684
{{ end }}
47-

0 commit comments

Comments
 (0)