@wordpress/block-library
Version:
Block library for the WordPress editor.
22 lines (21 loc) • 805 B
JavaScript
import { useBlockProps } from "@wordpress/block-editor";
import { usePostCommentsCount } from "../utils/hooks.mjs";
import { jsx } from "react/jsx-runtime";
// packages/block-library/src/post-comments-count/edit.jsx
function PostCommentsCountEdit({ context }) {
const { postId } = context;
const { totalItems: commentsCount } = usePostCommentsCount(postId);
const blockProps = useBlockProps();
const hasPostAndComments = postId && commentsCount !== null;
const blockStyles = {
...blockProps.style,
textDecoration: hasPostAndComments ? blockProps.style?.textDecoration : void 0
};
return /* @__PURE__ */ jsx("div", {
...blockProps,
style: blockStyles,
children: hasPostAndComments ? commentsCount : "0"
});
}
export { PostCommentsCountEdit as default };
//# sourceMappingURL=edit.mjs.map