mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Commit before merging master back in
This commit is contained in:
parent
dc86faeb3a
commit
1ee9e74bc7
8
.env
8
.env
@ -20,6 +20,14 @@
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
# Setup virtual environment
|
||||
if [ ! -d venv ]; then
|
||||
echo "Setting up virtual environment"
|
||||
virtualenv venv
|
||||
echo "Installing dependencies"
|
||||
pip install -r requirements.txt
|
||||
fi
|
||||
|
||||
# Activate virtual environment
|
||||
if [ -f venv/bin/activate ]; then
|
||||
echo "Activating virtual environment"
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -31,7 +31,7 @@
|
||||
<meta name="author" content="{{ config.site_author }}">
|
||||
{% endif %}
|
||||
<link rel="shortcut icon" href="{{ config.theme.favicon | url }}">
|
||||
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, $md-name$-$md-version$">
|
||||
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-material-4.4.2">
|
||||
{% endblock %}
|
||||
{% block htmltitle %}
|
||||
{% if page and page.meta and page.meta.title %}
|
||||
@ -192,7 +192,7 @@
|
||||
{% if language == "ja" %}
|
||||
<script src="{{ (path ~ 'tinyseg.js') | url }}"></script>
|
||||
{% endif %}
|
||||
{% if language in ($md-lunr-languages$) %}
|
||||
{% if language in ("da","de","du","es","fi","fr","hu","it","ja","jp","nl","no","pt","ro","ru","sv","tr") %}
|
||||
<script src="{{ (path ~ 'lunr.' ~ language ~ '.js') | url }}"></script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -13,6 +13,7 @@
|
||||
"email": "martin.donath@squidfunk.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"author": {
|
||||
"name": "Martin Donath",
|
||||
"email": "martin.donath@squidfunk.com"
|
||||
@ -72,6 +73,5 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
}
|
||||
|
@ -21,30 +21,35 @@
|
||||
*/
|
||||
|
||||
import { identity } from "ramda"
|
||||
import {
|
||||
EMPTY,
|
||||
MonoTypeOperatorFunction,
|
||||
NEVER,
|
||||
Observable,
|
||||
fromEvent,
|
||||
merge,
|
||||
of,
|
||||
pipe
|
||||
import {
|
||||
EMPTY,
|
||||
MonoTypeOperatorFunction,
|
||||
NEVER,
|
||||
Observable,
|
||||
fromEvent,
|
||||
merge,
|
||||
of,
|
||||
pipe,
|
||||
zip
|
||||
} from "rxjs"
|
||||
import {
|
||||
delay,
|
||||
filter,
|
||||
map,
|
||||
shareReplay,
|
||||
switchMap,
|
||||
switchMapTo,
|
||||
tap,
|
||||
import {
|
||||
delay,
|
||||
filter,
|
||||
map,
|
||||
pluck,
|
||||
shareReplay,
|
||||
switchMap,
|
||||
switchMapTo,
|
||||
tap,
|
||||
withLatestFrom
|
||||
} from "rxjs/operators"
|
||||
|
||||
import { isConfig } from "./config"
|
||||
import { ajax } from "rxjs/ajax"
|
||||
import { Config, isConfig } from "./config"
|
||||
import { setupSearch } from "./search"
|
||||
import {
|
||||
Component,
|
||||
paintHeaderShadow,
|
||||
paintHidden,
|
||||
paintSidebar,
|
||||
switchComponent,
|
||||
@ -57,7 +62,6 @@ import {
|
||||
watchToggle,
|
||||
watchTopOffset
|
||||
} from "./theme"
|
||||
import { paintHeaderShadow } from "./theme/component/header/shadow"
|
||||
import {
|
||||
watchDocument,
|
||||
watchDocumentSwitch,
|
||||
@ -124,12 +128,12 @@ export function initialize(config: unknown) {
|
||||
|
||||
/* Create document observables */
|
||||
const load$ = watchDocument()
|
||||
const switch$ = watchDocumentSwitch({ location$ })
|
||||
// const switch$ = watchDocumentSwitch({ location$ })
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/* Create component map observable */
|
||||
const components$ = watchComponentMap(names, { load$, switch$ })
|
||||
const components$ = watchComponentMap(names, { load$ })
|
||||
|
||||
const component = (name: Component): Observable<HTMLElement> => {
|
||||
return components$
|
||||
@ -153,45 +157,45 @@ export function initialize(config: unknown) {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// WIP
|
||||
load$
|
||||
.pipe(
|
||||
switchMap(({ body }) => fromEvent(body, "click")),
|
||||
switchMap(ev => {
|
||||
if (ev.target instanceof HTMLElement) {
|
||||
const el = ev.target.closest("a") || undefined
|
||||
if (el) {
|
||||
if (!/^(https?:|#)/.test(el.getAttribute("href")!)) {
|
||||
ev.preventDefault()
|
||||
}
|
||||
const href = el.href
|
||||
history.pushState({}, "", href) // TODO: reference necessary!?
|
||||
return of(href)
|
||||
}
|
||||
}
|
||||
return EMPTY
|
||||
}),
|
||||
// // WIP: instant loading
|
||||
// load$
|
||||
// .pipe(
|
||||
// switchMap(({ body }) => fromEvent(body, "click")),
|
||||
// switchMap(ev => {
|
||||
// if (ev.target instanceof HTMLElement) {
|
||||
// const el = ev.target.closest("a") || undefined
|
||||
// if (el) {
|
||||
// if (!/^(https?:|#)/.test(el.getAttribute("href")!)) {
|
||||
// ev.preventDefault()
|
||||
// }
|
||||
// const href = el.href
|
||||
// history.pushState({}, "", href) // TODO: reference necessary!?
|
||||
// return of(href)
|
||||
// }
|
||||
// }
|
||||
// return EMPTY
|
||||
// })
|
||||
|
||||
// try to reduce the jiggle upon instant page load. ideally, the location
|
||||
// should directly be resolved and the respective document loaded, but
|
||||
// we must scroll to the top at first and wait at least 250ms.
|
||||
//
|
||||
// Furthermore, this doesn't include the back/next buttons of the browser
|
||||
// which must be delayed
|
||||
tap(url => {
|
||||
if (!/#/.test(url))
|
||||
scrollTo({ top: 0 })
|
||||
}), // only when loading something we havent loaded!
|
||||
delay(250)
|
||||
)
|
||||
.subscribe(location$)
|
||||
// // try to reduce the jiggle upon instant page load. ideally, the location
|
||||
// // should directly be resolved and the respective document loaded, but
|
||||
// // we must scroll to the top at first and wait at least 250ms.
|
||||
// //
|
||||
// // Furthermore, this doesn't include the back/next buttons of the browser
|
||||
// // which must be delayed
|
||||
// // tap(url => {
|
||||
// // if (!/#/.test(url))
|
||||
// // scrollTo({ top: 0 })
|
||||
// // }) // only when loading something we havent loaded!
|
||||
// // delay(250)
|
||||
// )
|
||||
// .subscribe(location$)
|
||||
|
||||
location$.subscribe(x => {
|
||||
console.log("L", x)
|
||||
})
|
||||
switch$.subscribe(x => {
|
||||
console.log("S", x)
|
||||
})
|
||||
// location$.subscribe(x => {
|
||||
// console.log("L", x)
|
||||
// })
|
||||
// switch$.subscribe(x => {
|
||||
// console.log("S", x)
|
||||
// })
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
@ -254,23 +258,23 @@ export function initialize(config: unknown) {
|
||||
)
|
||||
.subscribe()
|
||||
|
||||
/* Create header title toggle */
|
||||
component("main")
|
||||
.pipe(
|
||||
delay(1000), // initial delay
|
||||
switchMap(el => typeof getElement("h1", el) !== "undefined"
|
||||
? watchBottomOffset(getElement("h1", el)!, { size$, offset$, header$ })
|
||||
.pipe(
|
||||
map(({ y }) => y >= 0),
|
||||
withLatestFrom(component("title")),
|
||||
tap(([active, title]) => {
|
||||
title.dataset.mdState = active ? "active" : ""
|
||||
})
|
||||
)
|
||||
: NEVER
|
||||
)
|
||||
)
|
||||
.subscribe()
|
||||
// /* Create header title toggle */
|
||||
// component("main")
|
||||
// .pipe(
|
||||
// delay(1000), // initial delay
|
||||
// switchMap(el => typeof getElement("h1", el) !== "undefined"
|
||||
// ? watchBottomOffset(getElement("h1", el)!, { size$, offset$, header$ })
|
||||
// .pipe(
|
||||
// map(({ y }) => y >= 0),
|
||||
// withLatestFrom(component("title")),
|
||||
// tap(([active, title]) => {
|
||||
// title.dataset.mdState = active ? "active" : ""
|
||||
// })
|
||||
// )
|
||||
// : NEVER
|
||||
// )
|
||||
// )
|
||||
// .subscribe()
|
||||
|
||||
// TODO: replace title as inner text
|
||||
|
||||
@ -319,7 +323,7 @@ export function initialize(config: unknown) {
|
||||
|
||||
/* User interface */
|
||||
watchDocument: () => load$,
|
||||
watchDocumentSwitch: () => switch$,
|
||||
// watchDocumentSwitch: () => switch$,
|
||||
watchLocation: () => location$,
|
||||
watchLocationFragment: () => fragment$,
|
||||
watchMediaScreen: () => screen$,
|
||||
|
@ -63,7 +63,6 @@ export type ComponentMap = {
|
||||
*/
|
||||
interface Options {
|
||||
load$: Observable<Document> /* Document observable */
|
||||
switch$: Observable<Document> /* Document switch observable */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
@ -82,9 +81,9 @@ interface Options {
|
||||
* @return Component map observable
|
||||
*/
|
||||
export function watchComponentMap(
|
||||
names: Component[], { load$, switch$ }: Options
|
||||
names: Component[], { load$ }: Options
|
||||
): Observable<ComponentMap> {
|
||||
const components$ = merge(load$, switch$)
|
||||
const components$ = load$
|
||||
.pipe(
|
||||
|
||||
/* Build component map */
|
||||
|
@ -22,3 +22,4 @@
|
||||
|
||||
export * from "./_"
|
||||
export * from "./offset"
|
||||
export * from "./shadow"
|
||||
|
Loading…
Reference in New Issue
Block a user