mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-06-26 04:59:35 +00:00
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.
48 lines
1 KiB
Ruby
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
|