プロジェクト内のlayouts
ディレクトリにshortcodes
ディレクトリを作成し、その中にmastodon.html
ファイルを作成する。
mastodon.html
内を以下のように編集する。
layouts/shortcodes/mastodon.html
{{- $newline := .Get "newline" | default "true" -}}
<iframe src="{{ .Get `src` }}/embed" class="mastodon-embed" style="max-width:100%;min-height:200px;border:0" width="400"></iframe>
<script src="https://qiitadon.com/embed.js" async="async"></script>
{{- if eq $newline "true" -}}<br>{{- end -}}
使い方
記事.md
<!-- 埋め込んだパーツのあと改行するとき -->
{{<mastodon src="https://qiitadon.com/@hidao/102765485747500054">}}
<!-- 埋め込んだパーツのあと改行しないとき -->
{{<mastodon src="https://qiitadon.com/@hidao/102765485747500054" newline="false">}}
src
の値にMastodonのtootへのURLを指定する。
あとがき
Hugoとhttps://www.netlify.com/の相性いいですね。