Fixed initialization of index for localsearch

This commit is contained in:
squidfunk 2020-03-06 12:02:38 +01:00
parent 184e5f24e2
commit 3a25eb46d4
11 changed files with 21 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
{ {
"assets/javascripts/bundle.js": "assets/javascripts/bundle.d76ca884.min.js", "assets/javascripts/bundle.js": "assets/javascripts/bundle.14729066.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.d76ca884.min.js.map", "assets/javascripts/bundle.js.map": "assets/javascripts/bundle.14729066.min.js.map",
"assets/javascripts/vendor.js": "assets/javascripts/vendor.dd2d8181.min.js", "assets/javascripts/vendor.js": "assets/javascripts/vendor.dd2d8181.min.js",
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.dd2d8181.min.js.map", "assets/javascripts/vendor.js.map": "assets/javascripts/vendor.dd2d8181.min.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.edc88caf.min.js", "assets/javascripts/worker/search.js": "assets/javascripts/worker/search.542c1c70.min.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.edc88caf.min.js.map", "assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.542c1c70.min.js.map",
"assets/stylesheets/main.css": "assets/stylesheets/main.5ac791a0.min.css", "assets/stylesheets/main.css": "assets/stylesheets/main.5ac791a0.min.css",
"assets/stylesheets/palette.css": "assets/stylesheets/palette.f5f04e6f.min.css" "assets/stylesheets/palette.css": "assets/stylesheets/palette.f5f04e6f.min.css"
} }

View File

@ -179,7 +179,7 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/vendor.dd2d8181.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/vendor.dd2d8181.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.d76ca884.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.14729066.min.js' | url }}"></script>
{%- set translations = {} -%} {%- set translations = {} -%}
{%- for key in [ {%- for key in [
"clipboard.copy", "clipboard.copy",
@ -202,7 +202,7 @@
url: { url: {
base: "{{ base_url }}", base: "{{ base_url }}",
worker: { worker: {
search: "{{ 'assets/javascripts/worker/search.edc88caf.min.js' | url }}" search: "{{ 'assets/javascripts/worker/search.542c1c70.min.js' | url }}"
} }
}, },
features: {{ config.theme.features | tojson }} features: {{ config.theme.features | tojson }}

View File

@ -20,15 +20,15 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import { Observable, Subject, from } from "rxjs" import { Observable, Subject, asyncScheduler, from } from "rxjs"
import { ajax } from "rxjs/ajax" import { ajax } from "rxjs/ajax"
import { import {
map, map,
observeOn,
pluck, pluck,
shareReplay, shareReplay,
switchMap, switchMap,
take, take,
tap,
withLatestFrom withLatestFrom
} from "rxjs/operators" } from "rxjs/operators"
@ -151,11 +151,12 @@ export function setupSearchWorker(
// /* Send index to worker */ // /* Send index to worker */
// index$ // index$
.pipe<SearchSetupMessage>( .pipe(
map(data => ({ map((data): SearchSetupMessage => ({
type: SearchMessageType.SETUP, type: SearchMessageType.SETUP,
data data
})) })),
observeOn(asyncScheduler) // make sure it runs on the next tick
) )
.subscribe(tx$.next.bind(tx$)) .subscribe(tx$.next.bind(tx$))

View File

@ -63,7 +63,7 @@ function setupLunrLanguages(config: SearchIndexConfig): void {
/* Load scripts synchronously */ /* Load scripts synchronously */
if (scripts.length) if (scripts.length)
self.importScripts( importScripts(
`${base}/min/lunr.stemmer.support.min.js`, `${base}/min/lunr.stemmer.support.min.js`,
...scripts ...scripts
) )
@ -109,6 +109,6 @@ export function handler(message: SearchMessage): SearchMessage {
* Worker * Worker
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
self.addEventListener("message", ev => { addEventListener("message", ev => {
self.postMessage(handler(ev.data)) postMessage(handler(ev.data))
}) })