From 157843e5aa7f569089fe5d47243e3768c4d14692 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Fri, 15 Oct 2021 11:46:34 +0200 Subject: [PATCH] [Search] add how to guide for indexing TechDocs documents (#7625) * add how to guide for indexing techdocs documents Signed-off-by: Emma Indal * add step of how to add techdocs to search type filter Signed-off-by: Emma Indal --- docs/features/search/README.md | 8 ++--- docs/features/search/how-to-guides.md | 52 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/docs/features/search/README.md b/docs/features/search/README.md index f975336fcc..0856451882 100644 --- a/docs/features/search/README.md +++ b/docs/features/search/README.md @@ -113,10 +113,10 @@ search engines. ## Plugins Integrated with Search -| Plugin | Support Status | -| -------- | -------------- | -| Catalog | ✅ | -| TechDocs | ✅ | +| Plugin | Support Status | +| -------------------------------------------------------------- | -------------- | +| Catalog | ✅ | +| [TechDocs](./how-to-guides.md#how-to-index-techdocs-documents) | ✅ | [Reach out to us](#get-involved) if you want to chat about support for more plugins integrated to search. diff --git a/docs/features/search/how-to-guides.md b/docs/features/search/how-to-guides.md index b6ea6ae364..43dfc41815 100644 --- a/docs/features/search/how-to-guides.md +++ b/docs/features/search/how-to-guides.md @@ -44,3 +44,55 @@ const app = createApp({ ], }); ``` + +## How to index TechDocs documents + +The techdocs-plugin has supported integrations to Search, meaning that it +provides a default collator ready to be used. + +The purpose of this how-to guide is to walk you through how to register the +[DefaultTechDocsCollator](https://github.com/backstage/backstage/blob/master/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts) +in your App in two steps, so that you can get TechDocs documents indexed. + +If you have been through the +[getting started guide](https://backstage.io/docs/features/search/getting-started) +already, you should have the `packages/backend/src/plugins/search.ts` file +available. If you have that, you can jump to the first step of this guide, if +not - start by go through the getting started guide. + +1. Import the DefaultTechDocsCollator from `@backstage/plugin-techdocs-backend`. + +```typescript +import { DefaultTechDocsCollator } from '@backstage/plugin-techdocs-backend'; +``` + +2. Register the DefaultTechDocsCollator with the IndexBuilder. + +```typescript +indexBuilder.addCollator({ + defaultRefreshIntervalSeconds: 600, + collator: DefaultTechDocsCollator.fromConfig(config, { + discovery, + logger, + }), +}); +``` + +You should now have your TechDocs documents indexed to your search engine of +choice! + +If you want your users to be able to filter down to the techdocs type when +searching. You can update your `SearchPage.tsx` file in +`packages/app/src/components/search` by adding `techdocs` to the list of values +of the `SearchType` component. + +```tsx + + + ... + +```