Updated search result styling and preview

This commit is contained in:
walcutt 2023-01-30 15:49:35 -05:00
parent 36b3cb7b8d
commit baffa4ee30
3 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,7 @@ permalink: /search
<input type="text" id="search-input" placeholder="Search blog posts..">
<ul id="results-container"></ul>
<div id="results-container"></div>
<script src="https://unpkg.com/simple-jekyll-search@latest/dest/simple-jekyll-search.min.js"></script>
@ -15,7 +15,8 @@ permalink: /search
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('results-container'),
json:'{{ site.baseurl }}/search.json',
searchResultTemplate: '<li><a href="{url}?query={query}" title="{desc}">{title}</a></li>',
searchResultTemplate: '<div class="search-result-box"><a class="internal-link" href="{url}?query={query}" title="{desc}">{title}</a><br><div class="search-excerpt">{excerpt}</div></div>',
// searchResultTemplate: '<li><a href="{url}?query={query}" title="{desc}">{title}</a></li>',
noResultsText: 'No results found',
limit: 10
});

View File

@ -121,12 +121,16 @@ nav {
}
}
.backlink-box {
.backlink-box, .search-result-box {
background: $color-box-background;
padding: 1em;
border-radius: $border-radius;
}
.search-result-box {
margin-bottom: 1em;
}
code {
background: #f5f5f5;
padding: 0.1em 0.2em;

View File

@ -9,7 +9,8 @@ layout: none
"tags" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.baseurl }}{{ post.url }}",
"date" : "{{ post.date }}",
"content" : "{{ post.content | strip_html | strip_newlines | smartify }}"
"content" : "{{ post.content | strip_html | strip_newlines | smartify }}",
"excerpt" : "{{ post.content | strip_html | strip_newlines | smartify | truncatewords: 10}}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]