Skip to content

Commit

Permalink
Add support for RSS Feed (#258)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
stumbo authored Dec 26, 2024
1 parent 0e207e8 commit 44f0ed8
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 2 deletions.
23 changes: 21 additions & 2 deletions config/_default/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# An overview of hugo configuration files can be found at:
# https://gohugo.io/getting-started/configuration/#configure-server
#
# title: The title that appears in the navbar of every page. We have
# edited navbar.html to not show the title in the navbar of the home page.
title: "The Medley Interlisp Project"

# relativeURLs: Enable to force all relative URLs to be relative to content root
relativeURLs: false
Expand All @@ -21,7 +24,7 @@ enableRobotsTXT: false
assetDir: static

# Enable .GitInfo object for each page. This will give values to .Lastmod etc.
enableGitInfo: false
enableGitInfo: true

# Top Level Language defaults
# See languages.yaml for language specific values
Expand All @@ -35,7 +38,23 @@ enableMissingTranslationPlaceholders: true
disableKinds:
- taxonomy
- term
- RSS

outputs:
home:
- HTML
section:
- HTML

frontmatter:
date:
- date
- pubdate
- :git
- :default

outputFormats:
rss:
baseName: rss

# Code Highlighting configuration
# Not Used. Code highlighting is controlled using the highlighting
Expand Down
4 changes: 4 additions & 0 deletions config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ links:
url: "https://bsky.app/profile/interlisp.org"
icon: "fa-brands fa-bluesky"
desc: "We're on Bluesky too!"
- name: "RSS Feed"
url: "project/status/rss.xml"
icon: "fa fa-rss"
desc: "Subscribe to our feed for the latest updates"
# - name: "Stack Overflow"
# url: "https://stackoverflow.com/questions/tagged/graphviz"
# icon: "fab fa-stack-overflow"
Expand Down
3 changes: 3 additions & 0 deletions content/en/project/status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: News and Status Reports
type: docs
weight: 2
outputs:
- html
- rss
aliases:
- /hugo/news/
- /medley/project/news/
Expand Down
64 changes: 64 additions & 0 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- $authorName := "" }}
{{- with .Site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- $authorName = . }}
{{- end }}
{{- end }}

{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}

<!-- Iterate through all sections and include both sections and
pages in the rss feed. The default rss.xml only includes
pages. -->
{{- $pages := slice }}
{{- $mainPages := where .Pages "Kind" "in" (slice "page" "section") }}
{{- $pages = $pages | union $mainPages }}

{{- range .Sections }}
{{- $sectionPages := where .Pages "Kind" "in" (slice "page" "section") }}
{{- $pages = $pages | union $sectionPages }}
{{- range .Sections }}
{{- $subSectionPages := where .Pages "Kind" "in" (slice "page" "section") }}
{{- $pages = $pages | union $subSectionPages }}
{{- end }}
{{- end }}

{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Updates from the Medley Interlisp Project</title>
<link>{{ .Permalink }}</link>
<description>Updates from the Medley Interlisp Project</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description>
{{ range .Params.tags }}
<category>{{ . }}</category>
{{ end }}
</item>
{{ end }}
</channel>
</rss>
17 changes: 17 additions & 0 deletions layouts/partials/footer/links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<ul class="td-footer__links-list">
{{ range . }}
{{ if eq .name "RSS Feed" }}
<li class="td-footer__links-item" data-bs-toggle="tooltip" title="RSS" aria-label="RSS">
<a target="_blank" rel="noopener" href="{{ absURL .url }}" aria-label="RSS">
<i class="fas fa-rss"></i>
</a>
</li>
{{ else }}
<li class="td-footer__links-item" data-bs-toggle="tooltip" title="{{ .name }}" aria-label="{{ .name }}">
<a target="_blank" rel="noopener" href="{{ .url }}" aria-label="{{ .name }}">
<i class="{{ .icon }}"></i>
</a>
{{ end }}
{{ end }}

</ul>
75 changes: 75 additions & 0 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{ $cover := and
(.HasShortcode "blocks/cover")
(not .Site.Params.ui.navbar_translucent_over_cover_disable)
-}}
{{ $baseURL := urls.Parse $.Site.Params.Baseurl -}}

<nav class="td-navbar js-navbar-scroll
{{- if $cover }} td-navbar-cover {{- end }}" data-bs-theme="dark">
<div class="container-fluid flex-column flex-md-row">
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
{{- /**/ -}}
<span class="navbar-brand__logo navbar-logo">
{{- if ne .Site.Params.ui.navbar_logo false -}}
{{ with resources.Get "icons/logo.svg" -}}
{{ ( . | minify).Content | safeHTML -}}
{{ end -}}
{{ end -}}
</span>
{{- /**/ -}}
<span class="navbar-brand__name">
<!-- Place the site title on every page header, except the home page -->
{{ if not .IsHome }}
{{ .Site.Title }}
{{ end }}

</span>
{{- /**/ -}}
</a>
<div class="td-navbar-nav-scroll ms-md-auto" id="main_navbar">
<ul class="navbar-nav">
{{ $p := . -}}
{{ range .Site.Menus.main -}}
<li class="nav-item">
{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) -}}
{{ $href := "" -}}
{{ with .Page -}}
{{ $active = or $active ( $.IsDescendant .) -}}
{{ $href = .RelPermalink -}}
{{ else -}}
{{ $href = .URL | relLangURL -}}
{{ end -}}
{{ $isExternal := ne $baseURL.Host (urls.Parse .URL).Host -}}
<a {{/**/ -}}
class="nav-link {{- if $active }} active {{- end }}" {{/**/ -}}
href="{{ $href }}"
{{- if $isExternal }} target="_blank" rel="noopener" {{- end -}}
>
{{- .Pre -}}
<span>{{ .Name }}</span>
{{- .Post -}}
</a>
</li>
{{ end -}}
{{ if .Site.Params.versions -}}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-version-selector.html" . -}}
</li>
{{ end -}}
{{ if (gt (len .Site.Home.Translations) 0) -}}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-lang-selector.html" . -}}
</li>
{{ end -}}
{{ if .Site.Params.ui.showLightDarkModeMenu -}}
<li class="td-light-dark-menu nav-item dropdown">
{{ partial "theme-toggler" . }}
</li>
{{ end -}}
</ul>
</div>
<div class="d-none d-lg-block">
{{ partial "search-input.html" . }}
</div>
</div>
</nav>
13 changes: 13 additions & 0 deletions layouts/partials/page-meta-lastmod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ if and .GitInfo .Site.Params.github_repo -}}
<div class="td-page-meta__lastmod">
<!--
Disable showing of Git Commit info in the footer
{{ T "post_last_mod" }} {{ .Lastmod.Format .Site.Params.time_format_default -}}
{{ with .GitInfo }}: {{/* Trim WS */ -}}
<a data-proofer-ignore href="{{ $.Site.Params.github_repo }}/commit/{{ .Hash }}">
{{- .Subject }} ({{ .AbbreviatedHash }}) {{- /* Trim WS */ -}}
</a>
{{- end }}
-->
</div>
{{ end -}}

0 comments on commit 44f0ed8

Please sign in to comment.