* web: Prep ESBuild plugin for publish. * prettier-config: Update deps. * eslint-config: Update deps. * docusaurus-config: Update deps. * docs: Update deps. * docs: Enable linter. * docs: Lint. * web/sfe: Clean up types. Prep for monorepo. * esbuild-plugin-live-reload: Update deps. * web: Tidy ESLint, script commands. * web: Fix logs. * web: Lint. * web: Split compile check from cached version.
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * @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 (tree) => {
 | 
						|
        visit(tree, "textDirective", (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;
 |