Files
website/layouts/_partials/comments.html
T

30 lines
1.5 KiB
HTML

{{/* 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 }}