Skip to content

Commit

Permalink
Move search result breadcrumbs into heading
Browse files Browse the repository at this point in the history
Previously the breadcrumbs were underneath the heading in a `div` - this
integrates them into the heading and link, bringing the context of each result
more to the fore, and reducing the number of lines each result takes up
  • Loading branch information
yndajas committed Nov 24, 2022
1 parent 1d0c6aa commit 13167be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/_sass/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@
list-style-type: none;
margin-bottom: 2rem;

&-title {
&-heading {
margin: 0 0 1rem;
}

&-breadcrumbs {
margin-bottom: 1rem;
}

&-excerpt {
margin: 0;
Expand Down
6 changes: 3 additions & 3 deletions src/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@

breadcrumbs.pop()

const breadcrumbsString = breadcrumbs.join(' > ')
const breadcrumbsString = breadcrumbs.length ? breadcrumbs.join(' > ') + ' > ' : ''
const heading = breadcrumbsString + item.title
const excerpt = getExcerpt(item.content, searchQuery)

innerHtml +=
'<li class="search-results__result">' +
`<a href="${item.url}">` +
`<h2 class="search-results__result-title">${item.title}</h2>` +
`<h2 class="search-results__result-heading">${heading}</h2>` +
'</a>' +
(breadcrumbs.length ? `<div class="search-results__result-breadcrumbs">${breadcrumbsString}</div>` : '') +
`<p class="search-results__result-excerpt">${excerpt}</p>` +
'</li>'
})
Expand Down

0 comments on commit 13167be

Please sign in to comment.