Structure documentation in /docs
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# Reference documentation
|
||||
|
||||
APIs and Components
|
||||
|
||||
- [createPlugin](createPlugin.md)
|
||||
- [createPlugin - router](createPlugin-router.md)
|
||||
|
||||
[Back to Docs](../README.md)
|
||||
@@ -0,0 +1,21 @@
|
||||
# createPlugin - router
|
||||
|
||||
The router that is passed to the `register` function includes makes it possible for plugins to hook into routing of the Backstage app and provide the end users with new views to navigate to.
|
||||
|
||||
```typescript
|
||||
type RouterHooks = {
|
||||
registerRoute(
|
||||
path: RoutePath,
|
||||
Component: ComponentType<any>,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
|
||||
registerRedirect(
|
||||
path: RoutePath,
|
||||
target: RoutePath,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
};
|
||||
```
|
||||
|
||||
[Back to References](README.md)
|
||||
@@ -0,0 +1,40 @@
|
||||
# createPlugin
|
||||
|
||||
Taking a plugin config as argument and returns a new plugin.
|
||||
|
||||
## Plugin Config
|
||||
|
||||
```typescript
|
||||
function createPlugin(config: PluginConfig): BackstagePlugin;
|
||||
|
||||
type PluginConfig = {
|
||||
id: string;
|
||||
register?(hooks: PluginHooks): void;
|
||||
};
|
||||
|
||||
type PluginHooks = {
|
||||
router: RouterHooks;
|
||||
};
|
||||
```
|
||||
|
||||
[Read more about the router here](createPlugin-router.md)
|
||||
|
||||
## Example Uses
|
||||
|
||||
### Creating a basic plugin
|
||||
|
||||
Showcasing adding multiple routes and a redirect.
|
||||
|
||||
```jsx
|
||||
import { createPlugin } from '@spotify-backstage/core';
|
||||
import ExampleComponent from './components/ExampleComponent';
|
||||
|
||||
export default createPlugin({
|
||||
id: 'new-plugin',
|
||||
register({ router }) {
|
||||
router.registerRoute('/new-plugin', ExampleComponent);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
[Back to References](README.md)
|
||||
Reference in New Issue
Block a user