Added support for hiding version warning in multiple versions

Co-authored-by: SaltyAimbOtter <40303883+SaltyAimbOtter@users.noreply.github.com>
This commit is contained in:
squidfunk 2023-02-18 12:10:28 +01:00
parent 981ee65498
commit b257235717
5 changed files with 33 additions and 10 deletions

View File

@ -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

View File

@ -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 %}

View File

@ -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)