UNPKG

strapi-plugin-parent-child-relationships

Version:

Strapi plugin to create and manage parent-child relationships between content types using custom fields

17 lines (14 loc) 409 B
import { normalizeRelation } from './normalizeRelations'; export const normalizeSearchResults = (relations, { mainFieldName }) => { const { data } = relations; const { pages = [] } = data ?? {}; return { ...relations, data: pages .map((page) => page?.results.map((relation) => normalizeRelation(relation, { mainFieldName })) ) .filter(Boolean) .flat(), }; };