Skip to content

Commit 9e40000

Browse files
committed
Make news sidebar rss based, and limitable by config
This can make use of multiple rss feeds in the data/feeds directory the items get merged and sorted by pubDate
1 parent b88e711 commit 9e40000

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ publishDir = "../website"
6060
github = "codemeta"
6161
repo = "codemeta.github.io"
6262
background = "img/pyramids.jpg"
63+
64+
newslimit = 5
6365

6466
date_format = "Mon, Jan 2, 2006"
6567
description = "A Rosetta Stone for Software Metadata"
Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
<div id="newslinks" class="container pt-2">
2-
<h3 class="ms-3">News</h3>
3-
<ul class="list-group list-unstyled">
4-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2025/06/18/codemetar-author-streamlines-software-metadata-updates/">CodemetaR Author streamlines software metadata updates</a></li>
5-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2025/05/07/software-heritage-citation-feature/">Software Heritage Citation Feature: Addressing researcher needs</a></li>
6-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2025/04/02/ospo-radar-project-launch/">The OSPO-RADAR Project: Making research software easier to find and use</a></li>
7-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2024/08/30/codemeta-new-features/">New Features in the CodeMeta Generator</a></li>
8-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2023/08/24/archival-of-software-metadata/">Deep Dive into the archival of Software Metadata</a></li>
9-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2020/03/18/codemeta-community/">Software Heritage contributes CodeMeta generator to the community</a></li>
10-
<li><a class="list-group-item newslink lh-base p-2" href="https://www.softwareheritage.org/2019/05/28/mining-software-metadata-for-80-m-projects-and-even-more/">Mining software metadata for 80 M projects and even more</a></li>
11-
</ul>
2+
<h3 class="ms-3">News</h3>
3+
<ul class="list-group list-unstyled">
4+
{{ if .IsHome }}
5+
6+
{{ $items := slice }}
7+
8+
{{ range $feed := .Site.Data.feeds }}
9+
{{ $item := index $feed.channel "item" }}
10+
{{ $items = $items | append $item }}
11+
{{ end }}
12+
13+
{{ $combi := slice }}
14+
15+
{{- range $items -}}
16+
{{ $t := time.AsTime .pubDate }}
17+
{{ $m := dict "link" .link "title" .title "pubDate" $t "description" .description }}
18+
{{ $combi = $combi | append $m }}
19+
{{- end -}}
20+
21+
{{ $combi := sort $combi ".pubDate" "desc" }}
22+
23+
{{ range first .Site.Params.newslimit $combi }}
24+
25+
<li class="ps-2">
26+
<a class="list-group-item newslink lh-base p-2" href="{{ .link }}">{{ .title }}</a>
27+
<small class="p-2 text-secondary-emphasis">{{ .pubDate | time.Format "Jan 02, 2006 3:04 PM MST" }}</small>
28+
</li>
29+
{{ end }}
30+
{{ else }}
31+
{{ range $combi }}
32+
<li class="ps-2">
33+
<a class="list-group-item newslink lh-base p-2" href="{{ .link }}">{{ .title }}</a>
34+
<small class="p-2 text-secondary-emphasis">{{ .pubDate | time.Format "Jan 02, 2006 3:04 PM MST" }}</small>
35+
</li>
36+
{{ end }}
37+
{{ end }}
38+
</ul>
39+
{{ if .IsHome }}<div class="text-center"><small class="mw-100 text-secondary-emphasis">Updates daily<br><a href="/news">Full news feed</a></small></div>{{ end }}
1240
</div>

0 commit comments

Comments
 (0)