import type { Config } from '@docusaurus/types'; import { sdks } from './remote-content/sdks'; import { docs as edgeAndProxy } from './remote-content/edge-proxy'; import pluginNpm2Yarn from '@docusaurus/remark-plugin-npm2yarn'; // for a given redirect object, modify it's `from` property such that for every // path that doesn't start with `/docs/`, a corresponding path that _does_ start // with `/docs/` is added. // // For instance, given the object // // { // to: '/new/path', // from: ['/old/path', '/docs/other/old/path'], // } // // it will produce // // { // to: '/new/path', // from: ['/old/path', '/docs/old/path', '/docs/other/old/path'], // } // const addDocsRoutePrefix = ({ from, ...rest }) => { const addDocs = (from) => { if (Array.isArray(from)) { // if `from` is a list, then check each entry return from.flatMap(addDocs); } else { if (from.startsWith('/docs/')) { return [from]; } else { return [from, `/docs${from}`]; } } }; return { ...rest, from: addDocs(from), }; }; const getUnleashRepoStars = async () => { try { const response = await fetch( `https://api.github.com/repos/unleash/unleash`, ); const data = await response.json(); const unleashRepoStars = data.stargazers_count; const formattedStars = unleashRepoStars >= 1000 ? `${(unleashRepoStars / 1000).toFixed(1)}k` : unleashRepoStars?.toString() || ''; return formattedStars; } catch (e) { console.error('Error fetching Unleash repo stars', e); return ''; } }; export default async function createConfigAsync(): Promise { const stars = await getUnleashRepoStars(); return { future: { experimental_faster: true, // turns Docusaurus Faster on globally }, title: 'Unleash Documentation', tagline: 'The enterprise ready feature flag service', url: 'https://docs.getunleash.io', baseUrl: '/', onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'throw', favicon: 'img/favicon.ico', organizationName: 'Unleash', // Usually your GitHub org/user name. projectName: 'unleash.github.io', // Usually your repo name. trailingSlash: false, markdown: { mermaid: true, }, customFields: { // expose env vars etc here environment: process.env.NODE_ENV, }, headTags: [ { tagName: 'link', attributes: { rel: 'preload', href: '/img/unleash_logo_dark.svg', as: 'image', type: 'image/svg+xml', }, }, ], themeConfig: { defaultMode: 'light', disableSwitch: true, respectPrefersColorScheme: false, algolia: { appId: '5U05JI5NE1', apiKey: 'dc9c4491fcf9143ee34015f22d1dd9d6', indexName: 'getunleash', }, theme: { customCss: './src/css/custom.css', }, metadata: [ { name: 'og:image:width', content: '1200' }, { name: 'og:image:height', content: '630' }, ], navbar: { logo: { alt: 'Unleash logo', src: 'img/unleash_logo_dark.svg', srcDark: 'img/unleash_logo_white.svg', href: 'https://www.getunleash.io', }, items: [ { type: 'html', value: 'Product', position: 'left', }, { type: 'html', value: 'Plans', position: 'left', }, { type: 'html', value: 'Blog', position: 'left', }, { type: 'html', value: 'Academy', position: 'left', }, { type: 'html', position: 'right', value: ` `, className: 'show-at-small-sizes', }, { type: 'html', position: 'right', value: ` Star ${stars} `, className: 'hide-at-small-sizes', }, { type: 'html', position: 'right', value: '', className: 'hide-at-small-sizes', }, { type: 'html', value: 'Sign in', position: 'right', className: 'hide-at-small-sizes', }, { type: 'html', position: 'right', value: 'Start free trial', className: 'hide-at-small-sizes', }, ], }, prism: { additionalLanguages: [ 'csharp', 'dart', 'java', 'php', 'ruby', 'bash', 'diff', ], }, languageTabs: [ { highlight: 'bash', language: 'curl', }, { highlight: 'python', language: 'python', variant: 'requests', }, { highlight: 'go', language: 'go', }, { highlight: 'javascript', language: 'nodejs', variant: 'native', }, { highlight: 'ruby', language: 'ruby', }, { highlight: 'csharp', language: 'csharp', variant: 'httpclient', }, { highlight: 'php', language: 'php', }, { highlight: 'java', language: 'java', }, { highlight: 'powershell', language: 'powershell', }, ], footer: { links: [ { title: 'Server SDKs', items: [ { label: 'Node.js', to: '/reference/sdks/node', }, { label: 'Java', to: '/reference/sdks/java', }, { label: 'Go', to: '/reference/sdks/go', }, { label: 'Rust', to: '/reference/sdks/rust', }, { label: 'Ruby', to: '/reference/sdks/ruby', }, { label: 'Python', to: '/reference/sdks/python', }, { label: '.NET', to: '/reference/sdks/dotnet', }, { label: 'PHP', to: '/reference/sdks/php', }, { label: 'All SDKs', to: '/reference/sdks', }, ], }, { title: 'Frontend SDKs', items: [ { label: 'JavaScript', to: '/reference/sdks/javascript-browser', }, { label: 'React', to: '/reference/sdks/react', }, { label: 'Next.js', to: '/reference/sdks/next-js', }, { label: 'Vue', to: '/reference/sdks/vue', }, { label: 'iOS', to: '/reference/sdks/ios', }, { label: 'Android', to: '/reference/sdks/android', }, { label: 'Flutter', to: '/reference/sdks/flutter', }, ], }, { title: 'Feature Flag use cases', items: [ { label: 'Secure, scalable feature flags', to: '/topics/feature-flags/feature-flag-best-practices', }, { label: 'Rollbacks', href: 'https://www.getunleash.io/feature-flag-use-cases-rollbacks', }, { label: 'FedRAMP, SOC2, ISO2700 compliance', to: '/using-unleash/compliance/compliance-overview', }, { label: 'Progressive or gradual rollouts', to: '/feature-flag-tutorials/use-cases/gradual-rollout', }, { label: 'Trunk-based development', to: '/feature-flag-tutorials/use-cases/trunk-based-development', }, { label: 'Software kill switches', href: 'https://www.getunleash.io/feature-flag-use-cases-software-kill-switches', }, { label: 'A/B testing', to: '/feature-flag-tutorials/use-cases/a-b-testing', }, { label: 'Feature management', href: 'https://www.getunleash.io/blog/feature-management', }, { label: 'Canary releases', href: 'https://www.getunleash.io/blog/canary-deployment-what-is-it', }, ], }, { title: 'Product', items: [ { label: 'Quickstart', to: '/quickstart', }, { label: 'Unleash architecture', to: '/get-started/unleash-overview', }, { label: 'Pricing', href: 'https://www.getunleash.io/pricing', }, { label: 'Product vision', href: 'https://www.getunleash.io/product-vision', }, { label: 'Open live demo', href: 'https://app.unleash-hosted.com/demo/login', }, { label: 'Open source', href: 'https://www.getunleash.io/open-source', }, { label: 'Enterprise feature management platform', href: 'https://www.getunleash.io/enterprise-feature-management-platform', }, { label: 'Unleash vs LaunchDarkly', href: 'https://www.getunleash.io/unleash-vs-launchdarkly', }, ], }, { title: 'Support', items: [ { label: 'Help center', href: 'https://www.getunleash.io/support', }, { label: 'Status', href: 'https://unleash.instatus.com', }, { label: 'Changelog', href: 'https://github.com/Unleash/unleash/releases', }, ], }, ], copyright: `Copyright © ${new Date().getFullYear()} Unleash. Built with Docusaurus.`, logo: { src: 'img/unleash_logo_dark_no_label.svg', srcDark: 'img/unleash_logo_white_no_label.svg', alt: 'Unleash logo', }, }, image: 'img/unleash-preview-1200-630.png', imageZoom: { // Optional medium-zoom options at // https://www.npmjs.com/package/medium-zoom#options selector: '.markdown :not(p) > img', options: { background: 'var(--ifm-background-color)', }, }, }, presets: [ [ '@docusaurus/preset-classic', { docs: { // Please change this to your repo. editUrl: 'https://github.com/Unleash/unleash/edit/main/website/', routeBasePath: '/', remarkPlugins: [[pluginNpm2Yarn, { sync: true }]], docItemComponent: '@theme/ApiItem', sidebarPath: './sidebars.ts', breadcrumbs: true, }, theme: { customCss: './src/css/custom.css', }, sitemap: { changefreq: 'weekly', lastmod: 'date', priority: 0.5, createSitemapItems: async (params) => { const { defaultCreateSitemapItems, ...rest } = params; const items = await defaultCreateSitemapItems(rest); return items.filter( (item) => !item.url.includes('/page/'), ); }, }, }, ], ], plugins: [ [ // heads up to anyone making redirects: // // remember that redirects only work in production and not in // development, as mentioned in the docs // https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-client-redirects/ '@docusaurus/plugin-client-redirects', { fromExtensions: ['html', 'htm'], redirects: [].map(addDocsRoutePrefix), // redirects are performed by Vercel createRedirects: (toPath) => { if ( toPath.indexOf('/docs/') === -1 && toPath.indexOf('index.html') === -1 ) { return `/docs/${toPath}`; } }, }, ], [ 'docusaurus-plugin-openapi-docs', { id: 'api-operations', docsPluginId: 'classic', config: { server: { specPath: 'docs/generated/openapi.json', outputDir: 'docs/reference/api/unleash', sidebarOptions: { groupPathsBy: 'tag', categoryLinkSource: 'tag', }, }, }, }, ], [ 'docusaurus-plugin-remote-content', { // more info at https://github.com/rdilweb/docusaurus-plugin-remote-content#options name: 'content-sdks', sourceBaseUrl: 'https://raw.githubusercontent.com/Unleash/', // gets prepended to all of the documents when fetching outDir: 'docs/generated', // the base directory to output to. documents: sdks.urls, // the file names to download modifyContent: sdks.modifyContent, noRuntimeDownloads: true, }, ], [ 'docusaurus-plugin-remote-content', { // more info at https://github.com/rdilweb/docusaurus-plugin-remote-content#options name: 'content-external', sourceBaseUrl: 'https://raw.githubusercontent.com/Unleash/', // gets prepended to all of the documents when fetching outDir: 'docs/generated/', // the base directory to output to. documents: edgeAndProxy.urls, // the file names to download modifyContent: edgeAndProxy.modifyContent, noRuntimeDownloads: true, }, ], 'plugin-image-zoom', ], themes: [ 'docusaurus-theme-openapi-docs', // Allows use of @theme/ApiItem and other components '@docusaurus/theme-mermaid', ], }; }