Skip to content

Commit

Permalink
fix: adjust page generator after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurTriis1 committed Jan 13, 2025
1 parent 4aaedb3 commit a0fbd79
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/cli/src/utils/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,27 @@ const getPluginPageFileContent = (
// GENERATED FILE
// @ts-nocheck
import * as page from 'src/plugins/${pluginName}/pages/${pageName}';
${appLayout ? `import GlobalSections, { getGlobalSectionsData } from 'src/components/cms/GlobalSections'` : ``}
${appLayout ? `import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'` : ``}
${appLayout ? `import RenderSections from 'src/components/cms/RenderSections'` : ``}
export async function getServerSideProps(${appLayout ? '{ previewData, ...otherProps }' : 'otherProps'}) {
const noop = async function() {}
const loaderData = await (page.loader || noop)(otherProps)
${appLayout ? `const globalSections = await getGlobalSectionsData(previewData)` : ``}
${appLayout ? `const { sections = [] } = await getGlobalSectionsData(previewData)` : ``}
return {
props: {
data: loaderData,
${appLayout ? 'globalSections: globalSections' : ``}
${appLayout ? 'globalSections: sections' : ``}
}
}
}
export default function Page(props) {
${
appLayout
? `return <GlobalSections {...props.globalSections}>
? `return <RenderSections globalSections={props.globalSections}>
{page.default(props.data)}
</GlobalSections>`
</RenderSections>`
: `return page.default(props.data)`
}
}
Expand Down

0 comments on commit a0fbd79

Please sign in to comment.