website: Touch up shared config. (#15153)
* website: Touch up shared config. * website: Update deps. Fix issues surrounding cross-package formatting.
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @file Common Docusaurus configuration utilities.
|
||||
*
|
||||
* @import { Config as DocusaurusConfig } from "@docusaurus/types"
|
||||
* @import { UserThemeConfig } from "./theme.js"
|
||||
* @import { Config, DocusaurusConfig } from "@docusaurus/types"
|
||||
* @import { UserThemeConfig, UserThemeConfigExtra } from "./theme.js"
|
||||
*/
|
||||
import { deepmerge } from "deepmerge-ts";
|
||||
|
||||
@ -11,14 +11,14 @@ import { createThemeConfig } from "./theme.js";
|
||||
//#region Types
|
||||
|
||||
/**
|
||||
* @typedef {Omit<DocusaurusConfig, 'themeConfig'>} DocusaurusConfigBase
|
||||
* @typedef {Omit<Config, 'themeConfig'>} DocusaurusConfigBase
|
||||
*
|
||||
* Represents the base configuration for Docusaurus, excluding the theme configuration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef DocusaurusConfigBaseTheme
|
||||
* @property {UserThemeConfig} themeConfig The theme configuration.
|
||||
* @property {UserThemeConfig & UserThemeConfigExtra} themeConfig The theme configuration.
|
||||
*
|
||||
* Represents a configuration object, only including the theme configuration.
|
||||
*/
|
||||
@ -39,31 +39,66 @@ import { createThemeConfig } from "./theme.js";
|
||||
//#region Functions
|
||||
|
||||
/**
|
||||
* Create a Docusaurus configuration.
|
||||
*
|
||||
* @param {DocusaurusConfigInit} [overrides] The options to override.
|
||||
* @returns {DocusaurusConfig}
|
||||
* Create a default Docusaurus configuration.
|
||||
*/
|
||||
export function createDocusaurusConfig({ themeConfig, ...overrides } = {}) {
|
||||
export function createDefaultDocusaurusConfig() {
|
||||
const NodeEnvironment = process.env.AK_DOCUSAURUS_ENV || process.env.NODE_ENV || "development";
|
||||
const production = NodeEnvironment === "production";
|
||||
|
||||
/**
|
||||
* @type {DocusaurusConfig}
|
||||
* @satisfies {Config}
|
||||
*/
|
||||
const config = {
|
||||
const DEFAULT_CONFIG = /** @type {const} */ ({
|
||||
trailingSlash: true,
|
||||
future: {
|
||||
v4: {
|
||||
removeLegacyPostBuildHeadAttribute: true,
|
||||
useCssCascadeLayers: false,
|
||||
},
|
||||
experimental_faster: {
|
||||
swcJsLoader: true,
|
||||
rspackBundler: true,
|
||||
lightningCssMinimizer: production,
|
||||
swcJsMinimizer: production,
|
||||
swcHtmlMinimizer: production,
|
||||
ssgWorkerThreads: production,
|
||||
mdxCrossCompilerCache: production,
|
||||
rspackPersistentCache: production,
|
||||
},
|
||||
},
|
||||
title: "authentik",
|
||||
tagline: "Bring all of your authentication into a unified platform.",
|
||||
url: "https://docs.goauthentik.io",
|
||||
baseUrl: "/",
|
||||
onBrokenLinks: "throw",
|
||||
onBrokenAnchors: "throw",
|
||||
onBrokenMarkdownLinks: "throw",
|
||||
onDuplicateRoutes: "throw",
|
||||
favicon: "img/icon.png",
|
||||
organizationName: "Authentik Security Inc.",
|
||||
projectName: "authentik",
|
||||
markdown: {
|
||||
mermaid: true,
|
||||
},
|
||||
});
|
||||
|
||||
return DEFAULT_CONFIG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Docusaurus configuration.
|
||||
*
|
||||
* @template {Partial<Config>} T
|
||||
* @param {T} overrides The options to override.
|
||||
* @returns {T & ReturnType<typeof createDefaultDocusaurusConfig>}
|
||||
*/
|
||||
export function createDocusaurusConfig({ themeConfig, ...overrides }) {
|
||||
const config = {
|
||||
...createDefaultDocusaurusConfig(),
|
||||
themeConfig: createThemeConfig(themeConfig),
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
return deepmerge(config, overrides);
|
||||
}
|
||||
|
||||
|
||||
@ -3,16 +3,26 @@
|
||||
*
|
||||
* @import { UserThemeConfig as UserThemeConfigCommon } from "@docusaurus/theme-common";
|
||||
* @import { UserThemeConfig as UserThemeConfigAlgolia } from "@docusaurus/theme-search-algolia";
|
||||
* @import { NavbarItemOverrides } from "./navbar.js"
|
||||
*/
|
||||
import { deepmerge } from "deepmerge-ts";
|
||||
import { themes as prismThemes } from "prism-react-renderer";
|
||||
|
||||
import { createNavbarItems } from "./navbar.js";
|
||||
|
||||
//#region Types
|
||||
|
||||
/**
|
||||
* Combined theme configuration for Docusaurus and Algolia.
|
||||
* @typedef {Object} UserThemeConfigExtra
|
||||
* @property {Partial<NavbarItemOverrides>} [navbarReplacements] The replacements for the navbar.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Combined theme configuration for Docusaurus, Algolia, and our own configuration.
|
||||
*
|
||||
* @typedef {UserThemeConfigCommon & UserThemeConfigAlgolia} UserThemeConfig
|
||||
*
|
||||
*/
|
||||
|
||||
//#endregion
|
||||
@ -57,10 +67,10 @@ export function createPrismConfig(overrides = {}) {
|
||||
/**
|
||||
* Creates a theme configuration for Docusaurus.
|
||||
*
|
||||
* @param {Partial<UserThemeConfig>} overrides - Overrides for the default theme configuration.
|
||||
* @param {Partial<UserThemeConfig & UserThemeConfigExtra>} overrides - Overrides for the default theme configuration.
|
||||
* @returns {UserThemeConfig}
|
||||
*/
|
||||
export function createThemeConfig({ prism, ...overrides } = {}) {
|
||||
export function createThemeConfig({ prism, navbarReplacements, ...overrides } = {}) {
|
||||
/**
|
||||
* @type {UserThemeConfig}
|
||||
*/
|
||||
@ -77,6 +87,17 @@ export function createThemeConfig({ prism, ...overrides } = {}) {
|
||||
appId: "36ROD0O0FV",
|
||||
apiKey: "727db511300ca9aec5425645bbbddfb5",
|
||||
},
|
||||
footer: {
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Authentik Security Inc. Built with Docusaurus.`,
|
||||
},
|
||||
navbar: {
|
||||
logo: {
|
||||
alt: "authentik logo",
|
||||
src: "img/icon_left_brand.svg",
|
||||
},
|
||||
|
||||
items: createNavbarItems(navbarReplacements),
|
||||
},
|
||||
prism: createPrismConfig(prism),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user