cleanPage
The cleanPage function prepares the page content retrieved by React Bricks APIs to be used in the PageViewer
component.
It removes all the invalid blocks (unknown in the schema or not allowed for this page type).
Signature
const cleanPage = (
page: types.Page,
pageTypes: types.IPageType[],
bricks: types.Bricks
): types.Page
Property | Definition |
---|---|
page | The page object, of type Page . |
pageTypes | The pageType schema, of type IPageType[] , as defined here. |
bricks | The block's schema, of type IBlockType[] , as defined here. |
Return value
cleanPage
returns an object of type Page
, with the clean content and the invalidBlocksTypes
array containing the name of each invalid block that was removed.
Usage example
fetchPage('about-us', 'API_KEY').then((data) => {
const myPage = cleanPage(data, pageTypes, bricks)
console.log(myPage.content)
})