simplified some loops, added day2.md to test new footer date functionality

This commit is contained in:
2026-03-10 23:59:17 +00:00
parent 18d151e0cf
commit 4ef81c59bf
8 changed files with 83 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ import (
"embed"
"fmt"
"path/filepath"
"slices"
"sort"
"strings"
"time"
@@ -109,8 +110,8 @@ func parseFrontmatter(content string) (PostMeta, string, error) {
meta.Excerpt = v
case "tags":
if v != "" {
tags := strings.Split(v, ",")
for _, t := range tags {
tags := strings.SplitSeq(v, ",")
for t := range tags {
meta.Tags = append(meta.Tags, strings.TrimSpace(t))
}
}
@@ -307,11 +308,8 @@ func GetPostsByTag(tag string, page, per int) []models.Post {
var filtered []models.Post
for _, post := range posts {
for _, t := range post.Tags {
if t == tag {
filtered = append(filtered, post)
break
}
if slices.Contains(post.Tags, tag) {
filtered = append(filtered, post)
}
}
@@ -336,11 +334,8 @@ func GetTotalPagesByTag(tag string, per int) int {
count := 0
for _, post := range posts {
for _, t := range post.Tags {
if t == tag {
count++
break
}
if slices.Contains(post.Tags, tag) {
count++
}
}