Skip to content

Commit c0a5eea

Browse files
authored
[infra] Better support for RSS and blog pages (#6002)
1 parent efb4d34 commit c0a5eea

File tree

14 files changed

+83
-24
lines changed

14 files changed

+83
-24
lines changed

content/en/_index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ description: >-
55
observability
66
outputs:
77
- HTML
8-
- REDIRECTS # Include this `content/en` ONLY
8+
# Include the following for `content/en` ONLY
9+
- REDIRECTS
10+
- RSS
911
developer_note:
1012
The blocks/cover shortcode (used below) will use as a background image any
1113
image file containing "background" in its name.

content/en/blog/2024/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
22
title: 2024
33
weight: -2024
4-
outputs: [HTML, RSS]
54
---

content/en/blog/2025/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: 2025
33
weight: -2025
4-
outputs: [HTML, RSS]
54
---
65

76
## Happy New Year!

content/en/blog/_index.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
22
title: Blog
33
menu: { main: { weight: 50 } }
4-
redirects:
5-
# Every January, update the year number in the paths below
6-
- { from: '', to: '2024/ 302!' }
7-
# Workaround to https://github.com/open-telemetry/opentelemetry.io/issues/4440:
8-
- { from: 'index.xml', to: '2024/index.xml 302!' }
94
outputs: [HTML, RSS]
105
htmltest:
116
# 2024-11-07 DO NOT COPY the following IgnoreDirs to non-en pages because it handles all locales.
@@ -14,4 +9,16 @@ htmltest:
149
- ^(../)?blog/(\d+/)?page/\d+
1510
# Ignore old blog posts
1611
- ^(../)?blog/20(19|21|22|23)/
12+
description: OpenTelemetry blog
1713
---
14+
15+
<script>
16+
document.addEventListener("DOMContentLoaded", function () {
17+
if (window.location.pathname.includes('/page/')) return;
18+
19+
var checkbox = document.getElementById("m-blog2025-check");
20+
if (checkbox) checkbox.checked = true;
21+
checkbox = document.getElementById("m-blog2024-check");
22+
if (checkbox) checkbox.checked = true;
23+
});
24+
</script>

content/es/_index.md

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: OpenTelemetry
33
description: >-
44
Telemetría portable, ubicua, y de alta calidad para una observabilidad eficaz
5-
outputs:
6-
- HTML
75
developer_note:
86
La macro para los bloques/portada usa como imagen de fondo cualquier archivo
97
de imagen que contenga la palabra "background" en su nombre.

content/fr/_index.md

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ title: OpenTelemetry
33
description: >-
44
Une télémétrie de qualité, universelle et portable pour une observabilité
55
efficace
6-
outputs:
7-
- HTML
8-
- REDIRECTS # Include this `content/fr` ONLY
96
developer_note:
107
La macro "blocks/cover" définie ci-dessous permet d'utiliser comme image de
118
fond tout visuel contenant "background" dans son nom.

content/ja/blog/2024/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 2024
33
weight: -2024
4-
outputs: [HTML, RSS]
54
default_lang_commit: 48eac183a4dd74946d5a45fa436cfc6052f30532
65
---

content/ja/blog/_index.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: ブログ
3-
menu:
4-
main: { weight: 50 }
5-
redirects: [{ from: '', to: '2024/ 301!' }]
3+
menu: { main: { weight: 50 } }
64
outputs: [HTML, RSS]
75
default_lang_commit: 48eac183a4dd74946d5a45fa436cfc6052f30532
86
---

content/pt/blog/2024/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 2024
33
weight: -2024
4-
outputs: [HTML, RSS]
54
default_lang_commit: 48eac183a4dd74946d5a45fa436cfc6052f30532
65
---

content/pt/blog/_index.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: Blog
3-
menu:
4-
main: { weight: 50 }
5-
redirects: [{ from: '', to: '2024/ 301!' }]
3+
menu: { main: { weight: 50 } }
64
outputs: [HTML, RSS]
75
default_lang_commit: 48eac183a4dd74946d5a45fa436cfc6052f30532
86
---

content/zh/blog/2024/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 2024
33
weight: -2024
4-
outputs: [HTML, RSS]
54
default_lang_commit: aca2e07f0d3a6
65
---

content/zh/blog/_index.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: 博客
33
menu: { main: { weight: 50 } }
4-
redirects: [{ from: '', to: '2024/ 301!' }]
54
outputs: [HTML, RSS]
65
default_lang_commit: 4c5468f8d16434f25f335e1b45922ca0f4cec18f
76
---

hugo.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ outputFormats:
7070
notAlternative: true
7171

7272
outputs:
73-
home: [HTML]
73+
home: [HTML, RSS]
7474
section: [HTML]
7575

76+
services:
77+
rss: { limit: 20 }
78+
7679
params:
7780
copyright:
7881
authors: >-

layouts/_default/rss.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/* Delta of https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml */}}
2+
3+
{{- $authorEmail := "" }}
4+
{{- with site.Params.author }}
5+
{{- if reflect.IsMap . }}
6+
{{- with .email }}
7+
{{- $authorEmail = . }}
8+
{{- end }}
9+
{{- end }}
10+
{{- end }}
11+
12+
{{- $authorName := "" }}
13+
{{- with site.Params.author }}
14+
{{- if reflect.IsMap . }}
15+
{{- with .name }}
16+
{{- $authorName = . }}
17+
{{- end }}
18+
{{- else }}
19+
{{- $authorName = . }}
20+
{{- end }}
21+
{{- end }}
22+
23+
{{- $pctx := . }}
24+
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
25+
{{- $pages := slice }}
26+
{{- if or $.IsHome $.IsSection }}
27+
{{- $pages = $pctx.RegularPages }}
28+
{{- else }}
29+
{{- $pages = $pctx.Pages }}
30+
{{- end }}
31+
{{- $pages = .RegularPagesRecursive }} {{- /* OTel: always use all pages, recursively. */}}
32+
{{- $limit := .Site.Config.Services.RSS.Limit }}
33+
{{- if ge $limit 1 }}
34+
{{- $pages = $pages | first $limit }}
35+
{{- end }}
36+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
37+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
38+
<channel>
39+
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
40+
<link>{{ .Permalink }}</link>
41+
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
42+
<generator>Hugo</generator>
43+
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
44+
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
45+
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
46+
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
47+
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
48+
{{- with .OutputFormats.Get "RSS" }}
49+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
50+
{{- end }}
51+
{{- range $pages.ByLastmod.Reverse }}
52+
<item>
53+
<title>{{ .Title }}</title>
54+
<link>{{ .Permalink }}</link>
55+
<pubDate>{{ .Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
56+
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
57+
<guid>{{ .Permalink }}</guid>
58+
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
59+
</item>
60+
{{- end }}
61+
</channel>
62+
</rss>

0 commit comments

Comments
 (0)