In search results show URL if title is empty

This commit is contained in:
Justin Hawkins 2025-05-04 11:45:43 +09:30
parent dd681a1099
commit 0dccd9f0f0
2 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package entity
import (
"html/template"
"strings"
"time"
)
@ -19,6 +20,13 @@ func (bm Bookmark) Type() string {
return "bookmark"
}
func (bm Bookmark) DisplayTitle() string {
if strings.TrimSpace(bm.Info.Title) == "" {
return bm.URL
}
return bm.Info.Title
}
type PageInfo struct {
Fetched time.Time
Title string

View File

@ -1,7 +1,7 @@
<ul>
{{ range .results }}
<li>
<a href="{{ .Bookmark.URL }}">{{ .Bookmark.Info.Title }}</a><br>
<a href="{{ .Bookmark.URL }}">{{ .Bookmark.DisplayTitle }}</a><br>
{{ .Highlight }}
</li>
{{ end }}