make index tagline & search placeholder customizable

pull/4/head
cblgh 2021-05-11 20:55:07 +02:00
rodzic 17635a513d
commit 6cd59b2f3d
4 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -14,10 +14,10 @@
{{ .SiteName }}
</h1>
<h2>
the search for the new—endless
{{ .Data.Tagline }}
</h2>
<form class="search-container">
<input type="search" required minlength="1" name="q" placeholder="tracking" value="{{ .Data.Query }}" class="search-box">
<input type="search" required minlength="1" name="q" placeholder="{{ .Data.Placeholder }}" class="search-box">
<button type="submit" class="search-button"></button>
</form>
</div>

Wyświetl plik

@ -1,7 +1,7 @@
{{ template "head" . }}
{{ template "nav" . }}
<form method="GET" class="search-container">
<input type="search" minlength="1" required name="q" value="{{ .Data.Query }}" class="search-box">
<input type="search" minlength="1" required name="q" placeholder="Search" value="{{ .Data.Query }}" class="search-box">
<button type="submit" class="search-button"></button>
</form>
<main id="results">

Wyświetl plik

@ -28,6 +28,11 @@ type SearchData struct {
Pages []types.PageData
}
type IndexData struct {
Tagline string
Placeholder string
}
type ListData struct {
Title string
URLs []types.PageData
@ -60,7 +65,7 @@ func (h RequestHandler) searchRoute(res http.ResponseWriter, req *http.Request)
}
if len(query) == 0 {
view.Data = SearchData{}
view.Data = IndexData{Tagline: h.config.General.Tagline, Placeholder: h.config.General.Placeholder}
h.renderView(res, "index", view)
return
}

Wyświetl plik

@ -15,9 +15,11 @@ type PageData struct {
type Config struct {
General struct {
Name string `json:name`
URL string `json:url`
Port int `json:port`
Name string `json:name`
Tagline string `json:tagline`
Placeholder string `json:placeholder`
URL string `json:url`
Port int `json:port`
} `json:general`
Data struct {
Source string `json:source`