mirror of
https://github.com/goauthentik/authentik
synced 2026-04-28 10:28:22 +02:00
* website: Unify Netlify redirects with Docusaurus's client-side router. * website: Flesh out client-redirects. * Potential fix for code scanning alert no. 256: Incomplete string escaping or encoding Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * website: Use package. * website: use permanent redirect. * Apply suggestions from code review Co-authored-by: Dewi Roberts <dewi@goauthentik.io> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Dewi Roberts <dewi@goauthentik.io> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * website: Spelling. * website: Add link. * website: Clarify. * website: Remove doc. * website: Add redirects for API and integrations. --------- Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
/* eslint-disable no-console */
|
|
/**
|
|
* @file Docusaurus releases plugin.
|
|
*
|
|
* @import { LoadContext, Plugin } from "@docusaurus/types"
|
|
* @import { AKReleasesPluginEnvironment } from "./node.mjs"
|
|
*/
|
|
|
|
import * as fs from "node:fs/promises";
|
|
import * as path from "node:path";
|
|
|
|
import { collectReleaseFiles, prepareReleaseEnvironment } from "./node.mjs";
|
|
|
|
const PLUGIN_NAME = "ak-releases-plugin";
|
|
const RELEASES_FILENAME = "releases.gen.json";
|
|
|
|
/**
|
|
* @typedef {object} AKReleasesPluginOptions
|
|
* @property {string} docsDirectory The path to the documentation directory.
|
|
* @property {AKReleasesPluginEnvironment} [environment] Optional environment variables overrides.
|
|
*/
|
|
|
|
/**
|
|
* @typedef {object} AKReleasesPluginData
|
|
* @property {string} publicPath URL to the plugin's public directory.
|
|
* @property {string[]} releases Available versions of the documentation.
|
|
* @property {AKReleasesPluginEnvironment} env Environment variables
|
|
*/
|
|
|
|
/**
|
|
* @param {LoadContext} loadContext
|
|
* @param {AKReleasesPluginOptions} options
|
|
* @returns {Promise<Plugin<AKReleasesPluginData>>}
|
|
*/
|
|
async function akReleasesPlugin(loadContext, options) {
|
|
return {
|
|
name: PLUGIN_NAME,
|
|
|
|
async loadContent() {
|
|
console.log(`🚀 ${PLUGIN_NAME} loaded`);
|
|
|
|
const environment = {
|
|
...prepareReleaseEnvironment(),
|
|
...options.environment,
|
|
};
|
|
|
|
const releases = collectReleaseFiles(options.docsDirectory).map(
|
|
(release) => release.name,
|
|
);
|
|
|
|
const outputPath = path.join(loadContext.siteDir, "static", RELEASES_FILENAME);
|
|
|
|
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
await fs.writeFile(outputPath, JSON.stringify(releases, null, 2), "utf-8");
|
|
console.log(`✅ ${RELEASES_FILENAME} generated`);
|
|
|
|
/**
|
|
* @type {AKReleasesPluginData}
|
|
*/
|
|
const content = {
|
|
releases,
|
|
publicPath: path.join("/", RELEASES_FILENAME),
|
|
env: environment,
|
|
};
|
|
|
|
content.publicPath;
|
|
|
|
return content;
|
|
},
|
|
|
|
contentLoaded({ content, actions }) {
|
|
const { setGlobalData } = actions;
|
|
|
|
setGlobalData(content);
|
|
},
|
|
};
|
|
}
|
|
|
|
export default akReleasesPlugin;
|