/
sdds
/
plasma
Обзор
Документация
Войти
/
sdds
/
plasma
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
dev
website/sdds-serv-docs/docusaurus.config.js
225 строк
8 KB
Dima Shugaev
feat(*-docs): add typesense search
29 авг 2025, 15:04
29 авг 2025, 15:04
d889181
Код
Авторство
О чём код?
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 = '' } = process.env; const defaultUrl = PREFIX ? `/${PREFIX}/sdds-serv/` : '/sdds-serv/'; const baseUrl = VERSION_NAME ? `/versions/${VERSION_NAME}/` : defaultUrl; /** @type {import('@docusaurus/types').DocusaurusConfig} */ module.exports = { title: 'SDDS SERV', tagline: 'Дизайн-система для разработки современных приложений.', url: 'https://plasma.sberdevices.ru/', baseUrl, onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'warn', favicon: 'images/favicon.png', organizationName: 'Salute-Developers', projectName: 'sdds-serv', trailingSlash: true, themes: ['@docusaurus/theme-live-codeblock', 'docusaurus-theme-search-typesense'], future: { experimental_faster: true, }, themeConfig: { navbar: { title: 'SDDS SERV', items: [ { type: 'docsVersionDropdown', position: 'right', dropdownActiveClassDisabled: false, dropdownItemsAfter: [ ...Object.entries(versionsArchived).map(([versionName, versionUrl]) => ({ label: versionName, href: versionUrl, })), ], }, ], }, 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: 'serv', 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-serv-docs/', versions: { current: { label: pckgJson.dependencies['@salutejs/sdds-serv'], path: '', }, }, }, theme: { customCss: require.resolve('./src/css/custom.css'), }, }, ], ], 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/sdds-serv/src/**/*.{ts,tsx}', '!../../packages/sdds-serv/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 names = []; content .filter((module) => { const result = !names.includes(module.displayName) && /^[A-Z]/.test(module.displayName) && (module.props || module.description) && module.displayName !== 'Default'; if (result) { names.push(module.displayName); return true; } return false; }) .forEach(async (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, }, }, };