diff --git a/packages/editor/src/components/post-card-panel/index.js b/packages/editor/src/components/post-card-panel/index.js index 5804d0955b94be..f51a612572a1ea 100644 --- a/packages/editor/src/components/post-card-panel/index.js +++ b/packages/editor/src/components/post-card-panel/index.js @@ -28,42 +28,52 @@ import { import { unlock } from '../../lock-unlock'; export default function PostCardPanel( { actions } ) { - const { title, icon, isSync } = useSelect( ( select ) => { - const { - getEditedPostAttribute, - getCurrentPostType, - getCurrentPostId, - __experimentalGetTemplateInfo, - } = select( editorStore ); - const { getEditedEntityRecord } = select( coreStore ); - const _type = getCurrentPostType(); - const _id = getCurrentPostId(); - const _record = getEditedEntityRecord( 'postType', _type, _id ); - const _templateInfo = - [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes( _type ) && - __experimentalGetTemplateInfo( _record ); - let _isSync = false; - if ( GLOBAL_POST_TYPES.includes( _type ) ) { - if ( PATTERN_POST_TYPE === _type ) { - // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead. - const currentSyncStatus = - getEditedPostAttribute( 'meta' )?.wp_pattern_sync_status === - 'unsynced' - ? 'unsynced' - : getEditedPostAttribute( 'wp_pattern_sync_status' ); - _isSync = currentSyncStatus !== 'unsynced'; - } else { - _isSync = true; + const { isFrontPage, isPostsPage, title, icon, isSync } = useSelect( + ( select ) => { + const { + getEditedPostAttribute, + getCurrentPostType, + getCurrentPostId, + __experimentalGetTemplateInfo, + } = select( editorStore ); + const { getEditedEntityRecord } = select( coreStore ); + const siteSettings = getEditedEntityRecord( 'root', 'site' ); + const _type = getCurrentPostType(); + const _id = getCurrentPostId(); + const _record = getEditedEntityRecord( 'postType', _type, _id ); + const _templateInfo = + [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes( + _type + ) && __experimentalGetTemplateInfo( _record ); + let _isSync = false; + if ( GLOBAL_POST_TYPES.includes( _type ) ) { + if ( PATTERN_POST_TYPE === _type ) { + // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead. + const currentSyncStatus = + getEditedPostAttribute( 'meta' ) + ?.wp_pattern_sync_status === 'unsynced' + ? 'unsynced' + : getEditedPostAttribute( + 'wp_pattern_sync_status' + ); + _isSync = currentSyncStatus !== 'unsynced'; + } else { + _isSync = true; + } } - } - return { - title: _templateInfo?.title || getEditedPostAttribute( 'title' ), - icon: unlock( select( editorStore ) ).getPostIcon( _type, { - area: _record?.area, - } ), - isSync: _isSync, - }; - }, [] ); + return { + title: + _templateInfo?.title || getEditedPostAttribute( 'title' ), + icon: unlock( select( editorStore ) ).getPostIcon( _type, { + area: _record?.area, + } ), + isSync: _isSync, + isFrontPage: siteSettings?.page_on_front === _id, + isPostsPage: siteSettings?.page_for_posts === _id, + }; + }, + [] + ); return (