Added a database
This commit is contained in:
parent
ebaec3d296
commit
8136655336
35 changed files with 925 additions and 134 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ type commonData struct {
|
|||
|
||||
type postSingleData struct {
|
||||
commonData
|
||||
Meta *models.Post
|
||||
Post *models.Post
|
||||
HTML template.HTML
|
||||
Path string
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue