website/docs: Update Docusaurus config. Prep for version picker. (#14401)

* website/docs: Clean up config. Add types.

* website/docs: Format MDX.

* website: Fix build warnings. Lint badges frontmatter.
This commit is contained in:
Teffen Ellis
2025-05-06 16:04:39 +02:00
committed by GitHub
parent 488a58e1c5
commit bfdb827ff9
65 changed files with 1504 additions and 1338 deletions

View File

@ -0,0 +1,47 @@
/**
* @file Remark plugin to transform `ak-enterprise` directives into badges.
*
* @import { Root } from "mdast";
*/
import { h } from "hastscript";
import { SKIP, visit } from "unist-util-visit";
/**
* MDAST plugin to transform `ak-enterprise` directives into badges.
*/
function remarkEnterpriseDirective() {
/**
* @param {Root} tree The MDAST tree to transform.
*/
return function (tree) {
visit(tree, "textDirective", function (node) {
if (node.name !== "ak-enterprise") return SKIP;
const data = node.data || (node.data = {});
const hast = h("span", {
...node.attributes,
"className": "badge badge--primary",
"title": `This feature is available in the enterprise version of authentik.`,
"aria-description": "Enterprise badge",
"role": "img",
});
data.hName = hast.tagName;
data.hProperties = hast.properties;
data.hChildren = [
{
type: "text",
value: "Enterprise",
},
];
node.children = [];
return SKIP;
});
};
}
export default remarkEnterpriseDirective;

View File

@ -1,14 +1,19 @@
/**
* @file Remark plugin to transform `ak-preview` directives into preview badges.
*
* @import { Root } from "mdast";
*/
import { h } from "hastscript";
import { Root } from "mdast";
import "mdast-util-directive";
import "mdast-util-to-hast";
import { SKIP, visit } from "unist-util-visit";
/**
* MDAST plugin to transform `ak-preview` directives into preview badges.
*/
function remarkPreviewDirective() {
return function (tree: Root) {
/**
* @param {Root} tree The MDAST tree to transform.
*/
return function (tree) {
visit(tree, "textDirective", function (node) {
if (node.name !== "ak-preview") return SKIP;

View File

@ -1,29 +1,35 @@
/**
* @file Remark plugin to transform `ak-support` directives into support level badges.
*
* @import { Root } from "mdast";
*/
import { h } from "hastscript";
import { Root } from "mdast";
import "mdast-util-directive";
import "mdast-util-to-hast";
import { coerce } from "semver";
import { SKIP, visit } from "unist-util-visit";
/**
* Support levels for authentik.
* @typedef {"authentik" | "community" | "vendor" | "deprecated"} SupportLevel
*/
export type SupportLevel = "authentik" | "community" | "vendor" | "deprecated";
/**
* Mapping of support levels to badge classes.
*
* @satisfies {Record<SupportLevel, string>}
*/
export const SupportLevelToLabel = {
export const SupportLevelToLabel = /** @type {const} */ ({
authentik: "authentik",
community: "Community",
vendor: "Vendor",
deprecated: "Deprecated",
} as const satisfies Record<SupportLevel, string>;
});
/**
* Type-predicate to determine if a string is a known support level.
*
* @param {string} input The string to check.
* @return {input is SupportLevel} True if the string is a known support level.
*/
export function isSupportLevel(input: string): input is SupportLevel {
export function isSupportLevel(input) {
return Object.hasOwn(SupportLevelToLabel, input);
}
@ -31,7 +37,10 @@ export function isSupportLevel(input: string): input is SupportLevel {
* MDAST plugin to transform `ak-support` directives into preview badges.
*/
function remarkSupportDirective() {
return function (tree: Root) {
/**
* @param {Root} tree The MDAST tree to transform.
*/
return function (tree) {
visit(tree, "textDirective", function (node) {
if (node.name !== "ak-support") return SKIP;

View File

@ -1,7 +1,9 @@
/**
* @file Remark plugin to transform `ak-version` directives into version badges.
*
* @import { Root } from "mdast";
*/
import { h } from "hastscript";
import { Root } from "mdast";
import "mdast-util-directive";
import "mdast-util-to-hast";
import { coerce } from "semver";
import { SKIP, visit } from "unist-util-visit";
@ -21,7 +23,10 @@ import { SKIP, visit } from "unist-util-visit";
* ```
*/
function remarkVersionDirective() {
return function (tree: Root) {
/**
* @param {Root} tree The MDAST tree to transform.
*/
return function (tree) {
visit(tree, "textDirective", function (node) {
if (node.name !== "ak-version") return SKIP;