-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(search): allow complete section customization #799
Conversation
This allows configuring the searchable sections and which sections show the search box. In addition the javascript is only included on pages where the search box is visible.
cdca33b
to
00e4a78
Compare
2868c10
to
8588fe5
Compare
To clarify the intended/expected behavior:
|
For reference if interested, I've got a modified version of this which can exclude individual pages from the index: ---
title: "A Title"
description: "A Description"
lead: ""
date: 2022-03-20T12:52:27+11:00
draft: false
images: []
weight: 600
search:
index: false
--- {{ $list := slice }}
{{- if and (isset .Site.Params.options "searchsectionsindex") (not (eq (len .Site.Params.options.searchSectionsIndex) 0)) }}
{{- if eq .Site.Params.options.searchSectionsIndex "ALL" }}
{{- $list = .Site.Pages }}
{{- else }}
{{- $list = (where (where .Site.Pages "Type" "in" .Site.Params.options.searchSectionsIndex) ".Params.search.index" "!=" "false") }}
{{- if (in .Site.Params.options.searchSectionsIndex "HomePage") }}
{{ $list = $list | append .Site.Home }}
{{- end }}
{{- end }}
{{- else }}
{{- $list = (where .Site.Pages "Section" "docs") }}
{{- end }}
{{ $len := (len $list) -}} |
That certainly is a nice one! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I'd like to go forward w/ Doks v0.5, so I'll merge your work. See also #816
Unfortunately, for my custom, doc-like sections created with commands like "npm run create -- --kind docs [section]" it does not work. Search box visibility works, but actual search in books does not work. Strings "ALL" seems to not work at all. I have section names like "books" and "faq", and no "doks" at all. Name "doks" makes not much sense for my use case. Blog search works.
|
See #395 (comment) |
Summary
This allows configuring the searchable sections and which sections show the search box. In addition the javascript is only included on pages where the search box is visible.
Basic example
Defaults
searchSectionsIndex set to ["docs", "blog"]
searchSectionsShow set to ["docs"]
Motivation
Closes #630
Checks
npm run test
ToDo
searchSectionsShow
/searchSectionsIndex
being undefined (currently causeserror calling len: reflect: call of reflect.Value.Type on zero Value
) fa01f4asearchSectionsShow
ALL
options b532c69