{{- /* 過去365日分のカレンダーを表示 */ -}} {{- $endDate := now -}} {{- $startDate := $endDate.AddDate 0 0 -364 -}} {{- /* カレンダー用のセクション設定(未設定の場合はmainSectionsを使用) */ -}} {{- $calendarSections := site.Params.calendarSections | default site.Params.mainSections -}} {{- /* 投稿日ごとの記事を集計 */ -}} {{- $postsByDate := dict -}} {{- range where site.RegularPages "Type" "in" $calendarSections -}} {{- $dateStr := .Date.Format "2006-01-02" -}} {{- $posts := slice -}} {{- if isset $postsByDate $dateStr -}} {{- $posts = index $postsByDate $dateStr -}} {{- end -}} {{- $posts = $posts | append . -}} {{- $postsByDate = merge $postsByDate (dict $dateStr $posts) -}} {{- end -}}

Post Activity (Last 365 Days)

{{- /* 曜日ラベル */ -}}
Mon
Wed
Fri
{{- /* 月ラベルとグリッド */ -}}
{{- $currentDate := $startDate -}} {{- $totalDays := 365 -}} {{- /* 最初の週の空白セルを追加 */ -}} {{- $firstWeekday := $startDate.Weekday -}} {{- range seq 0 (sub (int $firstWeekday) 1) -}}
{{- end -}} {{- /* 日付のセルを生成 */ -}} {{- range seq 0 $totalDays -}} {{- $dateStr := $currentDate.Format "2006-01-02" -}} {{- $count := 0 -}} {{- $hasClick := "" -}} {{- if isset $postsByDate $dateStr -}} {{- $posts := index $postsByDate $dateStr -}} {{- $count = len $posts -}} {{- $hasClick = "has-posts" -}} {{- end -}} {{- $level := "level-0" -}} {{- if gt $count 0 -}} {{- if eq $count 1 -}} {{- $level = "level-1" -}} {{- else if eq $count 2 -}} {{- $level = "level-2" -}} {{- else if eq $count 3 -}} {{- $level = "level-3" -}} {{- else -}} {{- $level = "level-4" -}} {{- end -}} {{- end -}}
{{- $currentDate = $currentDate.AddDate 0 0 1 -}} {{- end -}}
Less
More
{{- /* 記事リスト表示エリア */ -}}
{{- /* 記事データをJavaScriptに渡す */ -}}