feat: add source_url config option for footer source link
Thread source_url through: config.ServerConfig → Handler.sourceURL → PageData.SourceURL → template footer. Footer only shows Source link when source_url is set.
This commit is contained in:
parent
bb0b97820b
commit
805e7ffdc2
6 changed files with 18 additions and 9 deletions
|
|
@ -35,6 +35,7 @@ var staticFS embed.FS
|
|||
|
||||
// PageData holds all data passed to templates.
|
||||
type PageData struct {
|
||||
SourceURL string
|
||||
Query string
|
||||
Pageno int
|
||||
PrevPage int
|
||||
|
|
@ -187,9 +188,9 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int) PageD
|
|||
}
|
||||
|
||||
// RenderIndex renders the homepage (search box only).
|
||||
func RenderIndex(w http.ResponseWriter) error {
|
||||
func RenderIndex(w http.ResponseWriter, sourceURL string) error {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
return tmplIndex.ExecuteTemplate(w, "base", PageData{ShowHeader: true})
|
||||
return tmplIndex.ExecuteTemplate(w, "base", PageData{ShowHeader: true, SourceURL: sourceURL})
|
||||
}
|
||||
|
||||
// RenderSearch renders the full search results page (with base layout).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue