/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages-internal/api-docs-builder/src/utils/findPagesMarkdown.ts
51 строка
1 KB
Brijesh Bittu
[docs-infra] Rename package to @mui/internal-api-docs-builder (#48230)
21 апр 2026, 12:17
Не верифицирован
21 апр 2026, 12:17
c11f4ee
Код
Авторство
О чём код?
import fs from 'fs'; import path from 'path'; interface MarkdownPage { filename: string; pathname: string; } /** * Returns the markdowns of the documentation in a flat array. */ export default function findPagesMarkdown( directory: string = path.resolve(process.cwd(), 'docs/data'), pagesMarkdown: MarkdownPage[] = [], ) { const items = fs.readdirSync(directory); items.forEach((item) => { const filename = path.resolve(directory, item); if (fs.statSync(filename).isDirectory()) { findPagesMarkdown(filename, pagesMarkdown); return; } // Ignore non en-US source markdown. if (!/\.mdx?$/.test(item) || /-(zh|pt)\.mdx?/.test(item)) { return; } let pathname = filename .replace(new RegExp(`\\${path.sep}`, 'g'), '/') .replace(/^.*\/data/, '') .replace(/\.mdx?/, ''); // Remove the last pathname segment. pathname = pathname .split('/') .slice(0, pathname.split('/').length - 1) .join('/'); pagesMarkdown.push({ // Relative location of the markdown file in the file system. filename, // Relative location of the page in the URL. pathname, }); }); return pagesMarkdown; }