From 0dccd9f0f0cc7682ac98cdd4199f20a377c7d7e7 Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Sun, 4 May 2025 11:45:43 +0930 Subject: [PATCH] In search results show URL if title is empty --- entity/bookmark.go | 8 ++++++++ web/templates/search_results.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/entity/bookmark.go b/entity/bookmark.go index ad05adf..cd15606 100644 --- a/entity/bookmark.go +++ b/entity/bookmark.go @@ -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 diff --git a/web/templates/search_results.html b/web/templates/search_results.html index f52b78f..b68b534 100644 --- a/web/templates/search_results.html +++ b/web/templates/search_results.html @@ -1,7 +1,7 @@