(
authentication: AuthenticationContext,
pageDefinitions: PageDefinition[],
webId: WebId,
sharedParams: {
logger: Logger;
context: ImpureGraphContext<false, true>;
},
parentPage?: Page,
)
| 15 | }; |
| 16 | |
| 17 | export const seedPages = async ( |
| 18 | authentication: AuthenticationContext, |
| 19 | pageDefinitions: PageDefinition[], |
| 20 | webId: WebId, |
| 21 | sharedParams: { |
| 22 | logger: Logger; |
| 23 | context: ImpureGraphContext<false, true>; |
| 24 | }, |
| 25 | parentPage?: Page, |
| 26 | ) => { |
| 27 | const { context } = sharedParams; |
| 28 | |
| 29 | let prevFractionalIndex: string | undefined; |
| 30 | |
| 31 | for (const pageDefinition of pageDefinitions) { |
| 32 | const newPage: Page = await createPage(context, authentication, { |
| 33 | webId, |
| 34 | title: pageDefinition.title, |
| 35 | prevFractionalIndex, |
| 36 | type: "document", |
| 37 | }); |
| 38 | |
| 39 | if (parentPage) { |
| 40 | await setPageParentPage(context, authentication, { |
| 41 | page: newPage, |
| 42 | parentPage, |
| 43 | prevFractionalIndex: parentPage.fractionalIndex ?? null, |
| 44 | nextIndex: null, |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | prevFractionalIndex = newPage.fractionalIndex; |
| 49 | |
| 50 | if (pageDefinition.nestedPages) { |
| 51 | await seedPages( |
| 52 | authentication, |
| 53 | pageDefinition.nestedPages, |
| 54 | webId, |
| 55 | sharedParams, |
| 56 | newPage, |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 | }; |
no test coverage detected