Formatting + moved search index fetching to top level

This commit is contained in:
squidfunk
2021-02-24 18:02:09 +01:00
parent cb723d4bef
commit d6317dc514
69 changed files with 404 additions and 328 deletions

View File

@@ -31,10 +31,11 @@ import {
switchMap
} from "rxjs/operators"
import { feature } from "./_"
import { configuration, feature } from "./_"
import {
at,
getElement,
requestJSON,
setToggle,
watchDocument,
watchKeyboard,
@@ -60,6 +61,7 @@ import {
watchMain
} from "./components"
import {
SearchIndex,
setupClipboardJS,
setupInstantLoading
} from "./integrations"
@@ -89,6 +91,12 @@ const tablet$ = watchMedia("(min-width: 960px)")
const screen$ = watchMedia("(min-width: 1220px)")
const print$ = watchPrint()
/* Retrieve search index */
const config = configuration()
const index$ = __search?.index || requestJSON<SearchIndex>(
`${config.base}/search/search_index.json`
)
/* Set up Clipboard.js integration */
const alert$ = new Subject<string>()
setupClipboardJS({ alert$ })
@@ -160,11 +168,11 @@ const control$ = merge(
/* Search */
...getComponentElements("search")
.map(el => mountSearch(el, { keyboard$ })),
.map(el => mountSearch(el, { index$, keyboard$ })),
/* Repository information */
...getComponentElements("source")
.map(el => mountSource(el as HTMLAnchorElement)),
.map(el => mountSource(el)),
/* Navigation tabs */
...getComponentElements("tabs")