Removed necessity for Array.flat and Array.flatMap polyfill

This commit is contained in:
squidfunk 2023-07-07 10:22:47 +02:00
parent 54bef7bfe5
commit b37c668a9a
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
11 changed files with 24 additions and 17 deletions

View File

@ -23,5 +23,5 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{ 'assets/javascripts/custom.a2f5d53d.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/custom.785bde5b.min.js' | url }}"></script>
{% endblock %} {% endblock %}

View File

@ -222,7 +222,7 @@
"base": base_url, "base": base_url,
"features": features, "features": features,
"translations": {}, "translations": {},
"search": "assets/javascripts/workers/search.780af0f4.min.js" | url "search": "assets/javascripts/workers/search.dfff1995.min.js" | url
} -%} } -%}
{%- if config.extra.version -%} {%- if config.extra.version -%}
{%- set _ = app.update({ "version": config.extra.version }) -%} {%- set _ = app.update({ "version": config.extra.version }) -%}
@ -250,7 +250,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.c1c13a0d.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.4e31edb1.min.js' | url }}"></script>
{% for path in config.extra_javascript %} {% for path in config.extra_javascript %}
{% if path.endswith(".mjs") %} {% if path.endswith(".mjs") %}
<script type="module" src="{{ path | url }}"></script> <script type="module" src="{{ path | url }}"></script>

View File

@ -80,7 +80,7 @@ export type Translations =
*/ */
export interface Versioning { export interface Versioning {
provider: "mike" /* Version provider */ provider: "mike" /* Version provider */
default?: string /* Default version */ default?: string | string[] /* Default version */
} }
/** /**

View File

@ -89,7 +89,10 @@ export function transform(
/* => 4 */ /* => 4 */
.split(/\s+/g) .split(/\s+/g)
.flatMap(fn) .reduce((prev, term) => {
const next = fn(term)
return [...prev, ...Array.isArray(next) ? next : [next]]
}, [] as string[])
.map(term => /([~^]$)/.test(term) ? `${term}1` : term) .map(term => /([~^]$)/.test(term) ? `${term}1` : term)
.map(term => /(^[+-]|[~^]\d+$)/.test(term) ? term : `${term}*`) .map(term => /(^[+-]|[~^]\d+$)/.test(term) ? term : `${term}*`)
.join(" ") .join(" ")

View File

@ -161,8 +161,12 @@ export function setupVersionSelector(
if (outdated === null) { if (outdated === null) {
outdated = true outdated = true
/* Obtain and normalize default versions */
let ignored = config.version?.default || "latest"
if (!Array.isArray(ignored))
ignored = [ignored]
/* Check if version is considered a default */ /* Check if version is considered a default */
const ignored = [config.version?.default || ["latest"]].flat()
main: for (const ignore of ignored) main: for (const ignore of ignored)
for (const alias of current.aliases) for (const alias of current.aliases)
if (new RegExp(ignore, "i").test(alias)) { if (new RegExp(ignore, "i").test(alias)) {