Test Meta Description
All checks were successful
release-tag / release-image (push) Successful in 2m22s

This commit is contained in:
2025-05-05 20:58:17 +02:00
parent 10172d1fdc
commit 38fa612a18
3 changed files with 20 additions and 14 deletions

View File

@@ -58,10 +58,11 @@ func LoadDir(root string) ([]Article, error) {
} }
var meta struct { var meta struct {
Title string `json:"title"` Title string `json:"title"`
Date string `json:"date"` Date string `json:"date"`
Slug string `json:"slug"` Slug string `json:"slug"`
Cover string `json:"cover"` Cover string `json:"cover"`
Description string `json:"description"`
} }
if err := json.Unmarshal(headerJSON, &meta); err != nil { if err := json.Unmarshal(headerJSON, &meta); err != nil {
return fmt.Errorf("%s: %w", path, err) return fmt.Errorf("%s: %w", path, err)
@@ -87,11 +88,12 @@ func LoadDir(root string) ([]Article, error) {
} }
out = append(out, Article{ out = append(out, Article{
Title: meta.Title, Title: meta.Title,
Slug: meta.Slug, Slug: meta.Slug,
Date: date, Date: date,
Cover: meta.Cover, Cover: meta.Cover,
Body: template.HTML(body), Description: meta.Description,
Body: template.HTML(body),
}) })
return nil return nil
}) })

View File

@@ -7,9 +7,10 @@ import (
) )
type Article struct { type Article struct {
Title string Title string
Slug string Slug string
Date time.Time Date time.Time
Cover string //  NEW Cover string
Body template.HTML // already trusted Body template.HTML
Description string
} }

View File

@@ -4,6 +4,9 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
{{ if .Description }}
<meta name="description" content="{{ .Description }}">
{{ end }}
<title>{{ block "title" . }}B1tsblog{{ end }}</title> <title>{{ block "title" . }}B1tsblog{{ end }}</title>
<link rel="stylesheet" href="/static/main.css"> <link rel="stylesheet" href="/static/main.css">
</head> </head>