diff --git a/examples/my-gatsby-site/src/templates/SamplePage.tsx b/examples/my-gatsby-site/src/templates/SamplePage.tsx index 283da68f..918f7ad4 100644 --- a/examples/my-gatsby-site/src/templates/SamplePage.tsx +++ b/examples/my-gatsby-site/src/templates/SamplePage.tsx @@ -25,7 +25,7 @@ const SamplePage: JaenTemplate = () => {

IndexField

{Object.keys(page.children)}
} + onRender={(page, pageId) =>
{Object.keys(page.children)}
} />
diff --git a/packages/jaen-pages/src/containers/fields/IndexField/index.tsx b/packages/jaen-pages/src/containers/fields/IndexField/index.tsx index 2f2b55fc..b149ea6b 100644 --- a/packages/jaen-pages/src/containers/fields/IndexField/index.tsx +++ b/packages/jaen-pages/src/containers/fields/IndexField/index.tsx @@ -5,18 +5,19 @@ import {withRedux} from '@store/withRedux' interface IndexFieldProps { fixedSlug?: string - onRender: (page: ResolvedPageType) => JSX.Element + onRender: (page: ResolvedPageType, pageId: string) => JSX.Element } const IndexField: React.FC = props => { const {jaenPageContext} = useTemplate() - const page = useResolvedPage(props.fixedSlug || jaenPageContext.id) + const pageId = props.fixedSlug || jaenPageContext.id + const page = useResolvedPage(pageId) if (!page) { - throw new Error(`Page not found: ${props.fixedSlug || jaenPageContext.id}`) + throw new Error(`Page not found!: ${pageId}`) } - return props.onRender(page) + return props.onRender(page, pageId) } export default withRedux(IndexField) diff --git a/packages/jaen-pages/src/contexts/cms.tsx b/packages/jaen-pages/src/contexts/cms.tsx index 7cd8a0c0..b2f3cbee 100644 --- a/packages/jaen-pages/src/contexts/cms.tsx +++ b/packages/jaen-pages/src/contexts/cms.tsx @@ -234,6 +234,7 @@ export const CMSProvider: React.FC = ({ const id = jaenPageContext?.id || node.id site.allSitePage.nodes[id] = { + id, parent: jaenPageContext?.parent || null, children: jaenPageContext?.children || [], path: node.path, diff --git a/packages/jaen-pages/src/types.ts b/packages/jaen-pages/src/types.ts index bd3ae671..2f8600fc 100644 --- a/packages/jaen-pages/src/types.ts +++ b/packages/jaen-pages/src/types.ts @@ -98,6 +98,7 @@ export type PageMetadata = { } type BasePageType = { + id: string slug: string pageMetadata?: PageMetadata images: {