8000 Fixed #1877: 404 on search index when search is disabled · squidfunk/mkdocs-material@989b859 · GitHub
[go: up one dir, main page]

Skip to content< 8000 /a>

Commit 989b859

Browse files
committed
Fixed #1877: 404 on search index when search is disabled
1 parent f46334a commit 989b859

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

material/assets/javascripts/bundle.b7ed72fe.min.js renamed to material/assets/javascripts/bundle.a8472eec.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.a8472eec.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.b7ed72fe.min.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

material/assets/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"assets/javascripts/bundle.js": "assets/javascripts/bundle.b7ed72fe.min.js",
3-
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.b7ed72fe.min.js.map",
2+
"assets/javascripts/bundle.js": "assets/javascripts/bundle.a8472eec.min.js",
3+
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.a8472eec.min.js.map",
44
"assets/javascripts/vendor.js": "assets/javascripts/vendor.d1f5a259.min.js",
55
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.d1f5a259.min.js.map",
66
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.fae956e7.min.js",

material/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ <h1>{{ page.title | default(config.site_name, true)}}</h1>
183183
</div>
184184
{% block scripts %}
185185
<script src="{{ 'assets/javascripts/vendor.d1f5a259.min.js' | url }}"></script>
186-
<script src="{{ 'assets/javascripts/bundle.b7ed72fe.min.js' | url }}"></script>
186+
<script src="{{ 'assets/javascripts/bundle.a8472eec.min.js' | url }}"></script>
187187
{%- set translations = {} -%}
188188
{%- for key in [
189189
"clipboard.copy",

src/assets/javascripts/index.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,32 +237,35 @@ export function initialize(config: unknown) {
237237

238238
/* ----------------------------------------------------------------------- */
239239

240-
/* Search worker */
241-
const worker$ = defer(() => {
242-
const index = config.search && config.search.index
243-
? config.search.index
244-
: undefined
245-
246-
/* Fetch index if it wasn't passed explicitly */
247-
const index$ = typeof index !== "undefined"
248-
? from(index)
249-
: base$
250-
.pipe(
251-
switchMap(base => ajax({
252-
url: `${base}/search/search_index.json`,
253-
responseType: "json",
254-
withCredentials: true
255-
})
256-
.pipe<SearchIndex>(
257-
pluck("response")
240+
/* Search worker - only if search is present */
241+
const worker$ = useComponent("search")
242+
.pipe(
243+
switchMap(() => defer(() => {
244+
const index = config.search && config.search.index
245+
? config.search.index
246+
: undefined
247+
248+
/* Fetch index if it wasn't passed explicitly */
249+
const index$ = typeof index !== "undefined"
250+
? from(index)
251+
: base$
252+
.pipe(
253+
switchMap(base => ajax({
254+
url: `${base}/search/search_index.json`,
255+
responseType: "json",
256+
withCredentials: true
257+
})
258+
.pipe<SearchIndex>(
259+
pluck("response")
260+
)
261+
)
258262
)
259-
)
260-
)
261263

262-
return of(setupSearchWorker(config.search.worker, {
263-
base$, index$
264-
}))
265-
})
264+
return of(setupSearchWorker(config.search.worker, {
265+
base$, index$
266+
}))
267+
}))
268+
)
266269

267270
/* ----------------------------------------------------------------------- */
268271

0 commit comments

Comments
 (0)
0