mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Cleaned up main entrypoint
This commit is contained in:
parent
aa74dc4d41
commit
0f77194c23
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
9
material/assets/javascripts/bundle.d443780c.min.js
vendored
Normal file
9
material/assets/javascripts/bundle.d443780c.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.d443780c.min.js.map
Normal file
1
material/assets/javascripts/bundle.d443780c.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.419ace03.min.js",
|
||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.419ace03.min.js.map",
|
||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.d443780c.min.js",
|
||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.d443780c.min.js.map",
|
||||
"assets/javascripts/worker/packer.js": "assets/javascripts/worker/packer.c14659e8.min.js",
|
||||
"assets/javascripts/worker/packer.js.map": "assets/javascripts/worker/packer.c14659e8.min.js.map",
|
||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.07456dbc.min.js",
|
||||
|
@ -190,7 +190,7 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.419ace03.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.d443780c.min.js' | url }}"></script>
|
||||
<script id="__lang" type="application/json">
|
||||
{%- set translations = {} -%}
|
||||
{%- for key in [
|
||||
|
@ -80,9 +80,7 @@ import { mountClipboard } from "./integrations/clipboard"
|
||||
import { patchTables, patchDetails } from "patches"
|
||||
import { takeIf, not, isConfig } from "utilities"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* TODO: where do we put this stuff?
|
||||
* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
document.documentElement.classList.remove("no-js")
|
||||
document.documentElement.classList.add("js")
|
||||
@ -91,25 +89,7 @@ document.documentElement.classList.add("js")
|
||||
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g))
|
||||
document.documentElement.classList.add("ios")
|
||||
|
||||
// add to config? default components to mount...?
|
||||
const names: Component[] = [
|
||||
"container", /* Container */
|
||||
"header", /* Header */
|
||||
"header-title", /* Header title */
|
||||
"hero", /* Hero */
|
||||
"main", /* Main area */
|
||||
"navigation", /* Navigation */
|
||||
"search", /* Search */
|
||||
"search-query", /* Search input */
|
||||
"search-reset", /* Search reset */
|
||||
"search-result", /* Search results */
|
||||
"tabs", /* Tabs */
|
||||
"toc" /* Table of contents */
|
||||
]
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Helper functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Yes, this is a super hacky implementation. Needs clean up.
|
||||
@ -191,8 +171,30 @@ export function initialize(config: unknown) {
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
watchComponentMap(names, { document$ })
|
||||
watchToggleMap(["drawer", "search"], { document$ })
|
||||
const worker = setupSearchWorker(config.worker.search, {
|
||||
base: config.base
|
||||
})
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
watchToggleMap([
|
||||
"drawer", /* Toggle for drawer */
|
||||
"search" /* Toggle for search */
|
||||
], { document$ })
|
||||
watchComponentMap([
|
||||
"container", /* Container */
|
||||
"header", /* Header */
|
||||
"header-title", /* Header title */
|
||||
"hero", /* Hero */
|
||||
"main", /* Main area */
|
||||
"navigation", /* Navigation */
|
||||
"search", /* Search */
|
||||
"search-query", /* Search input */
|
||||
"search-reset", /* Search reset */
|
||||
"search-result", /* Search results */
|
||||
"tabs", /* Tabs */
|
||||
"toc" /* Table of contents */
|
||||
], { document$ })
|
||||
|
||||
/* Create header observable */
|
||||
const header$ = useComponent("header")
|
||||
@ -207,17 +209,11 @@ export function initialize(config: unknown) {
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
const sw = setupSearchWorker(config.worker.search, {
|
||||
base: config.base
|
||||
})
|
||||
|
||||
const search$ = useComponent("search")
|
||||
.pipe(
|
||||
mountSearch(sw, { viewport$, keyboard$ }),
|
||||
mountSearch(worker, { viewport$, keyboard$ }),
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
const navigation$ = useComponent("navigation")
|
||||
.pipe(
|
||||
mountNavigation({ main$, viewport$, screen$ })
|
||||
|
@ -71,7 +71,7 @@ export function mayReceiveKeyboardEvents(el: HTMLElement) {
|
||||
export function watchKeyboard(): Observable<Key> {
|
||||
return fromEvent<KeyboardEvent>(window, "keydown")
|
||||
.pipe(
|
||||
filter(ev => !(ev.shiftKey || ev.metaKey || ev.ctrlKey)),
|
||||
filter(ev => !(ev.metaKey || ev.ctrlKey)),
|
||||
map(ev => ({
|
||||
type: ev.key,
|
||||
claim() {
|
||||
|
Loading…
Reference in New Issue
Block a user