mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-06-25 04:59:11 +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.
32 lines
655 B
Ruby
32 lines
655 B
Ruby
require "phlex"
|
|
|
|
module Pressa
|
|
module Views
|
|
class PostListItemView < Phlex::HTML
|
|
def initialize(post:)
|
|
@post = post
|
|
end
|
|
|
|
def view_template
|
|
if @post.link_post?
|
|
li do
|
|
a(href: @post.link) { "→ #{@post.title}" }
|
|
time { short_date(@post.date) }
|
|
a(class: "permalink", href: @post.path) { "∞" }
|
|
end
|
|
else
|
|
li do
|
|
a(href: @post.path) { @post.title }
|
|
time { short_date(@post.date) }
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def short_date(date)
|
|
date.strftime("%-d %b %Y")
|
|
end
|
|
end
|
|
end
|
|
end
|