samhuri.net/lib/pressa/views/year_posts_view.rb
Sami Samhuri e43bb0a71b Add tag tooling: bake tags report and unlinked /tags/ pages
Adds Posts::TagIndex (counts, per-tag posts, per-tag/year breakdown)
and Posts::TagReport, wired into a new `bake tags` task that prints a
frequency table plus a tag-by-year sparkline straight to the terminal.

Also generates /tags/ and /tags/<tag>/ HTML pages via the existing
Posts plugin, listing tags with post counts and per-tag post listings.
Not linked from nav yet -- reachable by URL only until tags are
curated enough to surface properly.

Extracted PostListItemView out of YearPostsView so the post-link
rendering (incl. link posts) is shared with the new tag pages instead
of duplicated.
2026-06-21 20:43:30 -07:00

48 lines
1 KiB
Ruby

require "phlex"
require "pressa/views/post_list_item_view"
module Pressa
module Views
class YearPostsView < Phlex::HTML
def initialize(year:, year_posts:, site:)
@year = year
@year_posts = year_posts
@site = site
end
def view_template
div(class: "container") do
h2(class: "year") do
a(href: year_path) { @year.to_s }
end
@year_posts.sorted_months.each do |month_posts|
render_month(month_posts)
end
end
end
private
def year_path
@site.url_for("/posts/#{@year}/")
end
def render_month(month_posts)
month = month_posts.month
h3(class: "month") do
a(href: @site.url_for("/posts/#{@year}/#{month.padded}/")) do
month.name
end
end
ul(class: "posts") do
month_posts.sorted_posts.each do |post|
render PostListItemView.new(post:)
end
end
end
end
end
end