mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added support for hiding version warning in multiple versions
Co-authored-by: SaltyAimbOtter <40303883+SaltyAimbOtter@users.noreply.github.com>
This commit is contained in:
parent
981ee65498
commit
b257235717
@ -93,10 +93,25 @@ to `mkdocs.yml`:
|
||||
``` yaml
|
||||
extra:
|
||||
version:
|
||||
default: stable
|
||||
default: stable # (1)!
|
||||
```
|
||||
|
||||
Make sure that this matches the [default version].
|
||||
1. You can also define multiple aliases as the default version, e.g. `stable`
|
||||
and `development`.
|
||||
|
||||
``` yaml
|
||||
extra:
|
||||
version:
|
||||
default:
|
||||
- stable
|
||||
- development
|
||||
```
|
||||
|
||||
Now every version that has the `stable` and `development` aliases will not
|
||||
display the version warning.
|
||||
|
||||
Make sure one alias matches the [default version], as this is where users are
|
||||
redirected to.
|
||||
|
||||
[Version warning support]: https://github.com/squidfunk/mkdocs-material/releases/tag/8.0.0
|
||||
[theme extension]: ../customization.md#extending-the-theme
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -240,7 +240,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.055143c9.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.2a6f1dda.min.js' | url }}"></script>
|
||||
{% for path in config.extra_javascript %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -159,8 +159,16 @@ export function setupVersionSelector(
|
||||
/* Check if version state was already determined */
|
||||
let outdated = __md_get("__outdated", sessionStorage)
|
||||
if (outdated === null) {
|
||||
const latest = config.version?.default || "latest"
|
||||
outdated = !current.aliases.includes(latest)
|
||||
outdated = true
|
||||
|
||||
/* Check if version is considered a default */
|
||||
const ignored = [config.version?.default || ["latest"]].flat()
|
||||
main: for (const ignore of ignored)
|
||||
for (const alias of current.aliases)
|
||||
if (new RegExp(ignore, "i").test(alias)) {
|
||||
outdated = false
|
||||
break main
|
||||
}
|
||||
|
||||
/* Persist version state in session storage */
|
||||
__md_set("__outdated", outdated, sessionStorage)
|
||||
|
Loading…
Reference in New Issue
Block a user