Comments at the bottom of machine pages instead of a tab

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-11 22:07:30 +02:00
co-authored by Claude Opus 5.5
parent 696dfe5e77
commit 2edf77aaa7
22 changed files with 40 additions and 77 deletions
+29
View File
@@ -0,0 +1,29 @@
{{/* Visitor comments at the bottom of a machine's pages. Context: the machine page.
With a forum (params.forum.url) and a thread for the machine: the live thread in a frame
sized to its content. Otherwise: the archived comments as static text. */}}
{{ $p := .Params }}
{{ if and $p.forum_thread site.Params.forum.url }}
<section class="comments-section" id="comments" data-pagefind-ignore>
<h2>Comments</h2>
{{ $thread := printf "%s/embed/%d" (strings.TrimSuffix "/" site.Params.forum.url) (int $p.forum_thread) }}
<p class="note">The first comments were left by visitors of the original site. Log in to the forum to add yours. <a href="{{ replace $thread "/embed/" "/d/" }}">Open this discussion in the forum</a>.</p>
<iframe class="forum-thread" id="forum-thread" src="{{ $thread }}" title="Comments on {{ .Title }}" loading="lazy"></iframe>
{{ with resources.Get "js/iframeResizer.min.js" | fingerprint }}
<script src="{{ .RelPermalink }}"></script>
<script>iFrameResize({ checkOrigin: false, heightCalculationMethod: "lowestElement" }, "#forum-thread");</script>
{{ end }}
</section>
{{ else if $p.comments }}
<section class="comments-section" id="comments" data-pagefind-ignore>
<h2>Comments</h2>
<p class="note">Comments left by visitors of the original site. New comments are closed.</p>
<ol class="comments">
{{ range $p.comments }}
<li>
<p class="meta"><strong>{{ .author }}</strong>{{ with .date }} · {{ . }}{{ end }}</p>
<div>{{ .text | markdownify }}</div>
</li>
{{ end }}
</ol>
</section>
{{ end }}
+1 -1
View File
@@ -1,6 +1,6 @@
{{/* dict "machine" <machine page> "tab" <current tab or ""> */}}
{{ $m := .machine }}
{{ $labels := dict "photos" "Photos" "adverts" "Adverts" "hardware" "Hardware" "connectors" "Connectors" "software" "Software" "emulators" "Emulators" "links" "Links" "docs" "Docs" "videos" "Videos" "comments" "Comments" }}
{{ $labels := dict "photos" "Photos" "adverts" "Adverts" "hardware" "Hardware" "connectors" "Connectors" "software" "Software" "emulators" "Emulators" "links" "Links" "docs" "Docs" "videos" "Videos" }}
<header class="machine-header">
<p class="crumbs" data-pagefind-ignore>
<a href="{{ (site.GetPage "/museum").RelPermalink }}">Museum</a>
+1 -1
View File
@@ -24,7 +24,7 @@
</form>
</header>
{{/* search index: content pages only (not lists), filterable by section; see layouts/search.html */}}
{{ $indexed := and .IsPage (ne .Layout "search") (ne .Params.tab "comments") }}
{{ $indexed := and .IsPage (ne .Layout "search") }}
{{ $section := "" }}{{ with .FirstSection }}{{ if not .IsHome }}{{ $section = .Title }}{{ end }}{{ end }}
{{ if eq .Section "machine-tabs" }}{{ $section = "Museum" }}{{ end }}
<main{{ if $indexed }} data-pagefind-body{{ with $section }} data-pagefind-filter="Section:{{ . }}"{{ end }}{{ end }}>
+1 -20
View File
@@ -33,26 +33,7 @@
{{ end }}
</div>
{{ else if and (eq $tab "comments") $p.forum_thread site.Params.forum.url }}
{{/* live comments: the machine's forum thread, shown in a frame sized to its content */}}
{{ $thread := printf "%s/embed/%d" (strings.TrimSuffix "/" site.Params.forum.url) (int $p.forum_thread) }}
<p class="note">The first comments were left by visitors of the original site. Log in to the forum to add yours. <a href="{{ replace $thread "/embed/" "/d/" }}">Open this discussion in the forum</a>.</p>
<iframe class="forum-thread" id="forum-thread" src="{{ $thread }}" title="Comments on {{ $m.Title }}" loading="lazy"></iframe>
{{ with resources.Get "js/iframeResizer.min.js" | fingerprint }}
<script src="{{ .RelPermalink }}"></script>
<script>iFrameResize({ checkOrigin: false, heightCalculationMethod: "lowestElement" }, "#forum-thread");</script>
{{ end }}
{{ else if eq $tab "comments" }}
<p class="note">Comments left by visitors of the original site. New comments are closed.</p>
<ol class="comments">
{{ range $p.comments }}
<li>
<p class="meta"><strong>{{ .author }}</strong>{{ with .date }} · {{ . }}{{ end }}</p>
<div>{{ .text | markdownify }}</div>
</li>
{{ end }}
</ol>
{{ end }}
{{ partial "comments.html" $m }}
</article>
{{ end }}
+1
View File
@@ -4,5 +4,6 @@
{{ with .Params.image }}<img class="main-image" src="{{ . }}" alt="{{ $.Title }}">{{ end }}
<div class="content">{{ .Content }}</div>
{{ with .Params.specs }}{{ partial "specs.html" . }}{{ end }}
{{ partial "comments.html" . }}
</article>
{{ end }}