変更履歴リンクを追加した

Posted on 4月 16, 2023

右上に「変更履歴」リンクを追加した。現在はArchieというテーマを使用しているので(CSSは一部custom.cssで変更している)、これをフォークしてhead.htmlに下記を追加した。

{{- $githubHistory := $.Site.Params.historyBaseURL }}
{{ with .Page.File }}
    {{- $currentRelPath := .Path -}}
    <a class="change-history" alia-label="See change histories of this page" href="{{ print $githubHistory $currentRelPath }}">変更履歴</a>
{{ else }}
    <a class="change-history" alia-label="See change histories of this page" href="{{ print $githubHistory }}">変更履歴</a>
{{ end }}

各投稿ページではGitHubのそれぞれの変更履歴に飛び、トップページやタグ一覧では全体の変更履歴に飛ぶようになっている。 historyBaseURLconfig.tomlで下記のように定義できる。

[params]
historyBaseURL = "https://github.com/kozmof/kozmof.github.io/commits/main/content/"