Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.8ffeb9c9.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.1c0198ae.min.js' | url }}"></script>
{% for script in config.extra_javascript %}
{{ script | script_tag }}
{% endfor %}
Expand Down
2 changes: 2 additions & 0 deletions src/assets/javascripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
NEVER,
Observable,
Subject,
catchError,
defer,
delay,
filter,
Expand Down Expand Up @@ -111,6 +112,7 @@ function fetchSearchIndex(): Observable<SearchIndex> {
.pipe(
// @ts-ignore - @todo fix typings
map(() => __index),
catchError(() => NEVER),
shareReplay(1)
)
} else {
Expand Down
50 changes: 30 additions & 20 deletions src/assets/javascripts/components/search/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import css from "../client/index.css"
import { SearchIndex } from "../schema"
import { configuration } from "~/_"
import { h } from "~/utilities"
import { watchToggle } from "~/browser"
import { getElement, watchToggle } from "~/browser"

/* ----------------------------------------------------------------------------
* Types
Expand Down Expand Up @@ -97,27 +97,37 @@ export function mountSearch(
shadow.appendChild(h("style", {}, css.toString()))

// Setup search worker
setup(config.search, {
highlight: config.features.includes("search.highlight")
})
from(index$)
.subscribe(index => {
// Adjust base URLs of items
for (const item of index.items) {
item.location = new URL(item.location, config.base).toString()
}
mount(index, shadow)
try {
setup(config.search, {
highlight: config.features.includes("search.highlight")
})
from(index$)
.subscribe(index => {
// Adjust base URLs of items
for (const item of index.items) {
item.location = new URL(item.location, config.base).toString()
}
mount(index, shadow)
})

// Open search
fromEvent(el, "click").subscribe(() => {
open()
})

// Open search
fromEvent(el, "click").subscribe(() => {
open()
})

// Open search on mobile
watchToggle("search")
.pipe(skip(1))
.subscribe(() => open())
// Open search on mobile
watchToggle("search")
.pipe(skip(1))
.subscribe(() => open())
} catch {
// Search could not be initialized - we're likely offline, and the offline
// plugin has not been included, so we just hide the search
el.hidden = true

// Also hide search button in mobile view
let button = getElement("label[for=__search]")
button.hidden = true
}

// Return nothing
return NEVER
Expand Down
3 changes: 2 additions & 1 deletion src/assets/javascripts/integrations/instant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import {
EMPTY,
NEVER,
Observable,
Subject,
catchError,
Expand Down Expand Up @@ -268,7 +269,7 @@ export function setupInstantNavigation(
{ sitemap$, location$, viewport$, progress$ }: SetupOptions
): Observable<Document> {
if (location.protocol === "file:")
return EMPTY
return NEVER

// Since we might be on a slow connection, the user might trigger multiple
// instant navigation events that overlap. MkDocs produces relative URLs for
Expand Down