Skip to content

Commit

Permalink
feat: add the search.histories parameter, disable histories if false (
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Feb 20, 2024
1 parent d573309 commit 280694f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions assets/search/js/form.ts
Expand Up @@ -255,6 +255,7 @@ export default class Form {
const taxonomies = this.getTaxonomies()

if (query === '' && Object.values(taxonomies).filter((item) => item.length > 0).length == 0) {
this.renderer.clean()
this.renderer.renderHistories()
return
}
Expand Down
7 changes: 5 additions & 2 deletions assets/search/js/renderer.ts
Expand Up @@ -55,6 +55,7 @@ export default class Renderer {
}

clean() {
this.results = []
this.getContainer().innerHTML = ''
}

Expand Down Expand Up @@ -211,8 +212,10 @@ export default class Renderer {
}

renderHistories() {
this.results = []
this.clean()
if (!params.histories) {
return
}

const histories = Historiographer.get()
let html = ''
histories.forEach((history) => {
Expand Down
1 change: 1 addition & 0 deletions hugo.toml
Expand Up @@ -50,4 +50,5 @@ expand_results_meta = false
lazy_loading = true
filter_taxonomies = true
filter_years = true
histories = true
histories_count = 5
1 change: 1 addition & 0 deletions layouts/partials/search/assets/js-resource.html
Expand Up @@ -90,6 +90,7 @@
"icons" $icons
"indices" $indices
"i18n" $i18n.Values
"histories" (default true site.Params.search.histories)
"historiesCount" (default 5 site.Params.search.histories_count)
"defaultLang" $defaultLang
"langs" $langs.Values
Expand Down

0 comments on commit 280694f

Please sign in to comment.