LoginSignup
1
1

More than 3 years have passed since last update.

【Hugo】Mastodonのtootを埋め込むshortcode

Last updated at Posted at 2021-04-10

プロジェクト内の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/の相性いいですね。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1