This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/website/src/utils.js

32 lines
1.2 KiB
JavaScript

function generateVersionDropdown(sidebar) {
const releases = sidebar.docs
.filter((doc) => doc.link?.slug === "releases")[0]
.items.filter((release) => typeof release === "string");
const latest = releases[0].replace(/releases\/\d+\/v/, "");
return `<div class="navbar__item dropdown dropdown--hoverable dropdown--right">
<div aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link menu__link">
Version: ${latest}
</div>
<ul class="dropdown__menu">
${releases
.map((release) => {
const version = release.replace(/releases\/\d+\/v/, "");
const subdomain = `version-${version.replace(".", "-")}`;
const label = `Version: ${version}`;
return `<li>
<a
href="https://${subdomain}.goauthentik.io/docs"
target="_blank" rel="noopener noreferrer"
class="dropdown__link">${label}</a>
</li>`;
})
.join("")}
</ul>
</div>
<hr>`;
}
module.exports = {
generateVersionDropdown,
};