Improved graceful handling of broken search when browsing locally

This commit is contained in:
squidfunk 2021-07-10 11:42:38 +02:00
parent 52d773b81b
commit 580f1181f5
5 changed files with 96 additions and 89 deletions

View File

@ -223,7 +223,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.d7b0ad22.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.ddd52ceb.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

@ -55,7 +55,7 @@ export function resetBackToTopState(
* @param el - Back-to-top element
* @param value - Back-to-top offset
*/
export function setBackToTopOffset(
export function setBackToTopOffset(
el: HTMLElement, value: number
): void {
el.style.top = `${value}px`

View File

@ -85,6 +85,7 @@ export function mountSearch(
el: HTMLElement, { index$, keyboard$ }: MountOptions
): Observable<Component<Search>> {
const config = configuration()
try {
const worker = setupSearchWorker(config.search, index$)
/* Retrieve nested components */
@ -177,4 +178,10 @@ export function mountSearch(
query$,
mountSearchResult(result, worker, { query$ })
)
/* Gracefully handle broken search */
} catch (err) {
el.hidden = true
return NEVER
}
}