Skip to content

Commit

Permalink
Added support for displaying version aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed May 15, 2024
1 parent 485fa76 commit cc398dd
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 13 deletions.
6 changes: 6 additions & 0 deletions docs/schema/extra.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@
}
],
"default": "stable"
},
"alias": {
"title": "Show alias next to version number",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/setting-up-the-versioning/#version-alias",
"type": "boolean",
"default": true
}
}
},
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'assets/javascripts/custom.63a6dff3.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/custom.b457887c.min.js' | url }}"></script>
{% endblock %}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions material/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.732c4fb1.min.css' | url }}">
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.6543a935.min.css' | url }}">
{% if config.theme.palette %}
{% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.06af60db.min.css' | url }}">
Expand Down Expand Up @@ -249,7 +249,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.7c1205d0.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.ebd0bdb7.min.js' | url }}"></script>
{% for script in config.extra_javascript %}
{{ script | script_tag }}
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions src/templates/assets/javascripts/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type Translations =
export interface Versioning {
provider: "mike" /* Version provider */
default?: string | string[] /* Default version */
alias?: boolean /* Show alias */
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/templates/assets/javascripts/templates/version/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function renderVersion(version: Version): HTMLElement {
<li class="md-version__item">
<a href={`${url}`} class="md-version__link">
{version.title}
{config.version?.alias && version.aliases.length && (
<span class="md-version__alias">
{version.aliases[0]}
</span>
)}
</a>
</li>
)
Expand All @@ -84,6 +89,7 @@ function renderVersion(version: Version): HTMLElement {
export function renderVersionSelector(
versions: Version[], active: Version
): HTMLElement {
const config = configuration()
versions = versions.filter(version => !version.properties?.hidden)
return (
<div class="md-version">
Expand All @@ -92,6 +98,11 @@ export function renderVersionSelector(
aria-label={translation("select.version")}
>
{active.title}
{config.version?.alias && active.aliases.length && (
<span class="md-version__alias">
{active.aliases[0]}
</span>
)}
</button>
<ul class="md-version__list">
{versions.map(renderVersion)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
}
}

// Version alias
&__alias {
margin-left: px2rem(6px);
opacity: 0.7;
}

// Version selection list
&__list {
position: absolute;
Expand Down

0 comments on commit cc398dd

Please sign in to comment.