mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-12-24 01:42:10 +00:00
Indieweb: statically display webmentions
Statically grab and include webmentions during Hugo builds, no JS involved. Hugo supports making web requests and parsing the resulting JSON, so there was no need to use an external program either.
This commit is contained in:
parent
950918b104
commit
938428333e
4 changed files with 40 additions and 17 deletions
|
@ -43,11 +43,11 @@ nav li {
|
|||
* of the "date + title" format is enough to convey separation
|
||||
* between elements.
|
||||
*/
|
||||
.posts {
|
||||
.unstyled-list {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.posts li {
|
||||
.unstyled-list li {
|
||||
list-style-type: none;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
|
|
@ -14,17 +14,37 @@
|
|||
<section class="e-content" itemprop="articlebody">
|
||||
{{ partial "processed-content" . -}}
|
||||
</section>
|
||||
</article>
|
||||
<br>
|
||||
<hr>
|
||||
<footer class="comment">
|
||||
{{ with .OutputFormats.Get "gemtext" -}}
|
||||
<p>
|
||||
View this article on <a rel="syndication" class="u-syndication" href="{{replace .Permalink "/gemini" "" 1 | safeURL}}">my Gemini capsule</a>
|
||||
</p>
|
||||
{{ end -}}
|
||||
<p><a href="mailto:~seirdy/seirdy.one-comments@lists.sr.ht">Send an email</a> to leave a comment in the <a href="https://lists.sr.ht/~seirdy/seirdy.one-comments">mailing list</a> for seirdy.one. You'll have to send in plain text; please <a href="https://useplaintext.email/">learn how.</a>. Alternatively, send your email <a href="mailto:seirdy@seirdy.one">directly to me</a>; it won’t show up on the mailing list, but I’ll see it.</p>
|
||||
</footer>
|
||||
</article>
|
||||
<br>
|
||||
<hr>
|
||||
<footer class="comment">
|
||||
{{ with .OutputFormats.Get "gemtext" -}}
|
||||
<p>
|
||||
View this article on <a rel="syndication" class="u-syndication" href="{{replace .Permalink "/gemini" "" 1 | safeURL}}">my Gemini capsule</a>
|
||||
</p>
|
||||
{{ end -}}
|
||||
<p><a href="mailto:~seirdy/seirdy.one-comments@lists.sr.ht">Send an email</a> to leave a comment in the <a href="https://lists.sr.ht/~seirdy/seirdy.one-comments">mailing list</a> for seirdy.one. You'll have to send in plain text; please <a href="https://useplaintext.email/">learn how.</a>. Alternatively, send your email <a href="mailto:seirdy@seirdy.one">directly to me</a>; it won’t show up on the mailing list, but I’ll see it.</p>
|
||||
<p>This site also supports <a href="https://indieweb.org/webmention">Webmentions</a>. Webmentions received for this post will appear below after I approve them.</p>
|
||||
<section class="webmentions">
|
||||
<h2>Webmentions</h2>
|
||||
<ul class="unstyled-list">
|
||||
{{ $target := .RelPermalink -}}
|
||||
{{ $url := printf "https://seirdy.one/webmentions/get?status=approved&target=https://seirdy.one%s" $target -}}
|
||||
{{ $webmentions := getJSON $url -}}
|
||||
{{ range $webmentions -}}
|
||||
{{ $webmention := . -}}
|
||||
<li>
|
||||
<time datetime="{{ dateFormat "2006-01-02 15:04:05Z07:00" $webmention.created_at }}">{{ dateFormat "2006-01-02" $webmention.created_at }}</time>
|
||||
<br>
|
||||
<a href="{{ $webmention.source }}">{{ $webmention.title }}</a>
|
||||
</li>
|
||||
{{ else -}}
|
||||
<li><p>This post doesn't have any approved Webmentions yet.</p></li>
|
||||
{{ end -}}
|
||||
</ul>
|
||||
</section>
|
||||
</footer>
|
||||
</div>
|
||||
<hr>
|
||||
<br>
|
||||
{{ end }}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<h2>Posts</h2>
|
||||
{{ end -}}
|
||||
<p><em>Timestamp format: <code>YYYY-MM-DD</code>, as per <a href="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</a> and <a href="https://xkcd.com/1179/">ISO 8601</a></em></p>
|
||||
<ul class="posts">
|
||||
<ul class="unstyled-list">
|
||||
{{- range where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||
<li>
|
||||
<time datetime="{{ .Date.Format "2006-01-02 15:04:05Z07:00" }}">{{ .Date.Format "2006-01-02" }}</time>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{{ if .Params.footnote_heading -}}
|
||||
{{ $references := `(<section class="footnotes" role="doc-endnotes")` -}}
|
||||
{{ $references := `(<section class="footnotes" role="doc-endnotes">
|
||||
<hr>)` -}}
|
||||
{{ $heading := .Params.footnote_heading -}}
|
||||
{{ $referencesWithHeading := printf `${1} aria-labeledby="note-hd">
|
||||
<h2 id="note-hd">%s</h2` ($heading) -}}
|
||||
{{ $referencesWithHeading := printf `<section class="footnotes" role="doc-endnotes" aria-labeledby="note-hd">
|
||||
<h2 id="note-hd">%s</h2>` ($heading) -}}
|
||||
{{ .Content | replaceRE $references $referencesWithHeading | safeHTML -}}
|
||||
{{ else -}}
|
||||
{{ .Content -}}
|
||||
{{ end -}}
|
||||
|
|
Loading…
Reference in a new issue