Skip to content

Commit

Permalink
Added support for hiding version warning in multiple versions
Browse files Browse the repository at this point in the history
Co-authored-by: SaltyAimbOtter <40303883+SaltyAimbOtter@users.noreply.github.com>
  • Loading branch information
squidfunk and SaltyAimbOtter committed Feb 18, 2023
1 parent 981ee65 commit b257235
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
19 changes: 17 additions & 2 deletions docs/setup/setting-up-versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
12 changes: 10 additions & 2 deletions src/assets/javascripts/integrations/version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b257235

Please sign in to comment.