From 38fa612a180f34613d98d73073dbe77414ac056b Mon Sep 17 00:00:00 2001 From: jbergner Date: Mon, 5 May 2025 20:58:17 +0200 Subject: [PATCH] Test Meta Description --- internal/article/load.go | 20 +++++++++++--------- internal/article/model.go | 11 ++++++----- internal/web/templates/base.html | 3 +++ 3 files changed, 20 insertions(+), 14 deletions(-) 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 }} {{ block "title" . }}B1tsblog{{ end }}