Skip to content

Commit b257235

Browse files
Added support for hiding version warning in multiple versions
Co-authored-by: SaltyAimbOtter <[email protected]>
1 parent 981ee65 commit b257235

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

docs/setup/setting-up-versioning.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,25 @@ to `mkdocs.yml`:
9393
``` yaml
9494
extra:
9595
version:
96-
default: stable
96+
default: stable # (1)!
9797
```
9898

99-
Make sure that this matches the [default version].
99+
1. You can also define multiple aliases as the default version, e.g. `stable`
100+
and `development`.
101+
102+
``` yaml
103+
extra:
104+
version:
105+
default:
106+
- stable
107+
- development
108+
```
109+
110+
Now every version that has the `stable` and `development` aliases will not
111+
display the version warning.
112+
113+
Make sure one alias matches the [default version], as this is where users are
114+
redirected to.
100115

101116
[Version warning support]: https://github.com/squidfunk/mkdocs-material/releases/tag/8.0.0
102117
[theme extension]: ../customization.md#extending-the-theme

material/assets/javascripts/bundle.055143c9.min.js renamed to material/assets/javascripts/bundle.2a6f1dda.min.js

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

material/assets/javascripts/bundle.055143c9.min.js.map renamed to material/assets/javascripts/bundle.2a6f1dda.min.js.map

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

material/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
</script>
241241
{% endblock %}
242242
{% block scripts %}
243-
<script src="{{ 'assets/javascripts/bundle.055143c9.min.js' | url }}"></script>
243+
<script src="{{ 'assets/javascripts/bundle.2a6f1dda.min.js' | url }}"></script>
244244
{% for path in config.extra_javascript %}
245245
<script src="{{ path | url }}"></script>
246246
{% endfor %}

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,16 @@ export function setupVersionSelector(
159159
/* Check if version state was already determined */
160160
let outdated = __md_get("__outdated", sessionStorage)
161161
if (outdated === null) {
162-
const latest = config.version?.default || "latest"
163-
outdated = !current.aliases.includes(latest)
162+
outdated = true
163+
164+
/* Check if version is considered a default */
165+
const ignored = [config.version?.default || ["latest"]].flat()
166+
main: for (const ignore of ignored)
167+
for (const alias of current.aliases)
168+
if (new RegExp(ignore, "i").test(alias)) {
169+
outdated = false
170+
break main
171+
}
164172

165173
/* Persist version state in session storage */
166174
__md_set("__outdated", outdated, sessionStorage)

0 commit comments

Comments
 (0)