mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Refactored to use URLs at all times
This commit is contained in:
parent
eb82c8d586
commit
c79b786ea6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.16398d48.min.js.map
Normal file
1
material/assets/javascripts/bundle.16398d48.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.14f179c1.min.js",
|
"assets/javascripts/bundle.js": "assets/javascripts/bundle.16398d48.min.js",
|
||||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.14f179c1.min.js.map",
|
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.16398d48.min.js.map",
|
||||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
|
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
|
||||||
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
|
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
|
||||||
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.3f90c815.min.css",
|
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.3f90c815.min.css",
|
||||||
|
@ -190,7 +190,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.14f179c1.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.16398d48.min.js' | url }}"></script>
|
||||||
{%- set translations = {} -%}
|
{%- set translations = {} -%}
|
||||||
{%- for key in [
|
{%- for key in [
|
||||||
"clipboard.copy",
|
"clipboard.copy",
|
||||||
|
@ -58,7 +58,7 @@ interface MountOptions {
|
|||||||
*/
|
*/
|
||||||
export function mountHeaderTitle(
|
export function mountHeaderTitle(
|
||||||
{ header$, viewport$ }: MountOptions
|
{ header$, viewport$ }: MountOptions
|
||||||
): OperatorFunction<HTMLElement, any> {
|
): OperatorFunction<HTMLElement, boolean> {
|
||||||
return pipe(
|
return pipe(
|
||||||
switchMap(el => useComponent("main")
|
switchMap(el => useComponent("main")
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@ -59,7 +59,6 @@ import {
|
|||||||
watchToggle,
|
watchToggle,
|
||||||
setToggle,
|
setToggle,
|
||||||
getElements,
|
getElements,
|
||||||
getLocation,
|
|
||||||
watchMedia,
|
watchMedia,
|
||||||
watchDocument,
|
watchDocument,
|
||||||
watchLocation,
|
watchLocation,
|
||||||
@ -213,7 +212,7 @@ export function initialize(config: unknown) {
|
|||||||
const navigation$ = useComponent("navigation")
|
const navigation$ = useComponent("navigation")
|
||||||
.pipe(
|
.pipe(
|
||||||
mountNavigation({ header$, main$, viewport$, screen$ }),
|
mountNavigation({ header$, main$, viewport$, screen$ }),
|
||||||
shareReplay(1)
|
shareReplay(1) // shareReplay because there might be late subscribers
|
||||||
)
|
)
|
||||||
|
|
||||||
const toc$ = useComponent("toc")
|
const toc$ = useComponent("toc")
|
||||||
@ -260,7 +259,8 @@ export function initialize(config: unknown) {
|
|||||||
|
|
||||||
// Close drawer and search on hash change
|
// Close drawer and search on hash change
|
||||||
// put into navigation...
|
// put into navigation...
|
||||||
hash$.subscribe(x => {
|
// TODO: replace with popstate?
|
||||||
|
hash$.subscribe(() => {
|
||||||
useToggle("drawer").subscribe(el => {
|
useToggle("drawer").subscribe(el => {
|
||||||
setToggle(el, false)
|
setToggle(el, false)
|
||||||
})
|
})
|
||||||
|
@ -68,7 +68,7 @@ export function watchDocumentSwitch(
|
|||||||
): Observable<Document> {
|
): Observable<Document> {
|
||||||
return location$
|
return location$
|
||||||
.pipe(
|
.pipe(
|
||||||
startWith(location), // TODO: getLocation should return URL or Location
|
startWith(getLocation()),
|
||||||
distinctUntilKeyChanged("pathname"),
|
distinctUntilKeyChanged("pathname"),
|
||||||
skip(1),
|
skip(1),
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export function watchDocumentSwitch(
|
|||||||
.pipe<Document, Document>(
|
.pipe<Document, Document>(
|
||||||
pluck("response"),
|
pluck("response"),
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
setLocation(url.href) // TODO: setLocation should accept URL or location
|
setLocation(url)
|
||||||
return NEVER
|
return NEVER
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Subject, fromEvent } from "rxjs"
|
import { Subject } from "rxjs"
|
||||||
import { map } from "rxjs/operators"
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Functions
|
* Functions
|
||||||
@ -30,19 +29,24 @@ import { map } from "rxjs/operators"
|
|||||||
/**
|
/**
|
||||||
* Retrieve location
|
* Retrieve location
|
||||||
*
|
*
|
||||||
* @return Location
|
* This function will return a `URL` object (and not `Location`) in order to
|
||||||
|
* normalize typings across the application. Furthermore, locations need to be
|
||||||
|
* tracked without setting them and `Location` is a singleton which represents
|
||||||
|
* the current location.
|
||||||
|
*
|
||||||
|
* @return URL
|
||||||
*/
|
*/
|
||||||
export function getLocation(): string {
|
export function getLocation(): URL {
|
||||||
return location.href
|
return new URL(location.href)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set location
|
* Set location
|
||||||
*
|
*
|
||||||
* @param value - New location
|
* @param url - URL to change to
|
||||||
*/
|
*/
|
||||||
export function setLocation(value: string): void {
|
export function setLocation(url: URL): void {
|
||||||
location.href = value
|
location.href = url.href
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
@ -53,13 +57,5 @@ export function setLocation(value: string): void {
|
|||||||
* @return Location subject
|
* @return Location subject
|
||||||
*/
|
*/
|
||||||
export function watchLocation(): Subject<URL> {
|
export function watchLocation(): Subject<URL> {
|
||||||
const location$ = new Subject<URL>()
|
return new Subject<URL>()
|
||||||
// fromEvent<PopStateEvent>(window, "popstate")
|
|
||||||
// .pipe(
|
|
||||||
// map(getLocation)
|
|
||||||
// )
|
|
||||||
// .subscribe(location$)
|
|
||||||
|
|
||||||
/* Return location subject */
|
|
||||||
return location$
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user