From a70c866dd0b84d349eac85aa0e89f845b49d8d33 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Mon, 15 Jan 2024 18:12:56 -0600 Subject: [PATCH] additional search tweaks --- assets/js/search.js | 5 ++++- layouts/partials/search-form.html | 2 +- layouts/partials/search-index.html | 1 + layouts/search/list.html | 2 +- static/css/custom.css | 25 +++++++------------------ 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/assets/js/search.js b/assets/js/search.js index b89362e..cf4d850 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -5,7 +5,10 @@ function displayResults (results, store) { for (const n in results) { const item = store[results[n].ref]; resultList += '
  • ' + item.title + '
  • ' - resultList += '

    ' + item.content.substring(0, 150) + '...

    ' + if (item.description) + resultList += '

    ' + item.description + '

    ' + else + resultList += '

    ' + item.content.substring(0, 150) + '...

    ' } searchResults.innerHTML = resultList; } else { diff --git a/layouts/partials/search-form.html b/layouts/partials/search-form.html index 847e55b..d0c1455 100644 --- a/layouts/partials/search-form.html +++ b/layouts/partials/search-form.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/layouts/partials/search-index.html b/layouts/partials/search-index.html index 5415627..4276532 100644 --- a/layouts/partials/search-index.html +++ b/layouts/partials/search-index.html @@ -5,6 +5,7 @@ "title": "{{ .Title }}", "tags": [{{ range .Params.Tags }}"{{ . }}",{{ end }}], "content": {{ .Content | plainify }}, + "description": {{ .Description | plainify }}, "url": "{{ .Permalink }}" }, {{ end }} diff --git a/layouts/search/list.html b/layouts/search/list.html index 82bb25f..3edd248 100644 --- a/layouts/search/list.html +++ b/layouts/search/list.html @@ -1,6 +1,6 @@ {{ define "main" }} {{ partial "search-form.html" . }} - +