mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed regression with header title not being updated correctly
This commit is contained in:
parent
526fbed394
commit
d17c488b49
32
material/assets/javascripts/bundle.8c3a7438.min.js
vendored
Normal file
32
material/assets/javascripts/bundle.8c3a7438.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
material/assets/javascripts/bundle.8c3a7438.min.js.map
Normal file
7
material/assets/javascripts/bundle.8c3a7438.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -217,7 +217,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.35272152.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.8c3a7438.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -63,7 +63,8 @@ import {
|
||||
import {
|
||||
SearchIndex,
|
||||
setupClipboardJS,
|
||||
setupInstantLoading
|
||||
setupInstantLoading,
|
||||
setupVersionSelector
|
||||
} from "./integrations"
|
||||
import {
|
||||
patchIndeterminate,
|
||||
@ -107,6 +108,10 @@ setupClipboardJS({ alert$ })
|
||||
if (feature("navigation.instant"))
|
||||
setupInstantLoading({ document$, location$, viewport$ })
|
||||
|
||||
/* Set up version selector */
|
||||
if (config.version?.provider === "mike")
|
||||
setupVersionSelector()
|
||||
|
||||
/* Always close drawer and search on navigation */
|
||||
merge(location$, target$)
|
||||
.pipe(
|
||||
@ -168,10 +173,6 @@ const control$ = merge(
|
||||
...getComponentElements("header")
|
||||
.map(el => mountHeader(el, { viewport$, header$, main$ })),
|
||||
|
||||
/* Header title */
|
||||
...getComponentElements("header-title")
|
||||
.map(el => mountHeaderTitle(el, { viewport$, header$ })),
|
||||
|
||||
/* Search */
|
||||
...getComponentElements("search")
|
||||
.map(el => mountSearch(el, { index$, keyboard$ })),
|
||||
@ -192,6 +193,10 @@ const content$ = defer(() => merge(
|
||||
...getComponentElements("content")
|
||||
.map(el => mountContent(el, { target$, viewport$, print$ })),
|
||||
|
||||
/* Header title */
|
||||
...getComponentElements("header-title")
|
||||
.map(el => mountHeaderTitle(el, { viewport$, header$ })),
|
||||
|
||||
/* Sidebar */
|
||||
...getComponentElements("sidebar")
|
||||
.map(el => el.getAttribute("data-md-type") === "navigation"
|
||||
|
@ -34,7 +34,6 @@ import {
|
||||
tap
|
||||
} from "rxjs/operators"
|
||||
|
||||
import { configuration } from "~/_"
|
||||
import {
|
||||
resetHeaderTitleState,
|
||||
setHeaderTitleState
|
||||
@ -42,15 +41,9 @@ import {
|
||||
import {
|
||||
Viewport,
|
||||
getElement,
|
||||
getElementOrThrow,
|
||||
getElementSize,
|
||||
requestJSON,
|
||||
watchViewportAt
|
||||
} from "~/browser"
|
||||
import {
|
||||
Version,
|
||||
renderVersionSelector
|
||||
} from "~/templates"
|
||||
|
||||
import { Component } from "../../_"
|
||||
import { Header } from "../_"
|
||||
@ -130,7 +123,7 @@ export function mountHeaderTitle(
|
||||
const internal$ = new Subject<HeaderTitle>()
|
||||
internal$
|
||||
.pipe(
|
||||
observeOn(animationFrameScheduler),
|
||||
observeOn(animationFrameScheduler)
|
||||
)
|
||||
.subscribe(({ active }) => {
|
||||
if (active)
|
||||
@ -139,15 +132,6 @@ export function mountHeaderTitle(
|
||||
resetHeaderTitleState(el)
|
||||
})
|
||||
|
||||
/* Render version selector */
|
||||
const config = configuration()
|
||||
if (config.version?.provider === "mike")
|
||||
requestJSON<Version[]>(new URL("versions.json", config.base))
|
||||
.subscribe(versions => {
|
||||
const topic = getElementOrThrow(".md-header__topic", el)
|
||||
topic.appendChild(renderVersionSelector(versions))
|
||||
})
|
||||
|
||||
/* Obtain headline, if any */
|
||||
const headline = getElement<HTMLHeadingElement>("article h1")
|
||||
if (typeof headline === "undefined")
|
||||
|
@ -23,3 +23,4 @@
|
||||
export * from "./clipboard"
|
||||
export * from "./instant"
|
||||
export * from "./search"
|
||||
export * from "./version"
|
||||
|
41
src/assets/javascripts/integrations/version/index.ts
Normal file
41
src/assets/javascripts/integrations/version/index.ts
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2021 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { configuration } from "~/_"
|
||||
import { getElementOrThrow, requestJSON } from "~/browser"
|
||||
import { Version, renderVersionSelector } from "~/templates"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Set up version selector
|
||||
*/
|
||||
export function setupVersionSelector(): void {
|
||||
const config = configuration()
|
||||
requestJSON<Version[]>(new URL("versions.json", config.base))
|
||||
.subscribe(versions => {
|
||||
const topic = getElementOrThrow(".md-header__topic")
|
||||
topic.appendChild(renderVersionSelector(versions))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user