/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/src/plugins/featureRequests/FeatureRequestsPlugin.js
43 строки
1 KB
Sébastien Lorber
feat(core): simplify plugin API, support route.props (#10042)
16 апр 2024, 14:57
Не верифицирован
16 апр 2024, 14:57
5c1d646
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import path from 'path'; import {normalizeUrl, posixPath} from '@docusaurus/utils'; /** * @param {import('@docusaurus/types').LoadContext} context * @returns {import('@docusaurus/types').Plugin} */ export default function FeatureRequestsPlugin(context) { return { name: 'feature-requests-plugin', async contentLoaded({actions}) { const basePath = normalizeUrl([context.baseUrl, '/feature-requests']); const paths = await actions.createData( 'paths.json', JSON.stringify(basePath), ); // TODO Docusaurus v4 breaking change // module aliasing should be automatic // we should never find local absolute FS paths in the codegen registry const aliasedSource = (source) => `@generated/${posixPath( path.relative(context.generatedFilesDir, source), )}`; actions.addRoute({ path: basePath, exact: false, component: '@site/src/plugins/featureRequests/FeatureRequestsPage', modules: { basePath: aliasedSource(paths), }, }); }, }; }