1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-24 07:30:12 +01:00

Commit before merging master back in

This commit is contained in:
squidfunk 2019-12-17 09:53:16 +01:00
parent dc86faeb3a
commit 1ee9e74bc7
8 changed files with 111 additions and 85 deletions

8
.env
View File

@ -20,6 +20,14 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # 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 # Activate virtual environment
if [ -f venv/bin/activate ]; then if [ -f venv/bin/activate ]; then
echo "Activating virtual environment" 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

View File

@ -31,7 +31,7 @@
<meta name="author" content="{{ config.site_author }}"> <meta name="author" content="{{ config.site_author }}">
{% endif %} {% endif %}
<link rel="shortcut icon" href="{{ config.theme.favicon | url }}"> <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 %} {% endblock %}
{% block htmltitle %} {% block htmltitle %}
{% if page and page.meta and page.meta.title %} {% if page and page.meta and page.meta.title %}
@ -192,7 +192,7 @@
{% if language == "ja" %} {% if language == "ja" %}
<script src="{{ (path ~ 'tinyseg.js') | url }}"></script> <script src="{{ (path ~ 'tinyseg.js') | url }}"></script>
{% endif %} {% 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> <script src="{{ (path ~ 'lunr.' ~ language ~ '.js') | url }}"></script>
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -13,6 +13,7 @@
"email": "martin.donath@squidfunk.com" "email": "martin.donath@squidfunk.com"
}, },
"license": "MIT", "license": "MIT",
"private": true,
"author": { "author": {
"name": "Martin Donath", "name": "Martin Donath",
"email": "martin.donath@squidfunk.com" "email": "martin.donath@squidfunk.com"
@ -72,6 +73,5 @@
}, },
"engines": { "engines": {
"node": ">= 10" "node": ">= 10"
}, }
"private": true
} }

View File

@ -21,30 +21,35 @@
*/ */
import { identity } from "ramda" import { identity } from "ramda"
import { import {
EMPTY, EMPTY,
MonoTypeOperatorFunction, MonoTypeOperatorFunction,
NEVER, NEVER,
Observable, Observable,
fromEvent, fromEvent,
merge, merge,
of, of,
pipe pipe,
zip
} from "rxjs" } from "rxjs"
import { import {
delay, delay,
filter, filter,
map, map,
shareReplay, pluck,
switchMap, shareReplay,
switchMapTo, switchMap,
tap, switchMapTo,
tap,
withLatestFrom withLatestFrom
} from "rxjs/operators" } from "rxjs/operators"
import { isConfig } from "./config" import { ajax } from "rxjs/ajax"
import { Config, isConfig } from "./config"
import { setupSearch } from "./search"
import { import {
Component, Component,
paintHeaderShadow,
paintHidden, paintHidden,
paintSidebar, paintSidebar,
switchComponent, switchComponent,
@ -57,7 +62,6 @@ import {
watchToggle, watchToggle,
watchTopOffset watchTopOffset
} from "./theme" } from "./theme"
import { paintHeaderShadow } from "./theme/component/header/shadow"
import { import {
watchDocument, watchDocument,
watchDocumentSwitch, watchDocumentSwitch,
@ -124,12 +128,12 @@ export function initialize(config: unknown) {
/* Create document observables */ /* Create document observables */
const load$ = watchDocument() const load$ = watchDocument()
const switch$ = watchDocumentSwitch({ location$ }) // const switch$ = watchDocumentSwitch({ location$ })
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* Create component map observable */ /* Create component map observable */
const components$ = watchComponentMap(names, { load$, switch$ }) const components$ = watchComponentMap(names, { load$ })
const component = (name: Component): Observable<HTMLElement> => { const component = (name: Component): Observable<HTMLElement> => {
return components$ return components$
@ -153,45 +157,45 @@ export function initialize(config: unknown) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// WIP // // WIP: instant loading
load$ // load$
.pipe( // .pipe(
switchMap(({ body }) => fromEvent(body, "click")), // switchMap(({ body }) => fromEvent(body, "click")),
switchMap(ev => { // switchMap(ev => {
if (ev.target instanceof HTMLElement) { // if (ev.target instanceof HTMLElement) {
const el = ev.target.closest("a") || undefined // const el = ev.target.closest("a") || undefined
if (el) { // if (el) {
if (!/^(https?:|#)/.test(el.getAttribute("href")!)) { // if (!/^(https?:|#)/.test(el.getAttribute("href")!)) {
ev.preventDefault() // ev.preventDefault()
} // }
const href = el.href // const href = el.href
history.pushState({}, "", href) // TODO: reference necessary!? // history.pushState({}, "", href) // TODO: reference necessary!?
return of(href) // return of(href)
} // }
} // }
return EMPTY // return EMPTY
}), // })
// try to reduce the jiggle upon instant page load. ideally, the location // // try to reduce the jiggle upon instant page load. ideally, the location
// should directly be resolved and the respective document loaded, but // // should directly be resolved and the respective document loaded, but
// we must scroll to the top at first and wait at least 250ms. // // 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 // // Furthermore, this doesn't include the back/next buttons of the browser
// which must be delayed // // which must be delayed
tap(url => { // // tap(url => {
if (!/#/.test(url)) // // if (!/#/.test(url))
scrollTo({ top: 0 }) // // scrollTo({ top: 0 })
}), // only when loading something we havent loaded! // // }) // only when loading something we havent loaded!
delay(250) // // delay(250)
) // )
.subscribe(location$) // .subscribe(location$)
location$.subscribe(x => { // location$.subscribe(x => {
console.log("L", x) // console.log("L", x)
}) // })
switch$.subscribe(x => { // switch$.subscribe(x => {
console.log("S", x) // console.log("S", x)
}) // })
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
@ -254,23 +258,23 @@ export function initialize(config: unknown) {
) )
.subscribe() .subscribe()
/* Create header title toggle */ // /* Create header title toggle */
component("main") // component("main")
.pipe( // .pipe(
delay(1000), // initial delay // delay(1000), // initial delay
switchMap(el => typeof getElement("h1", el) !== "undefined" // switchMap(el => typeof getElement("h1", el) !== "undefined"
? watchBottomOffset(getElement("h1", el)!, { size$, offset$, header$ }) // ? watchBottomOffset(getElement("h1", el)!, { size$, offset$, header$ })
.pipe( // .pipe(
map(({ y }) => y >= 0), // map(({ y }) => y >= 0),
withLatestFrom(component("title")), // withLatestFrom(component("title")),
tap(([active, title]) => { // tap(([active, title]) => {
title.dataset.mdState = active ? "active" : "" // title.dataset.mdState = active ? "active" : ""
}) // })
) // )
: NEVER // : NEVER
) // )
) // )
.subscribe() // .subscribe()
// TODO: replace title as inner text // TODO: replace title as inner text
@ -319,7 +323,7 @@ export function initialize(config: unknown) {
/* User interface */ /* User interface */
watchDocument: () => load$, watchDocument: () => load$,
watchDocumentSwitch: () => switch$, // watchDocumentSwitch: () => switch$,
watchLocation: () => location$, watchLocation: () => location$,
watchLocationFragment: () => fragment$, watchLocationFragment: () => fragment$,
watchMediaScreen: () => screen$, watchMediaScreen: () => screen$,

View File

@ -63,7 +63,6 @@ export type ComponentMap = {
*/ */
interface Options { interface Options {
load$: Observable<Document> /* Document observable */ load$: Observable<Document> /* Document observable */
switch$: Observable<Document> /* Document switch observable */
} }
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
@ -82,9 +81,9 @@ interface Options {
* @return Component map observable * @return Component map observable
*/ */
export function watchComponentMap( export function watchComponentMap(
names: Component[], { load$, switch$ }: Options names: Component[], { load$ }: Options
): Observable<ComponentMap> { ): Observable<ComponentMap> {
const components$ = merge(load$, switch$) const components$ = load$
.pipe( .pipe(
/* Build component map */ /* Build component map */

View File

@ -22,3 +22,4 @@
export * from "./_" export * from "./_"
export * from "./offset" export * from "./offset"
export * from "./shadow"