Skip to content

Commit e4f7dd1

Browse files
authored
add footer navigation and breadcrumbs (#29)
## Summary - Add a footer with navigation links (Home, Architecture, Reply to this) to de-orphan sub-pages that previously had no way to navigate between them - Prevent `graphviz-ssr.js` from rewriting footer URLs into empty links. - Add JSON-LD breadcrumb structured data for each page so search engines understand the site hierarchy <br /><br /> <img width="400" height="241" alt="footer-gitgitgadget" src="https://github.com/user-attachments/assets/64c8b1cf-6a06-46bd-9c73-44255d025fc8" />
2 parents 643f10f + d4f92f8 commit e4f7dd1

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

assets/sass/main.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,29 @@ div.feature-matrix {
7878
vertical-align: center;
7979
}
8080
}
81+
footer nav ul {
82+
list-style: none;
83+
padding: 0;
84+
margin: 0;
85+
display: flex;
86+
flex-wrap: wrap;
87+
gap: 0.5em 1em;
88+
justify-content: center;
89+
text-align: center;
90+
}
91+
footer nav ul li a {
92+
text-decoration: none;
93+
}
94+
.footer-favicon {
95+
width: 24px;
96+
height: 24px;
97+
display: block;
98+
}
99+
.footer-home-link {
100+
display: block;
101+
width: 24px;
102+
margin: 0.75em auto 0;
103+
}
81104
@media screen and (max-width: 450px) {
82105
big {
83106
font-size: 300%;

layouts/_default/baseof.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="icon" href="{{ relURL "favicon.ico" }}">
88
{{- $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "main.scss" . | css.Sass }}
99
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
10+
{{- partial "breadcrumbs.html" . -}}
1011
</head>
1112
<body>
1213
{{ partial "banner.html" . -}}

layouts/_default/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{{ define "main" }}
22
{{ .Content | replaceRE "(<h2 id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1} <a href="#${2}">#</a> ${3}` | safeHTML }}
3+
{{ partial "footer.html" . }}
34
{{ end }}

layouts/_default/single.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<div class="block">
33
{{ .Content }}
44
</div>
5+
{{ partial "footer.html" . }}
56
{{ end }}

layouts/partials/breadcrumbs.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script type="application/ld+json">
2+
{
3+
"@context": "https://schema.org",
4+
"@type": "BreadcrumbList",
5+
"itemListElement": [
6+
{
7+
"@type": "ListItem",
8+
"position": 1,
9+
"name": "Home",
10+
"item": "{{ .Site.BaseURL }}"
11+
}{{ if ne .Kind "home" }},
12+
{
13+
"@type": "ListItem",
14+
"position": 2,
15+
"name": "{{ .Title }}",
16+
"item": "{{ .Permalink }}"
17+
}{{ end }}
18+
]
19+
}
20+
</script>

layouts/partials/footer.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<footer>
2+
<hr>
3+
<nav>
4+
<ul>
5+
<li><a href="{{ relURL "/" }}">Home</a></li>
6+
<li><a href="{{ relURL "architecture/" }}">Architecture</a></li>
7+
<li><a href="{{ relURL "reply-to-this/" }}">Reply to this</a></li>
8+
</ul>
9+
</nav>
10+
<a class="footer-home-link" href="{{ relURL "/" }}" aria-label="Home">
11+
<img class="footer-favicon" src="{{ relURL "favicon.ico" }}" alt="" aria-hidden="true">
12+
</a>
13+
</footer>

script/graphviz-ssr.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import Viz from "../static/js/viz-global.js"
1313
for (const { Path: pathInPublic } of JSON.parse(readFileSync("public/diagram-list.json", "utf-8"))) {
1414
const path = `public${pathInPublic}.html`
1515
const contents = readFileSync(path, "utf-8")
16-
const html = parse(contents)
16+
// `node-html-parser` can misparse unquoted URLs ending in `/` (e.g. `href=../architecture/`)
17+
// and rewrite links as empty anchors. Quote these attribute values before parsing.
18+
const normalized = contents.replace(/\b(href|src)=([^"'`\s>]+)/g, '$1="$2"')
19+
const html = parse(normalized)
1720
const vizImport = html.querySelector('script[src$="viz-global.js"]')
1821
if (!vizImport) {
1922
console.error(`No 'viz-global.js' import found in ${path}; skipping`)

0 commit comments

Comments
 (0)