mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-14 10:57:41 +01:00
Fixed invalid outdated version banner URL when using instant loading
This commit is contained in:
parent
1cc250625b
commit
bcc2c180cd
File diff suppressed because one or more lines are too long
8
material/assets/javascripts/bundle.5413a266.min.js.map
Normal file
8
material/assets/javascripts/bundle.5413a266.min.js.map
Normal file
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/stylesheets/main.2d9f7617.min.css
vendored
Normal file
1
material/assets/stylesheets/main.2d9f7617.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/stylesheets/main.2d9f7617.min.css.map
Normal file
1
material/assets/stylesheets/main.2d9f7617.min.css.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.e8d9bf0c.min.css' | url }}">
|
||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.2d9f7617.min.css' | url }}">
|
||||
{% if config.theme.palette %}
|
||||
{% set palette = config.theme.palette %}
|
||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
|
||||
@ -214,7 +214,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.b88e97c5.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.5413a266.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -122,7 +122,7 @@ if (feature("navigation.instant"))
|
||||
|
||||
/* Set up version selector */
|
||||
if (config.version?.provider === "mike")
|
||||
setupVersionSelector()
|
||||
setupVersionSelector({ document$ })
|
||||
|
||||
/* Always close drawer and search on navigation */
|
||||
merge(location$, target$)
|
||||
|
@ -237,6 +237,7 @@ export function setupInstantLoading(
|
||||
"[data-md-component=announce]",
|
||||
"[data-md-component=container]",
|
||||
"[data-md-component=header-topic]",
|
||||
"[data-md-component=outdated]",
|
||||
"[data-md-component=logo]",
|
||||
"[data-md-component=skip]",
|
||||
...feature("navigation.tabs.sticky")
|
||||
|
@ -22,12 +22,14 @@
|
||||
|
||||
import {
|
||||
EMPTY,
|
||||
Subject,
|
||||
combineLatest,
|
||||
filter,
|
||||
fromEvent,
|
||||
map,
|
||||
of,
|
||||
switchMap
|
||||
switchMap,
|
||||
switchMapTo
|
||||
} from "rxjs"
|
||||
|
||||
import { configuration } from "~/_"
|
||||
@ -45,14 +47,29 @@ import {
|
||||
|
||||
import { fetchSitemap } from "../sitemap"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Helper types
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Setup options
|
||||
*/
|
||||
interface SetupOptions {
|
||||
document$: Subject<Document> /* Document subject */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Set up version selector
|
||||
*
|
||||
* @param options - Options
|
||||
*/
|
||||
export function setupVersionSelector(): void {
|
||||
export function setupVersionSelector(
|
||||
{ document$ }: SetupOptions
|
||||
): void {
|
||||
const config = configuration()
|
||||
const versions$ = requestJSON<Version[]>(
|
||||
new URL("../versions.json", config.base)
|
||||
@ -115,17 +132,25 @@ export function setupVersionSelector(): void {
|
||||
.subscribe(([versions, current]) => {
|
||||
const topic = getElement(".md-header__topic")
|
||||
topic.appendChild(renderVersionSelector(versions, current))
|
||||
})
|
||||
|
||||
/* Integrate outdated version banner with instant loading */
|
||||
document$.pipe(switchMapTo(current$))
|
||||
.subscribe(current => {
|
||||
|
||||
/* Check if version state was already determined */
|
||||
if (__md_get("__outdated", sessionStorage) === null) {
|
||||
let outdated = __md_get("__outdated", sessionStorage)
|
||||
if (outdated === null) {
|
||||
const latest = config.version?.default || "latest"
|
||||
const outdated = !current.aliases.includes(latest)
|
||||
outdated = !current.aliases.includes(latest)
|
||||
|
||||
/* Persist version state in session storage */
|
||||
__md_set("__outdated", outdated, sessionStorage)
|
||||
if (outdated)
|
||||
for (const warning of getComponentElements("outdated"))
|
||||
warning.hidden = false
|
||||
}
|
||||
|
||||
/* Unhide outdated version banner */
|
||||
if (outdated)
|
||||
for (const warning of getComponentElements("outdated"))
|
||||
warning.hidden = false
|
||||
})
|
||||
}
|
||||
|
@ -50,4 +50,3 @@
|
||||
<!-- Extra JavaScript (can't be set in mkdocs.yml due to content hash) -->
|
||||
<script src="{{ 'overrides/assets/javascripts/bundle.js' | url }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user