From e15241ea1d8f392bee2c9ff7161e21fdb55d28f1 Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Thu, 22 Apr 2021 10:40:10 +0200 Subject: [PATCH] Update README Signed-off-by: Marcus Eide --- plugins/shortcuts/README.md | 40 ++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/plugins/shortcuts/README.md b/plugins/shortcuts/README.md index 423f03948c..2848ece0e8 100644 --- a/plugins/shortcuts/README.md +++ b/plugins/shortcuts/README.md @@ -1,13 +1,39 @@ # shortcuts -Welcome to the shortcuts plugin! +`shortcuts-plugin` allows a user to have easy access to pages within a Backstage app by storing them as "shortcuts" in the Sidebar. -_This plugin was created through the Backstage CLI_ +## Usage -## Getting started +Add the `` component within your ``: -Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/shortcuts](http://localhost:3000/shortcuts). +```ts +import { Shortcuts } from '@backstage/plugin-shortcuts'; -You can also serve the plugin in isolation by running `yarn start` in the plugin directory. -This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. -It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory. + + {/* ... */} + + + +; +``` + +The plugin exports a `shortcutApiRef` and an implementation of the `ShortcutApi` that uses `localStorage` for storage, that you can use to get started quickly. To use it add it to your app's `apis.ts`: + +```ts +import { + LocalStoredShortcuts, + shortcutsApiRef, +} from '@backstage/plugin-shortcuts'; + +export const apis = [ + // ... + createApiFactory({ + api: shortcutsApiRef, + deps: { errorApi: errorApiRef }, + factory: ({ errorApi }) => + new LocalStoredShortcuts( + WebStorage.create({ namespace: '@backstage/shortcuts', errorApi }), + ), + }), +]; +```