mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-30 01:32:39 -04:00
Fixed #1877: 404 on search index when search is disabled
This commit is contained in:
@@ -237,32 +237,35 @@ export function initialize(config: unknown) {
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/* Search worker */
|
||||
const worker$ = defer(() => {
|
||||
const index = config.search && config.search.index
|
||||
? config.search.index
|
||||
: undefined
|
||||
/* Search worker - only if search is present */
|
||||
const worker$ = useComponent("search")
|
||||
.pipe(
|
||||
switchMap(() => defer(() => {
|
||||
const index = config.search && config.search.index
|
||||
? config.search.index
|
||||
: undefined
|
||||
|
||||
/* Fetch index if it wasn't passed explicitly */
|
||||
const index$ = typeof index !== "undefined"
|
||||
? from(index)
|
||||
: base$
|
||||
.pipe(
|
||||
switchMap(base => ajax({
|
||||
url: `${base}/search/search_index.json`,
|
||||
responseType: "json",
|
||||
withCredentials: true
|
||||
})
|
||||
.pipe<SearchIndex>(
|
||||
pluck("response")
|
||||
/* Fetch index if it wasn't passed explicitly */
|
||||
const index$ = typeof index !== "undefined"
|
||||
? from(index)
|
||||
: base$
|
||||
.pipe(
|
||||
switchMap(base => ajax({
|
||||
url: `${base}/search/search_index.json`,
|
||||
responseType: "json",
|
||||
withCredentials: true
|
||||
})
|
||||
.pipe<SearchIndex>(
|
||||
pluck("response")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return of(setupSearchWorker(config.search.worker, {
|
||||
base$, index$
|
||||
}))
|
||||
})
|
||||
return of(setupSearchWorker(config.search.worker, {
|
||||
base$, index$
|
||||
}))
|
||||
}))
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user