diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index 058e838fe6..80951ed400 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -52,6 +52,7 @@ "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/integration-react": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index eb2f165350..bea4b7ab34 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -13,3 +13,39 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import React from 'react'; +import { + createPlugin, + createSchemaFromZod, +} from '@backstage/frontend-plugin-api'; +import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; + +/** @alpha */ +export const TechDocsSearchResultListItemExtension = + createSearchResultListItemExtension({ + id: 'techdocs', + configSchema: createSchemaFromZod(z => + z.object({ + // TODO: Define how the icon can be configurable + title: z.string().optional(), + lineClamp: z.number().default(5), + asLink: z.boolean().default(true), + asListItem: z.boolean().default(true), + noTrack: z.boolean().default(false), + }), + ), + predicate: result => result.type === 'techdocs', + component: async ({ config }) => { + const { TechDocsSearchResultListItem } = await import( + './search/components/TechDocsSearchResultListItem' + ); + return props => ; + }, + }); + +/** @alpha */ +export default createPlugin({ + id: 'techdocs', + extensions: [TechDocsSearchResultListItemExtension], +}); diff --git a/yarn.lock b/yarn.lock index 3dd3f6315b..655acc26ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9739,6 +9739,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/integration": "workspace:^" "@backstage/integration-react": "workspace:^" "@backstage/plugin-catalog-react": "workspace:^"