diff --git a/internal/article/load.go b/internal/article/load.go index f6a391c..806efe4 100644 --- a/internal/article/load.go +++ b/internal/article/load.go @@ -58,10 +58,11 @@ func LoadDir(root string) ([]Article, error) { } var meta struct { - Title string `json:"title"` - Date string `json:"date"` - Slug string `json:"slug"` - Cover string `json:"cover"` + Title string `json:"title"` + Date string `json:"date"` + Slug string `json:"slug"` + Cover string `json:"cover"` + Description string `json:"description"` } if err := json.Unmarshal(headerJSON, &meta); err != nil { return fmt.Errorf("%s: %w", path, err) @@ -87,11 +88,12 @@ func LoadDir(root string) ([]Article, error) { } out = append(out, Article{ - Title: meta.Title, - Slug: meta.Slug, - Date: date, - Cover: meta.Cover, - Body: template.HTML(body), + Title: meta.Title, + Slug: meta.Slug, + Date: date, + Cover: meta.Cover, + Description: meta.Description, + Body: template.HTML(body), }) return nil }) diff --git a/internal/article/model.go b/internal/article/model.go index fe00b45..5d6c0f4 100644 --- a/internal/article/model.go +++ b/internal/article/model.go @@ -7,9 +7,10 @@ import ( ) type Article struct { - Title string - Slug string - Date time.Time - Cover string // NEW - Body template.HTML // already trusted + Title string + Slug string + Date time.Time + Cover string + Body template.HTML + Description string } diff --git a/internal/web/templates/base.html b/internal/web/templates/base.html index 418c658..2473526 100644 --- a/internal/web/templates/base.html +++ b/internal/web/templates/base.html @@ -4,6 +4,9 @@
+ {{ if .Description }} + + {{ end }}