Skip to content

Commit

Permalink
Use BasePostWithEmbeddedAuthor
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 13, 2024
1 parent 1f27c34 commit 23c43f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/fields/src/fields/author/author-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import type { User } from '@wordpress/core-data';
/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import type { BasePostWithEmbeddedAuthor } from '../../types';

function AuthorView( { item }: { item: BasePost } ) {
function AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {
const { text, imageUrl } = useSelect(
( select ) => {
const { getEntityRecord } = select( coreStore );
Expand Down
4 changes: 2 additions & 2 deletions packages/fields/src/fields/author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import type { BasePostWithEmbeddedAuthor } from '../../types';
import AuthorView from './author-view';

const authorField: Field< BasePost > = {
const authorField: Field< BasePostWithEmbeddedAuthor > = {
label: __( 'Author' ),
id: 'author',
type: 'integer',
Expand Down
10 changes: 7 additions & 3 deletions packages/fields/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ interface Links {

interface Author {
name: string;
avatar_urls: Record< string, string >;
}

interface Embedded {
author?: Author[];
interface EmbeddedAuthor {
author: Author[];
}

export interface BasePost extends CommonPost {
Expand All @@ -48,7 +49,10 @@ export interface BasePost extends CommonPost {
date?: string;
modified?: string;
author?: number;
_embedded?: Embedded;
}

export interface BasePostWithEmbeddedAuthor extends BasePost {
_embedded: EmbeddedAuthor;
}

export interface Template extends CommonPost {
Expand Down

0 comments on commit 23c43f7

Please sign in to comment.