feat(techdocs): migrate search result item extension

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-09-29 09:38:13 +02:00
parent d58c324777
commit 2718c8d4cb
3 changed files with 38 additions and 0 deletions
+36
View File
@@ -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 => <TechDocsSearchResultListItem {...props} {...config} />;
},
});
/** @alpha */
export default createPlugin({
id: 'techdocs',
extensions: [TechDocsSearchResultListItemExtension],
});