Skip to content

Commit

Permalink
Hide word count and reading time meta data for the Posts Page details…
Browse files Browse the repository at this point in the history
… panel (#52186)

* Hide word count and reading time meta data for the Posts Page details panel

* Apply suggestions from code review.
  • Loading branch information
juanfra authored Jul 3, 2023
1 parent afa9979 commit 96a8929
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function getPageDetails( page ) {
: 0;
const readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );

if ( wordsCounted ) {
if ( wordsCounted && ! page?.isPostsPage ) {
details.push(
{
label: __( 'Words' ),
Expand All @@ -100,7 +100,7 @@ function getPageDetails( page ) {

export default function PageDetails( { id } ) {
const { record } = useEntityRecord( 'postType', 'page', id );
const { parentTitle, templateTitle } = useSelect(
const { parentTitle, templateTitle, isPostsPage } = useSelect(
( select ) => {
const { getEditedPostContext } = unlock( select( editSiteStore ) );
const postContext = getEditedPostContext();
Expand Down Expand Up @@ -135,12 +135,16 @@ export default function PageDetails( { id } ) {
)?.title?.rendered
: null;

const { getEntityRecord } = select( coreStore );
const siteSettings = getEntityRecord( 'root', 'site' );

return {
parentTitle: _parentTitle,
templateTitle: _templateTitle,
isPostsPage: record?.id === siteSettings?.page_for_posts,
};
},
[ record?.parent ]
[ record?.parent, record?.id ]
);
return (
<SidebarNavigationScreenDetailsPanel
Expand All @@ -150,6 +154,7 @@ export default function PageDetails( { id } ) {
{ getPageDetails( {
parentTitle,
templateTitle,
isPostsPage,
...record,
} ).map( ( { label, value } ) => (
<SidebarNavigationScreenDetailsPanelRow key={ label }>
Expand Down

0 comments on commit 96a8929

Please sign in to comment.