title substitute if no title set

This commit is contained in:
Niko Abeler 2022-11-19 16:02:41 +01:00
parent ecc12333e1
commit 396b84c9bb
2 changed files with 11 additions and 1 deletions

View File

@ -2,7 +2,9 @@
{{range .}} {{range .}}
<div class="h-entry"> <div class="h-entry">
<hgroup> <hgroup>
<h3><a class="u-url" href="{{.UrlPath}}">{{.Title}}</a></h3> <h3><a class="u-url" href="{{.UrlPath}}">
{{ if .Title }}{{.Title}}{{ else }}Note: {{.Id}}{{ end }}
</a></h3>
<small> <small>
Published: Published:
<time class="dt-published" datetime="{{.Meta.Date}}"> <time class="dt-published" datetime="{{.Meta.Date}}">

View File

@ -86,6 +86,14 @@ func TestCanRenderIndexPage(t *testing.T) {
assertions.AssertContains(t, result, "testpost2") assertions.AssertContains(t, result, "testpost2")
} }
func TestCanRenderIndexPageNoTitle(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{}, "hi")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, post.Id())
assertions.AssertContains(t, result, "Note: ")
}
func TestIndexPageContainsHFeedContainer(t *testing.T) { func TestIndexPageContainsHFeedContainer(t *testing.T) {
user := getTestUser() user := getTestUser()
user.CreateNewPost("testpost1", false) user.CreateNewPost("testpost1", false)