Files
dedinit.ru/themes/rDedInit/layouts/_default/archives.html
T
estorozhenko 832bb568f5
deploy-dedinit / Build & SFTP Deploy (push) Successful in 5m59s
feat: навигация архива — heatmap год×месяц сверху (sticky) вместо правого сайдбара
- archives.html: sticky-панель над списком, строки-годы × столбцы-месяцы
- квадратики-уровни 0-4 по числу постов (как GitHub), пустые месяцы — заглушки
- якоря месяцев: год-номер (2026-09) вместо кириллицы (ломались URL-encoded)
- archive.css: стили heatmap, переменные --heat-1..4, hover, sticky
- theme-vars.css: --heat-* для светлой/тёмной темы
- zmedia.css: мобильные — панель в колонку с горизонтальной прокруткой
2026-10-04 11:30:02 +00:00

134 lines
4.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{- define "main" }}
<header class="page-header">
<h1>
{{ .Title }}
{{- if (.Param "ShowRssButtonInSectionTermList") }}
{{- $rss := (.OutputFormats.Get "rss") }}
{{- if (eq .Kind `page`) }}
{{- $rss = (.Parent.OutputFormats.Get "rss") }}
{{- end }}
{{- with $rss }}
<a href="{{ .RelPermalink }}" title="RSS" aria-label="RSS">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" height="23">
<path d="M4 11a9 9 0 0 1 9 9" />
<path d="M4 4a16 16 0 0 1 16 16" />
<circle cx="5" cy="19" r="1" />
</svg>
</a>
{{- end }}
{{- end }}
</h1>
{{- if .Description }}
<div class="post-description">
{{ .Description }}
</div>
{{- end }}
</header>
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{- if site.Params.ShowAllPagesInArchive }}
{{- $pages = site.RegularPages }}
{{- end }}
<div class="archive-layout">
{{- /* Heatmap-навигация: строки-годы, столбцы-месяцы (sticky, над списком) */}}
<nav class="archive-nav" aria-label="Навигация по архиву">
<div class="archive-nav-head">
<span class="archive-nav-title">Архив</span>
<span class="archive-nav-hint">год × месяц</span>
</div>
<div class="archive-heatmap" role="grid">
{{- /* Собираем уровни по (год, месяц): индекс 1..12 */}}
{{- $heat := dict }}
{{- range $pages }}
{{- $y := .Date.Format "2006" }}
{{- $m := .Date.Format "1" }}
{{- $key := printf "%s-%s" $y $m }}
{{- $cur := index $heat $key | default 0 }}
{{- $heat = merge $heat (dict $key (add $cur 1)) }}
{{- end }}
{{- $years := slice }}
{{- range $pages.GroupByPublishDate "2006" }}{{ if ne .Key "0001" }}{{ $years = $years | append .Key }}{{ end }}{{ end }}
{{- range $years }}
{{- $y := . }}
<div class="heatmap-row" role="row">
<a class="heatmap-year" href="#{{ $y }}">{{ $y }}</a>
<div class="heatmap-cells">
{{- range $mi := seq 1 12 }}
{{- $key := printf "%s-%d" $y $mi }}
{{- $count := index $heat $key | default 0 }}
{{- $level := 0 }}
{{- if gt $count 0 }}{{ $level = 1 }}{{ end }}
{{- if gt $count 2 }}{{ $level = 2 }}{{ end }}
{{- if gt $count 4 }}{{ $level = 3 }}{{ end }}
{{- if gt $count 7 }}{{ $level = 4 }}{{ end }}
{{- $anchor := printf "%s-%02d" $y $mi }}
{{- if gt $count 0 }}
<a class="heatmap-cell level-{{ $level }}" href="#{{ $anchor }}"
title="{{ $y }}-{{ $mi }}: {{ $count }}" aria-label="{{ $y }}-{{ $mi }}, {{ $count }} постов"></a>
{{- else }}
<span class="heatmap-cell level-0" title="{{ $y }}-{{ $mi }}: нет постов"></span>
{{- end }}
{{- end }}
</div>
</div>
{{- end }}
</div>
</nav>
<div class="archive-posts">
{{- range $pages.GroupByPublishDate "2006" }}
{{- if ne .Key "0001" }}
<div class="archive-year">
{{- $year := replace .Key "0001" "" }}
<h2 class="archive-year-header" id="{{ $year }}">
<a class="archive-header-link" href="#{{ $year }}">
{{- $year -}}
</a>
<sup class="archive-count">&nbsp;{{ len .Pages }}</sup>
</h2>
{{- range .Pages.GroupByDate "January" }}
<div class="archive-month">
{{- $monthID := printf "%s-%02d" $year (index .Pages 0).Date.Month }}
<h3 class="archive-month-header" id="{{ $monthID }}">
<a class="archive-header-link" href="#{{ $monthID }}">
{{- .Key -}}
</a>
<sup class="archive-count">&nbsp;{{ len .Pages }}</sup>
</h3>
<div class="archive-posts">
{{- range .Pages }}
{{- if eq .Kind "page" }}
<div class="archive-entry">
<h3 class="archive-entry-title entry-hint-parent">
{{- .Title | markdownify }}
{{- if .Draft }}
<span class="entry-hint" title="Draft">
<svg xmlns="http://www.w3.org/2000/svg" height="15" viewBox="0 -960 960 960" fill="currentColor">
<path
d="M160-410v-60h300v60H160Zm0-165v-60h470v60H160Zm0-165v-60h470v60H160Zm360 580v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q9 9 13 20t4 22q0 11-4.5 22.5T862.09-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z" />
</svg>
</span>
{{- end }}
</h3>
<div class="archive-meta">
{{- partial "post_meta.html" . -}}
</div>
<a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ .Permalink }}"></a>
</div>
{{- end }}
{{- end }}
</div>
</div>
{{- end }}
</div>
{{- end }}
{{- end }}
</div>
</div>
{{- end }}{{/* end main */}}