additional search tweaks

This commit is contained in:
John Bowdre 2024-01-15 18:12:56 -06:00
parent 9223c6ca9e
commit 6da286c017
5 changed files with 14 additions and 21 deletions

View file

@ -5,7 +5,10 @@ function displayResults (results, store) {
for (const n in results) { for (const n in results) {
const item = store[results[n].ref]; const item = store[results[n].ref];
resultList += '<li><a href="' + item.url + '">' + item.title + '</a></li>' resultList += '<li><a href="' + item.url + '">' + item.title + '</a></li>'
resultList += '<p>' + item.content.substring(0, 150) + '...</p>' if (item.description)
resultList += '<p>' + item.description + '</p>'
else
resultList += '<p>' + item.content.substring(0, 150) + '...</p>'
} }
searchResults.innerHTML = resultList; searchResults.innerHTML = resultList;
} else { } else {

View file

@ -1,5 +1,5 @@
<form id="search" <form id="search"
action='{{ with .GetPage "/search" }}{{ .Permalink }}{{ end }}' method="get"> action='{{ with .GetPage "/search" }}{{ .Permalink }}{{ end }}' method="get">
<input type="search" id="search-query" name="query" placeholder="Looking for something?" aria-label="search text"> <input type="input" id="search-query" name="query" placeholder="grep -i" aria-label="search text">
<button type="submit" aria-label="search button"><i class="fa-solid fa-magnifying-glass"></i></button> <button type="submit" aria-label="search button"><i class="fa-solid fa-magnifying-glass"></i></button>
</form> </form>

View file

@ -5,6 +5,7 @@
"title": "{{ .Title }}", "title": "{{ .Title }}",
"tags": [{{ range .Params.Tags }}"{{ . }}",{{ end }}], "tags": [{{ range .Params.Tags }}"{{ . }}",{{ end }}],
"content": {{ .Content | plainify }}, "content": {{ .Content | plainify }},
"description": {{ .Description | plainify }},
"url": "{{ .Permalink }}" "url": "{{ .Permalink }}"
}, },
{{ end }} {{ end }}

View file

@ -1,6 +1,6 @@
{{ define "main" }} {{ define "main" }}
{{ partial "search-form.html" . }} {{ partial "search-form.html" . }}
<br>
<ul id="results"> <ul id="results">
<li> <li>
Enter a keyword above to search this site. Enter a keyword above to search this site.

View file

@ -223,42 +223,31 @@ form {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border-radius: 0.25rem; border-radius: 0.25rem;
margin: 0.25rem; outline: 0.25rem solid var(--bg);
height: 1.5rem;
} }
input { input {
flex-grow: 2; flex-grow: 2;
border: none; border: none;
background-color: var(--off-bg); background-color: var(--off-bg);
/* border-radius: 0.25rem; */
color: var(--off-fg); color: var(--off-fg);
height: 1.5rem;
border-radius: 0.25rem;
padding-left: 0.5rem;
font-family: var(--font-monospace);
} }
input:focus { input:focus {
outline: none; outline: none;
} }
input:placeholder-shown {
font-style: italic;
}
form:focus-within { form:focus-within {
outline: 1px solid var(--logo); outline: 1px solid var(--logo);
/* border-radius: 0.25rem; */
} }
/* form input {
border-radius: 0.25rem;
margin: 0.25rem;
background-color: var(--off-bg);
} */
form button { form button {
/* border-radius: 0.25rem;
margin: 0.25rem; */
outline: none; outline: none;
border: none; border: none;
background-color: var(--off-bg); background-color: var(--off-bg);
color: var(--logo); color: var(--link);
} }