diff --git a/example/src/blocks/post-meta/block.json b/example/src/blocks/post-meta/block.json index 78afc849..12ad61ed 100644 --- a/example/src/blocks/post-meta/block.json +++ b/example/src/blocks/post-meta/block.json @@ -9,5 +9,9 @@ "default": "" } }, + "usesContext": [ + "postId", + "postType" + ], "editorScript": "file:./index.js" } \ No newline at end of file diff --git a/example/src/blocks/post-meta/edit.js b/example/src/blocks/post-meta/edit.js index ae9d8999..bf11bedd 100644 --- a/example/src/blocks/post-meta/edit.js +++ b/example/src/blocks/post-meta/edit.js @@ -5,10 +5,11 @@ import { store as blockEditorStore, } from '@wordpress/block-editor'; import { useSelect, useDispatch } from '@wordpress/data'; -import { PostMeta } from '@10up/block-components'; +import { PostMeta, PostContext } from '@10up/block-components'; export const BlockEdit = (props) => { - const { attributes, setAttributes, name } = props; + const { attributes, setAttributes, name, context } = props; + const { postId, postType } = context; const { metaKey } = attributes; const blockProps = useBlockProps(); @@ -46,7 +47,9 @@ export const BlockEdit = (props) => { return (