/
sdds
/
plasma
Обзор
Документация
Войти
/
sdds
/
plasma
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
dev
website/sdds-scan-docs/docusaurus.config.js
224 строки
8 KB
Alexander Lobyntsev
docs: rework contentLoaded method [PLASMA-6798]
17 мар 2026, 10:09
17 мар 2026, 10:09
5e182ce
Код
Авторство
О чём код?
import { themes } from 'prism-react-renderer'; import path from 'path'; import { withCustomConfig } from 'react-docgen-typescript'; import fg from 'fast-glob'; // eslint-disable-next-line @typescript-eslint/no-var-requires const pckgJson = require('./package.json'); // eslint-disable-next-line @typescript-eslint/no-var-requires const versionsArchived = require('./versionsArchived.json'); const { VERSION_NAME, PREFIX, TYPESENSE_KEY = '', TYPESENSE_SERVICE_HOSTNAME = '' } = process.env; const defaultUrl = PREFIX ? `/${PREFIX}/sdds-scan/` : '/sdds-scan/'; const baseUrl = VERSION_NAME ? `/versions/${VERSION_NAME}/` : defaultUrl; /** @type {import('@docusaurus/types').DocusaurusConfig} */ const config = { title: 'sdds-scan', tagline: 'Дизайн-система для разработки современных приложений.', url: 'https://plasma.sberdevices.ru/', baseUrl, onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'warn', favicon: 'images/favicon.png', organizationName: 'Salute-Developers', trailingSlash: true, themes: ['@docusaurus/theme-live-codeblock', 'docusaurus-theme-search-typesense'], future: { experimental_faster: true, }, themeConfig: { navbar: { title: 'SDDS-SCAN', items: [ { type: 'docsVersionDropdown', position: 'right', dropdownActiveClassDisabled: false, dropdownItemsAfter: [ ...Object.entries(versionsArchived).map(([versionName, versionUrl]) => ({ label: versionName, href: versionUrl, })), ], }, { href: 'https://github.com/salute-developers/plasma', label: 'GitHub', position: 'right', }, ], }, footer: { style: 'light', links: [ { title: 'Сообщество', items: [ { label: 'GitHub', href: 'https://github.com/salute-developers/plasma', }, ], }, ], }, prism: { theme: themes.github, darkTheme: themes.dracula, }, colorMode: { // "light" | "dark" defaultMode: 'light', // Hides the switch in the navbar // Useful if you want to support a single color mode disableSwitch: false, // Whether to use the prefers-color-scheme media-query, // using user system preferences, instead of the hardcoded defaultMode. respectPrefersColorScheme: true, }, typesense: { // Replace this with the name of your index/collection. // It should match the "index_name" entry in the scraper's "config.json" file. typesenseCollectionName: 'scan', typesenseServerConfig: { nodes: [ { host: TYPESENSE_SERVICE_HOSTNAME, port: 443, protocol: 'https', }, ], apiKey: TYPESENSE_KEY, }, // Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters typesenseSearchParameters: {}, // Optional contextualSearch: true, }, }, presets: [ [ '@docusaurus/preset-classic', { docs: { routeBasePath: '/', sidebarPath: require.resolve('./sidebars.js'), editUrl: 'https://github.com/salute-developers/plasma/blob/master/website/sdds-scan-docs/', versions: { current: { label: pckgJson.dependencies['@salutejs/sdds-scan'], path: '', }, }, }, theme: { customCss: require.resolve('./src/css/custom.css'), }, }, ], ], plugins: [ function docgenPlugin() { // Плагин генерации документации return { name: 'docusaurus-plugin-react-docgen-typescript', async loadContent() { // Загрузка компонентов для документации return withCustomConfig('./tsconfig.json', { shouldExtractLiteralValuesFromEnum: true, shouldRemoveUndefinedFromOptional: true, propFilter: () => { // Функция обрезки типов return true; }, }).parse( await fg([ '../../packages/sdds-scan/src/**/*.{ts,tsx}', '!../../packages/sdds-scan/src/**/*.test.*', ]), ); }, configureWebpack(config) { return { resolve: { alias: { '@docgen': path.join( config.resolve.alias['@generated'], 'docusaurus-plugin-react-docgen-typescript', 'default', ), }, }, }; }, async contentLoaded({ content, actions }) { const components = new Map(); content.forEach((module) => { const { displayName, description, props } = module; if ( /^[A-Z]/.test(displayName) && displayName !== 'Default' && (props || description) && !components.has(displayName) ) { components.set(displayName, module); } }); await Promise.all( [...components.values()].map((component) => actions.createData( `${component.displayName}.json`, JSON.stringify({ props: Object.entries(component.props).reduce( (acc, [key, { declarations, ...rest }]) => ({ ...acc, [key]: rest, }), {}, ), description: component.description, }), ), ), ); }, }; }, function aliasPlugin() { return { name: 'docusaurus-plugin-aliases', configureWebpack() { return { resolve: { symlinks: false, alias: { react: path.resolve(__dirname, 'node_modules', 'react'), 'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'), 'styled-components': path.resolve(__dirname, 'node_modules', 'styled-components'), }, }, }; }, }; }, ], markdown: { format: 'detect', mdx1Compat: { comments: true, admonitions: true, headingIds: true, }, }, }; export default config;