feat(techdocs): migrate search result item extension
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -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],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user