From d7f22bea406d3f58adba0d569d06bff3cacabb20 Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 29 Aug 2024 17:42:28 -0700 Subject: [PATCH 1/2] decode html entities in primary term component --- components/post-primary-term/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/post-primary-term/index.tsx b/components/post-primary-term/index.tsx index c2900226..af287fd7 100644 --- a/components/post-primary-term/index.tsx +++ b/components/post-primary-term/index.tsx @@ -1,4 +1,5 @@ import { __ } from '@wordpress/i18n'; +import { decodeEntities } from '@wordpress/html-entities'; import { usePrimaryTerm } from '../../hooks'; interface PostPrimaryTermProps { @@ -50,5 +51,5 @@ export const PostPrimaryTerm = ({ wrapperProps.href = termUrl; } - return {termString}; + return {decodeEntities(termString)}; }; From fe7390ebd0429bdd2e8e4b7ff326214d45a11157 Mon Sep 17 00:00:00 2001 From: Peter Sorensen Date: Thu, 29 Aug 2024 17:42:53 -0700 Subject: [PATCH 2/2] adds simple primary term block for demo --- example/src/blocks/primary-category/block.json | 14 ++++++++++++++ example/src/blocks/primary-category/edit.tsx | 12 ++++++++++++ example/src/blocks/primary-category/index.ts | 9 +++++++++ 3 files changed, 35 insertions(+) create mode 100644 example/src/blocks/primary-category/block.json create mode 100644 example/src/blocks/primary-category/edit.tsx create mode 100644 example/src/blocks/primary-category/index.ts diff --git a/example/src/blocks/primary-category/block.json b/example/src/blocks/primary-category/block.json new file mode 100644 index 00000000..0bb428e0 --- /dev/null +++ b/example/src/blocks/primary-category/block.json @@ -0,0 +1,14 @@ +{ + "apiVersion": 3, + "name": "example/primary-category", + "title": "Post Primary Category", + "icon": "archive", + "category": "common", + "example": {}, + "supports": { + "html": false + }, + "attributes": {}, + "variations": [], + "editorScript": "file:./index.ts" +} \ No newline at end of file diff --git a/example/src/blocks/primary-category/edit.tsx b/example/src/blocks/primary-category/edit.tsx new file mode 100644 index 00000000..ee42fba5 --- /dev/null +++ b/example/src/blocks/primary-category/edit.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { useBlockProps } from '@wordpress/block-editor'; +import { PostPrimaryCategory } from '@10up/block-components'; + +export const BlockEdit = ({context}) => { + const blockProps = useBlockProps(); + return ( +
+ +
+ ) +}; \ No newline at end of file diff --git a/example/src/blocks/primary-category/index.ts b/example/src/blocks/primary-category/index.ts new file mode 100644 index 00000000..d06ab1b1 --- /dev/null +++ b/example/src/blocks/primary-category/index.ts @@ -0,0 +1,9 @@ +import { registerBlockType } from '@wordpress/blocks'; +import metadata from './block.json'; +import { BlockEdit } from './edit'; + + +registerBlockType( metadata, { + edit: BlockEdit, + save: () => null +});