feat: Adds a tag grid at top of articles view.
All checks were successful
CI / release (push) Successful in 6m34s
All checks were successful
CI / release (push) Successful in 6m34s
This commit is contained in:
@@ -2,12 +2,6 @@ import Foundation
|
||||
import HTML
|
||||
import Saga
|
||||
|
||||
func uniqueTagsWithCount(_ articles: [Item<ArticleMetadata>]) -> [(String, Int)] {
|
||||
let tags = articles.flatMap { $0.metadata.tags }
|
||||
let tagsWithCounts = tags.reduce(into: [:]) { $0[$1, default: 0] += 1 }
|
||||
return tagsWithCounts.sorted { $0.1 > $1.1 }
|
||||
}
|
||||
|
||||
func renderArticles(context: ItemsRenderingContext<ArticleMetadata>) -> Node {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy"
|
||||
@@ -16,9 +10,9 @@ func renderArticles(context: ItemsRenderingContext<ArticleMetadata>) -> Node {
|
||||
let sortedByYearDescending = articlesPerYear.sorted { $0.key > $1.key }
|
||||
|
||||
return baseLayout(canocicalURL: "/articles/", section: .articles, title: "Articles", rssLink: "", extraHeader: "") {
|
||||
// TODO: Add list of tags here that can be navigated to.
|
||||
sortedByYearDescending.map { year, articles in
|
||||
div(class: "mt-8 bg-slate-800 rounded-lg") {
|
||||
div(class: "mt-8 mb-10 bg-slate-800 border border-slate-200 rounded-lg") {
|
||||
TagGrid(items: context.items)
|
||||
div(class: "border-b border-light pt-6 w-full") {
|
||||
div(class: "px-6 flex flex-row gap-4 ") {
|
||||
img(src: "/static/img/calendar.svg", width: "40")
|
||||
|
||||
Reference in New Issue
Block a user