Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display decoded HTML entities in PostPrimaryCategory component #342

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/post-primary-term/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { usePrimaryTerm } from '../../hooks';

interface PostPrimaryTermProps {
Expand Down Expand Up @@ -50,5 +51,5 @@ export const PostPrimaryTerm = ({
wrapperProps.href = termUrl;
}

return <Tag {...wrapperProps}>{termString}</Tag>;
return <Tag {...wrapperProps}>{decodeEntities(termString)}</Tag>;
};
14 changes: 14 additions & 0 deletions example/src/blocks/primary-category/block.json
Original file line number Diff line number Diff line change
@@ -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"
}
12 changes: 12 additions & 0 deletions example/src/blocks/primary-category/edit.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div {...blockProps}>
<PostPrimaryCategory />
</div>
)
};
9 changes: 9 additions & 0 deletions example/src/blocks/primary-category/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { registerBlockType } from '@wordpress/blocks';
import metadata from './block.json';
import { BlockEdit } from './edit';


registerBlockType( metadata, {
edit: BlockEdit,
save: () => null
});
Loading