usePageValues
const usePageValues = (): [ types.PageValues, (pageData: types.PartialPage) => void]
Hook with no arguments that returns a [pageValues, setPageValues]
array.
pageValues
is an object with the values you see belowsetPageValues
is a function to set the values (which will merge the object one level deep).
On the frontend Viewer the setPage function performs no acton. In that case you should take just the first element with the pageValues.
Values
The values you can access are:
{ id: string type: string name: string slug: string meta: { title?: string description?: string language?: string featuredImage?: string } authorId?: string author: Author invalidBlocksTypes?: string[] status: PageStatus isLocked: boolean tags: string[] createdAt: string publishedAt?: string}
See the Page type and IMeta interface
Example usage
const [page, setPage] = usePageValues()// Set meta title equal to the "title" props anytime it changesuseEffect(() => { setPage({ meta: { ...page.meta, title: typeof title === 'string' ? title : Plain.serialize(title), }, })}, [title])return ( <div> Created at {moment(page.createdAt).format('MM/DD/YYYY')}. </div>)