Skip to content

Commit 44f0ed8

Browse files
authored
Add support for RSS Feed (#258)
* Add Title to hugo.yaml and modify navbar to use it navbar.html by defalut puts the title on every page. This update modifies it to not put the title on the home page. The title already is a central part of the text within the page and having it on the home page is redundant. Defining the title in the config comes in useful for other Hugo templates that want to use the title of the website. * Add RSS Feed to History, Software and Project pages. RSS Feed generates feed containing all subpages from these sections. * Add rss Feed to Footer Update rssFeed url value to project/status page Add frontmatter and enable git info These changes allow us to get the last modified date for pages. Update page-meta-lastmod file to not show git commit info * Update config files to rename RSS Feed to rss.xml * Update title and description lines Title and Description are set to Updates from the Medley Interlisp Project.
1 parent 0e207e8 commit 44f0ed8

File tree

7 files changed

+197
-2
lines changed

7 files changed

+197
-2
lines changed

config/_default/hugo.yaml

+21-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# An overview of hugo configuration files can be found at:
66
# https://gohugo.io/getting-started/configuration/#configure-server
77
#
8+
# title: The title that appears in the navbar of every page. We have
9+
# edited navbar.html to not show the title in the navbar of the home page.
10+
title: "The Medley Interlisp Project"
811

912
# relativeURLs: Enable to force all relative URLs to be relative to content root
1013
relativeURLs: false
@@ -21,7 +24,7 @@ enableRobotsTXT: false
2124
assetDir: static
2225

2326
# Enable .GitInfo object for each page. This will give values to .Lastmod etc.
24-
enableGitInfo: false
27+
enableGitInfo: true
2528

2629
# Top Level Language defaults
2730
# See languages.yaml for language specific values
@@ -35,7 +38,23 @@ enableMissingTranslationPlaceholders: true
3538
disableKinds:
3639
- taxonomy
3740
- term
38-
- RSS
41+
42+
outputs:
43+
home:
44+
- HTML
45+
section:
46+
- HTML
47+
48+
frontmatter:
49+
date:
50+
- date
51+
- pubdate
52+
- :git
53+
- :default
54+
55+
outputFormats:
56+
rss:
57+
baseName: rss
3958

4059
# Code Highlighting configuration
4160
# Not Used. Code highlighting is controlled using the highlighting

config/_default/params.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ links:
7979
url: "https://bsky.app/profile/interlisp.org"
8080
icon: "fa-brands fa-bluesky"
8181
desc: "We're on Bluesky too!"
82+
- name: "RSS Feed"
83+
url: "project/status/rss.xml"
84+
icon: "fa fa-rss"
85+
desc: "Subscribe to our feed for the latest updates"
8286
# - name: "Stack Overflow"
8387
# url: "https://stackoverflow.com/questions/tagged/graphviz"
8488
# icon: "fab fa-stack-overflow"

content/en/project/status/_index.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
title: News and Status Reports
33
type: docs
44
weight: 2
5+
outputs:
6+
- html
7+
- rss
58
aliases:
69
- /hugo/news/
710
- /medley/project/news/

layouts/_default/rss.xml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{- $authorName := "" }}
2+
{{- with .Site.Params.author }}
3+
{{- if reflect.IsMap . }}
4+
{{- with .name }}
5+
{{- $authorName = . }}
6+
{{- end }}
7+
{{- else }}
8+
{{- $authorName = . }}
9+
{{- end }}
10+
{{- end }}
11+
12+
{{- $pctx := . }}
13+
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
14+
15+
<!-- Iterate through all sections and include both sections and
16+
pages in the rss feed. The default rss.xml only includes
17+
pages. -->
18+
{{- $pages := slice }}
19+
{{- $mainPages := where .Pages "Kind" "in" (slice "page" "section") }}
20+
{{- $pages = $pages | union $mainPages }}
21+
22+
{{- range .Sections }}
23+
{{- $sectionPages := where .Pages "Kind" "in" (slice "page" "section") }}
24+
{{- $pages = $pages | union $sectionPages }}
25+
{{- range .Sections }}
26+
{{- $subSectionPages := where .Pages "Kind" "in" (slice "page" "section") }}
27+
{{- $pages = $pages | union $subSectionPages }}
28+
{{- end }}
29+
{{- end }}
30+
31+
{{- $limit := .Site.Config.Services.RSS.Limit }}
32+
{{- if ge $limit 1 }}
33+
{{- $pages = $pages | first $limit }}
34+
{{- end }}
35+
36+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
37+
<channel>
38+
<title>Updates from the Medley Interlisp Project</title>
39+
<link>{{ .Permalink }}</link>
40+
<description>Updates from the Medley Interlisp Project</description>
41+
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
42+
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
43+
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
44+
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
45+
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
46+
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
47+
{{ with .OutputFormats.Get "RSS" }}
48+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
49+
{{ end }}
50+
{{ range $pages }}
51+
<item>
52+
<title>{{ .Title }}</title>
53+
<link>{{ .Permalink }}</link>
54+
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
55+
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
56+
<guid>{{ .Permalink }}</guid>
57+
<description>{{ .Summary | html }}</description>
58+
{{ range .Params.tags }}
59+
<category>{{ . }}</category>
60+
{{ end }}
61+
</item>
62+
{{ end }}
63+
</channel>
64+
</rss>

layouts/partials/footer/links.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ul class="td-footer__links-list">
2+
{{ range . }}
3+
{{ if eq .name "RSS Feed" }}
4+
<li class="td-footer__links-item" data-bs-toggle="tooltip" title="RSS" aria-label="RSS">
5+
<a target="_blank" rel="noopener" href="{{ absURL .url }}" aria-label="RSS">
6+
<i class="fas fa-rss"></i>
7+
</a>
8+
</li>
9+
{{ else }}
10+
<li class="td-footer__links-item" data-bs-toggle="tooltip" title="{{ .name }}" aria-label="{{ .name }}">
11+
<a target="_blank" rel="noopener" href="{{ .url }}" aria-label="{{ .name }}">
12+
<i class="{{ .icon }}"></i>
13+
</a>
14+
{{ end }}
15+
{{ end }}
16+
17+
</ul>

layouts/partials/navbar.html

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{{ $cover := and
2+
(.HasShortcode "blocks/cover")
3+
(not .Site.Params.ui.navbar_translucent_over_cover_disable)
4+
-}}
5+
{{ $baseURL := urls.Parse $.Site.Params.Baseurl -}}
6+
7+
<nav class="td-navbar js-navbar-scroll
8+
{{- if $cover }} td-navbar-cover {{- end }}" data-bs-theme="dark">
9+
<div class="container-fluid flex-column flex-md-row">
10+
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
11+
{{- /**/ -}}
12+
<span class="navbar-brand__logo navbar-logo">
13+
{{- if ne .Site.Params.ui.navbar_logo false -}}
14+
{{ with resources.Get "icons/logo.svg" -}}
15+
{{ ( . | minify).Content | safeHTML -}}
16+
{{ end -}}
17+
{{ end -}}
18+
</span>
19+
{{- /**/ -}}
20+
<span class="navbar-brand__name">
21+
<!-- Place the site title on every page header, except the home page -->
22+
{{ if not .IsHome }}
23+
{{ .Site.Title }}
24+
{{ end }}
25+
26+
</span>
27+
{{- /**/ -}}
28+
</a>
29+
<div class="td-navbar-nav-scroll ms-md-auto" id="main_navbar">
30+
<ul class="navbar-nav">
31+
{{ $p := . -}}
32+
{{ range .Site.Menus.main -}}
33+
<li class="nav-item">
34+
{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) -}}
35+
{{ $href := "" -}}
36+
{{ with .Page -}}
37+
{{ $active = or $active ( $.IsDescendant .) -}}
38+
{{ $href = .RelPermalink -}}
39+
{{ else -}}
40+
{{ $href = .URL | relLangURL -}}
41+
{{ end -}}
42+
{{ $isExternal := ne $baseURL.Host (urls.Parse .URL).Host -}}
43+
<a {{/**/ -}}
44+
class="nav-link {{- if $active }} active {{- end }}" {{/**/ -}}
45+
href="{{ $href }}"
46+
{{- if $isExternal }} target="_blank" rel="noopener" {{- end -}}
47+
>
48+
{{- .Pre -}}
49+
<span>{{ .Name }}</span>
50+
{{- .Post -}}
51+
</a>
52+
</li>
53+
{{ end -}}
54+
{{ if .Site.Params.versions -}}
55+
<li class="nav-item dropdown d-none d-lg-block">
56+
{{ partial "navbar-version-selector.html" . -}}
57+
</li>
58+
{{ end -}}
59+
{{ if (gt (len .Site.Home.Translations) 0) -}}
60+
<li class="nav-item dropdown d-none d-lg-block">
61+
{{ partial "navbar-lang-selector.html" . -}}
62+
</li>
63+
{{ end -}}
64+
{{ if .Site.Params.ui.showLightDarkModeMenu -}}
65+
<li class="td-light-dark-menu nav-item dropdown">
66+
{{ partial "theme-toggler" . }}
67+
</li>
68+
{{ end -}}
69+
</ul>
70+
</div>
71+
<div class="d-none d-lg-block">
72+
{{ partial "search-input.html" . }}
73+
</div>
74+
</div>
75+
</nav>
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{ if and .GitInfo .Site.Params.github_repo -}}
2+
<div class="td-page-meta__lastmod">
3+
<!--
4+
Disable showing of Git Commit info in the footer
5+
{{ T "post_last_mod" }} {{ .Lastmod.Format .Site.Params.time_format_default -}}
6+
{{ with .GitInfo }}: {{/* Trim WS */ -}}
7+
<a data-proofer-ignore href="{{ $.Site.Params.github_repo }}/commit/{{ .Hash }}">
8+
{{- .Subject }} ({{ .AbbreviatedHash }}) {{- /* Trim WS */ -}}
9+
</a>
10+
{{- end }}
11+
-->
12+
</div>
13+
{{ end -}}

0 commit comments

Comments
 (0)