added seeder for legacy apge and added the legacy page
This commit is contained in:
@@ -218,11 +218,12 @@ export async function readExisting(
|
||||
strapi: Core.Strapi,
|
||||
uid: SeedUid,
|
||||
populate: string[],
|
||||
find?: SeedData
|
||||
find?: SeedData,
|
||||
locale: SeedLocale = 'ar'
|
||||
): Promise<SeedDocument | null> {
|
||||
return documents(strapi, uid).findFirst({
|
||||
...(find ? { filters: find } : {}),
|
||||
locale: 'ar',
|
||||
locale,
|
||||
...draftFilter(strapi, uid),
|
||||
populate,
|
||||
});
|
||||
@@ -236,3 +237,15 @@ export function mediaId(component: unknown, field: string): number | undefined {
|
||||
const id = (media as Record<string, unknown>).id;
|
||||
return typeof id === 'number' ? id : undefined;
|
||||
}
|
||||
|
||||
/** The ids of populated media entries nested in a component. */
|
||||
export function mediaIds(component: unknown, field: string): number[] {
|
||||
if (!component || typeof component !== 'object') return [];
|
||||
const media = (component as Record<string, unknown>)[field];
|
||||
if (!Array.isArray(media)) return [];
|
||||
return media.flatMap((item: unknown) => {
|
||||
if (!item || typeof item !== 'object') return [];
|
||||
const id = (item as Record<string, unknown>).id;
|
||||
return typeof id === 'number' ? [id] : [];
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user