Added a database

This commit is contained in:
Leon Mika 2026-02-19 22:29:44 +11:00
parent ebaec3d296
commit 8136655336
35 changed files with 925 additions and 134 deletions

View file

@ -109,7 +109,7 @@ func (b *Builder) renderPost(post *models.Post) (postSingleData, error) {
return postSingleData{
commonData: commonData{Site: b.site},
Path: postPath,
Meta: post,
Post: post,
HTML: template.HTML(md.String()),
}, nil
}

View file

@ -16,7 +16,7 @@ func TestBuilder_BuildSite(t *testing.T) {
t.Run("build site", func(t *testing.T) {
tmpls := fstest.MapFS{
"posts_single.html": {Data: []byte(`{{ .HTML }}`)},
"posts_list.html": {Data: []byte(`{{ range .Posts}}<a href="{{url_abs .Path}}">{{.Meta.Title}}</a>,{{ end }}`)},
"posts_list.html": {Data: []byte(`{{ range .Posts}}<a href="{{url_abs .Path}}">{{.Post.Title}}</a>,{{ end }}`)},
"layout_main.html": {Data: []byte(`{{ .Body }}`)},
}
@ -59,4 +59,4 @@ func TestBuilder_BuildSite(t *testing.T) {
}
})
}
}

View file

@ -38,7 +38,7 @@ type commonData struct {
type postSingleData struct {
commonData
Meta *models.Post
Post *models.Post
HTML template.HTML
Path string
}