Tables with a header row can be sorted by clicking a column header

Listing tables on company, taxonomy and generic list pages get column headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
This commit is contained in:
2026-10-12 21:03:41 +02:00
co-authored by Claude Opus 5.5
parent c913d792c4
commit dfb2d2ce68
7 changed files with 83 additions and 12 deletions
+12 -4
View File
@@ -1,14 +1,22 @@
{{/* table of pages: machines get company/year/type columns; companies are a plain list */}}
{{ if eq (index . 0).Section "companies" }}
{{/* table of pages: machines get company/year/type columns; companies are a plain list.
Takes the pages, or (dict "pages" … "head" true) to add the column headers (sortable). */}}
{{ $pages := . }}{{ $head := false }}
{{ if reflect.IsMap . }}{{ $pages = .pages }}{{ $head = .head }}{{ end }}
{{ if eq (index $pages 0).Section "companies" }}
<ul class="columns">
{{ range . }}
{{ range $pages }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a> <small>({{ len .Params.machines }})</small></li>
{{ end }}
</ul>
{{ else }}
<table class="list">
{{ if $head }}
<thead>
<tr><th>Name</th><th>Year</th><th>{{ if eq (index $pages 0).Section "software" }}Tags{{ else }}Type{{ end }}</th><th>Origin</th></tr>
</thead>
{{ end }}
<tbody>
{{ range . }}
{{ range $pages }}
<tr>
<td><a href="{{ .RelPermalink }}">{{ .Title }}</a></td>
<td>{{ partial "terms.html" (dict "page" . "taxonomy" "years") }}</td>
+3
View File
@@ -8,6 +8,9 @@
{{ with resources.Get "css/main.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ end }}
{{ with resources.Get "js/sortTables.js" | minify | fingerprint }}
<script src="{{ .RelPermalink }}" defer></script>
{{ end }}
</head>
<body>
<header class="site-header">
+1 -1
View File
@@ -7,7 +7,7 @@
<h2>Systems</h2>
{{ $pages := slice }}
{{ range . }}{{ with site.GetPage . }}{{ $pages = $pages | append . }}{{ end }}{{ end }}
{{ partial "page-list.html" $pages }}
{{ partial "page-list.html" (dict "pages" $pages "head" true) }}
{{ end }}
</article>
{{ end }}
+1 -1
View File
@@ -1,5 +1,5 @@
{{ define "main" }}
<h1>{{ .Title }}</h1>
<div class="content">{{ .Content }}</div>
{{ partial "page-list.html" .RegularPages.ByTitle }}
{{ partial "page-list.html" (dict "pages" .RegularPages.ByTitle "head" true) }}
{{ end }}
+1 -1
View File
@@ -3,6 +3,6 @@
<h1>{{ .Title }}</h1>
{{ range .Pages.GroupBy "Section" }}
<h2>{{ with site.GetPage (printf "/%s" .Key) }}{{ .Title }}{{ end }} <small>({{ len .Pages }})</small></h2>
{{ partial "page-list.html" .Pages.ByTitle }}
{{ partial "page-list.html" (dict "pages" .Pages.ByTitle "head" true) }}
{{ end }}
{{ end }}