Comments on news posts: one forum discussion per post

oc:pages command in the forum extension, tools/forum_sync.py and
'make forum-sync' (run by deploy) keep data/forum_pages.json up to date;
post pages end with their discussion.

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:22:20 +02:00
co-authored by Claude Opus 5.5
parent 418913d47e
commit 785c4967be
12 changed files with 243 additions and 31 deletions
+1 -7
View File
@@ -5,13 +5,7 @@
{{ 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 }}
{{ partial "forum-thread.html" (dict "id" $p.forum_thread "title" .Title "note" "The first comments were left by visitors of the original site. Log in to the forum to add yours.") }}
</section>
{{ else if $p.comments }}
<section class="comments-section" id="comments" data-pagefind-ignore>
+9
View File
@@ -0,0 +1,9 @@
{{/* A forum discussion shown in a frame sized to its content.
dict "id" <discussion number> "title" <page title> "note" <sentence shown above> */}}
{{ $thread := printf "%s/embed/%d" (strings.TrimSuffix "/" site.Params.forum.url) (int .id) }}
<p class="note">{{ .note }} <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 }}
+7
View File
@@ -5,6 +5,13 @@
<p class="meta">{{ if not .Date.IsZero }}<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 January 2006" }}</time>{{ end }}{{ with .GetTerms "author" }}{{ if not $.Date.IsZero }} · {{ end }}{{ partial "terms.html" (dict "page" $ "taxonomy" "author") }}{{ end }}</p>
{{ with partial "banner.html" (dict "page" . "width" 1000) }}<img class="post-banner" src="{{ . }}" alt="">{{ end }}
<div class="content">{{ .Content }}</div>
{{/* comments: the post's forum discussion, created by `make forum-sync` (data/forum_pages.json) */}}
{{ with and site.Params.forum.url .File (index (hugo.Data.forum_pages | default dict) .File.Path) }}
<section class="comments-section" id="comments" data-pagefind-ignore>
<h2>Comments</h2>
{{ partial "forum-thread.html" (dict "id" . "title" $.Title "note" "Log in to the forum to comment.") }}
</section>
{{ end }}
<nav class="prev-next" data-pagefind-ignore>
{{ with .PrevInSection }}<a href="{{ .RelPermalink }}">← {{ .Title }}</a>{{ end }}
{{ with .NextInSection }}<a href="{{ .RelPermalink }}">{{ .Title }} →</a>{{ end }}