import { mkdirSync, writeFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { escapeText } from "../../renderers/util.js";
import { getSettings } from "../../settings.js";
export const docusaurusConfig = {
    rendererType: "mdx",
    componentPackageName: "@speakeasy-api/docs-md-react",
    buildPagePath(slug, { appendIndex = false } = {}) {
        const settings = getSettings();
        if (appendIndex) {
            slug += "/index";
        }
        return resolve(join(settings.output.pageOutDir, `${slug}.mdx`));
    },
    buildPagePreamble(frontMatter) {
        return `---
sidebar_position: ${frontMatter.sidebarPosition}
sidebar_label: ${escapeText(frontMatter.sidebarLabel, { escape: "mdx" })}
---

import "@speakeasy-api/docs-md-react/docusaurus.css";
`;
    },
    postProcess() {
        const settings = getSettings();
        // Create the about page metadata
        mkdirSync(settings.output.pageOutDir, { recursive: true });
        writeFileSync(join(settings.output.pageOutDir, "_category_.json"), JSON.stringify({
            position: 2,
            label: "API Reference",
            collapsible: true,
            collapsed: false,
        }, null, "  "), {});
        // Create the endpoint pages metadata
        mkdirSync(join(settings.output.pageOutDir, "endpoint"), {
            recursive: true,
        });
        writeFileSync(join(settings.output.pageOutDir, "endpoint", "_category_.json"), JSON.stringify({
            position: 3,
            label: "Operations",
            collapsible: true,
            collapsed: false,
        }, null, "  "));
    },
};
//# sourceMappingURL=docusaurus.js.map