/
sdds
/
plasma
Обзор
Документация
Войти
/
sdds
/
plasma
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
dev
website/plasma-web-docs/docusaurus.config.js
289 строк
11 KB
Dima Shugaev
feat(infra): update configs for docsense
08 апр 2026, 10:47
08 апр 2026, 10:47
0031244
Код
Авторство
О чём код?
import { themes } from 'prism-react-renderer'; // eslint-disable-next-line @typescript-eslint/no-var-requires,import/order const path = require('path'); // eslint-disable-next-line @typescript-eslint/no-var-requires const docgen = require('react-docgen-typescript'); // eslint-disable-next-line @typescript-eslint/no-var-requires const fg = require('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 = '', QDRANT_API_KEY = '', } = process.env; const prPrefix = VERSION_NAME || PREFIX; const defaultUrl = PREFIX ? `/${PREFIX}/web/` : '/web/'; const baseUrl = VERSION_NAME ? `/versions/${VERSION_NAME}/` : defaultUrl; /** @type {import('@docusaurus/types').DocusaurusConfig} */ module.exports = { title: 'Plasma Web', tagline: 'Дизайн-система для разработки современных приложений.', url: 'https://plasma.sberdevices.ru/', baseUrl, onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'warn', favicon: 'images/favicon.png', organizationName: 'Salute-Developers', projectName: 'Plasma', trailingSlash: true, themes: ['@docusaurus/theme-live-codeblock', 'docusaurus-theme-search-typesense'], future: { experimental_faster: true, }, themeConfig: { navbar: { title: 'Plasma', logo: { alt: 'Plasma', src: 'images/plasma-logo.png', }, items: [ { href: `https://plasma.sberdevices.ru${prPrefix}/ui/`, position: 'left', label: 'UI', }, { type: 'doc', position: 'left', docId: 'intro', label: 'Web', }, { 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', }, { href: `${baseUrl}ai-search/`, label: 'AI-поиск', position: 'right', }, ], }, footer: { style: 'light', links: [ { title: 'Документация', items: [ { label: 'Plasma UI', to: `https://plasma.sberdevices.ru${prPrefix}/ui/`, }, { label: 'Plasma Web', to: '/', }, ], }, { title: 'Сообщество', items: [ { label: 'Telegram', href: 'https://t.me/smartmarket_community', }, { 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: 'web', 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, }, qdrantApiKey: QDRANT_API_KEY, }, presets: [ [ '@docusaurus/preset-classic', { docs: { routeBasePath: '/', sidebarPath: require.resolve('./sidebars.js'), editUrl: 'https://github.com/salute-developers/plasma/blob/master/website/plasma-web-docs/', versions: { current: { label: pckgJson.dependencies['@salutejs/plasma-web'], path: '', }, }, }, theme: { customCss: require.resolve('./src/css/custom.css'), }, sitemap: { lastmod: 'date', changefreq: 'weekly', priority: 0.5, ignorePatterns: ['/tags/**'], filename: 'sitemap.xml', createSitemapItems: async (params) => { const { defaultCreateSitemapItems, ...rest } = params; const items = await defaultCreateSitemapItems(rest); return items.filter((item) => !item.url.includes('/page/')); }, }, }, ], ], plugins: [ function docgenPlugin() { // Плагин генерации документации return { name: 'docusaurus-plugin-react-docgen-typescript', async loadContent() { // Загрузка компонентов для документации return docgen .withCustomConfig('./tsconfig.json', { shouldExtractLiteralValuesFromEnum: true, shouldRemoveUndefinedFromOptional: true, propFilter: () => { // Функция обрезки типов return true; }, }) .parse( await fg([ '../../packages/plasma-web/src/**/*.{ts,tsx}', '!../../packages/plasma-web/src/**/*.test.*', '../../packages/plasma-hope/src/**/*.{ts,tsx}', '!../../packages/plasma-hope/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, }, }, };