Skip to content

Commit bcc2c18

Browse files
committed
Fixed invalid outdated version banner URL when using instant loading
1 parent 1cc2506 commit bcc2c18

File tree

12 files changed

+52
-27
lines changed

12 files changed

+52
-27
lines changed

material/assets/javascripts/bundle.b88e97c5.min.js renamed to material/assets/javascripts/bundle.5413a266.min.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.5413a266.min.js.map

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.b88e97c5.min.js.map

-8
This file was deleted.

material/assets/stylesheets/main.2d9f7617.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.2d9f7617.min.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.e8d9bf0c.min.css

-1
This file was deleted.

material/assets/stylesheets/main.e8d9bf0c.min.css.map

-1
This file was deleted.

material/base.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% endif %}
3535
{% endblock %}
3636
{% block styles %}
37-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.e8d9bf0c.min.css' | url }}">
37+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.2d9f7617.min.css' | url }}">
3838
{% if config.theme.palette %}
3939
{% set palette = config.theme.palette %}
4040
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
@@ -214,7 +214,7 @@
214214
</script>
215215
{% endblock %}
216216
{% block scripts %}
217-
<script src="{{ 'assets/javascripts/bundle.b88e97c5.min.js' | url }}"></script>
217+
<script src="{{ 'assets/javascripts/bundle.5413a266.min.js' | url }}"></script>
218218
{% for path in config["extra_javascript"] %}
219219
<script src="{{ path | url }}"></script>
220220
{% endfor %}

src/assets/javascripts/bundle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ if (feature("navigation.instant"))
122122

123123
/* Set up version selector */
124124
if (config.version?.provider === "mike")
125-
setupVersionSelector()
125+
setupVersionSelector({ document$ })
126126

127127
/* Always close drawer and search on navigation */
128128
merge(location$, target$)

src/assets/javascripts/integrations/instant/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export function setupInstantLoading(
237237
"[data-md-component=announce]",
238238
"[data-md-component=container]",
239239
"[data-md-component=header-topic]",
240+
"[data-md-component=outdated]",
240241
"[data-md-component=logo]",
241242
"[data-md-component=skip]",
242243
...feature("navigation.tabs.sticky")

src/assets/javascripts/integrations/version/index.ts

+32-7
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222

2323
import {
2424
EMPTY,
25+
Subject,
2526
combineLatest,
2627
filter,
2728
fromEvent,
2829
map,
2930
of,
30-
switchMap
31+
switchMap,
32+
switchMapTo
3133
} from "rxjs"
3234

3335
import { configuration } from "~/_"
@@ -45,14 +47,29 @@ import {
4547

4648
import { fetchSitemap } from "../sitemap"
4749

50+
/* ----------------------------------------------------------------------------
51+
* Helper types
52+
* ------------------------------------------------------------------------- */
53+
54+
/**
55+
* Setup options
56+
*/
57+
interface SetupOptions {
58+
document$: Subject<Document> /* Document subject */
59+
}
60+
4861
/* ----------------------------------------------------------------------------
4962
* Functions
5063
* ------------------------------------------------------------------------- */
5164

5265
/**
5366
* Set up version selector
67+
*
68+
* @param options - Options
5469
*/
55-
export function setupVersionSelector(): void {
70+
export function setupVersionSelector(
71+
{ document$ }: SetupOptions
72+
): void {
5673
const config = configuration()
5774
const versions$ = requestJSON<Version[]>(
5875
new URL("../versions.json", config.base)
@@ -115,17 +132,25 @@ export function setupVersionSelector(): void {
115132
.subscribe(([versions, current]) => {
116133
const topic = getElement(".md-header__topic")
117134
topic.appendChild(renderVersionSelector(versions, current))
135+
})
136+
137+
/* Integrate outdated version banner with instant loading */
138+
document$.pipe(switchMapTo(current$))
139+
.subscribe(current => {
118140

119141
/* Check if version state was already determined */
120-
if (__md_get("__outdated", sessionStorage) === null) {
142+
let outdated = __md_get("__outdated", sessionStorage)
143+
if (outdated === null) {
121144
const latest = config.version?.default || "latest"
122-
const outdated = !current.aliases.includes(latest)
145+
outdated = !current.aliases.includes(latest)
123146

124147
/* Persist version state in session storage */
125148
__md_set("__outdated", outdated, sessionStorage)
126-
if (outdated)
127-
for (const warning of getComponentElements("outdated"))
128-
warning.hidden = false
129149
}
150+
151+
/* Unhide outdated version banner */
152+
if (outdated)
153+
for (const warning of getComponentElements("outdated"))
154+
warning.hidden = false
130155
})
131156
}

src/overrides/main.html

-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@
5050
<!-- Extra JavaScript (can't be set in mkdocs.yml due to content hash) -->
5151
<script src="{{ 'overrides/assets/javascripts/bundle.js' | url }}"></script>
5252
{% endblock %}
53-

0 commit comments

Comments
 (0)