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

View File

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