api-docs: port top-level component to composability API

This commit is contained in:
Patrik Oldsberg
2021-01-19 23:33:52 +01:00
parent bad33a2ec2
commit fb265bb4fa
2 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -15,4 +15,4 @@
*/
export * from './components';
export { plugin } from './plugin';
export { plugin, ApiExplorerPage } from './plugin';
+18 -3
View File
@@ -15,14 +15,21 @@
*/
import { ApiEntity } from '@backstage/catalog-model';
import { createApiFactory, createPlugin } from '@backstage/core';
import { ApiExplorerPage } from './components/ApiExplorerPage/ApiExplorerPage';
import {
createApiFactory,
createPlugin,
createRoutableExtension,
} from '@backstage/core';
import { ApiExplorerPage as Page } from './components/ApiExplorerPage/ApiExplorerPage';
import { defaultDefinitionWidgets } from './components/ApiDefinitionCard';
import { rootRoute } from './routes';
import { apiDocsConfigRef } from './config';
export const plugin = createPlugin({
id: 'api-docs',
routes: {
root: rootRoute,
},
apis: [
createApiFactory({
api: apiDocsConfigRef,
@@ -38,6 +45,14 @@ export const plugin = createPlugin({
}),
],
register({ router }) {
router.addRoute(rootRoute, ApiExplorerPage);
router.addRoute(rootRoute, Page);
},
});
export const ApiExplorerPage = plugin.provide(
createRoutableExtension({
component: () =>
import('./components/ApiExplorerPage').then(m => m.ApiExplorerPage),
mountPoint: rootRoute,
}),
);