Files
dedinit.ru/openspec/changes/archive-by-year-month/design.md
T
2026-09-22 14:13:14 +00:00

53 lines
2.4 KiB
Markdown
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.
# Design: Archive by Year/Month
## Goal
Страница `/posts/` (меню «Архив») показывает посты, сгруппированные по
годам и месяцам (как штатный архив Hugo/PaperMod), вместо плоского списка.
## Approach
Используем готовый layout темы rDedInit: `themes/rDedInit/layouts/_default/archives.html`.
Что он делает (из исходника theme):
- `where site.RegularPages "Type" "in" site.Params.mainSections` — берёт
обычные страницы основных секций (не список, без пагинации).
- `GroupByPublishDate "2006"` — группировка по годам.
- Внутри каждого года `GroupByDate "January"` — группировка по месяцам.
- Заголовки `.archive-year` / `.archive-month`, счётчики, якоря `#2026`,
`#2026-January`.
- Каждая запись — `.archive-entry` с title, post_meta и ссылкой.
Стили `.archive-*` уже есть в `assets/css/common/archive.css`.
## Change: content/posts/_index.md
Создать файл `content/posts/_index.md`:
```yaml
---
title: "Архив"
description: "Все посты блога по годам и месяцам"
layout: archives
---
```
Frontmatter `layout: archives` заставляет Hugo выбрать
`_default/archives.html` для листинга секции (Hugo ищет layout по
порядку: `<type>/<layout>.html`, `_default/<layout>.html` — найдёт
`_default/archives.html`).
Никаких других файлов менять не нужно:
- Меню `[menu.main]` Архив → `/posts/` уже настроено (hugo.toml).
- RSS секции `/posts/` рендерится через `rss.xml` независимо.
- `baseof.html` уже поддерживает `eq .Layout "archives"` для
breadcrumbs/навигации.
- `index.json` (поиск) и `rss.xml` исключают layout `archives` из листинга.
## Verification
1. `make build` (hugo --minify)
2. `grep -c 'archive-year' public/posts/index.html` > 0
3. `grep -c 'archive-month' public/posts/index.html` > 0
4. Убедиться, что title на странице — «Архив», посты сгруппированы по годам
5. `make deploy-dry-run` — SFTP-симуляция (деплой: Gitea Actions)