|
1 | 1 | /**
|
2 | 2 | * External dependencies
|
3 | 3 | */
|
4 |
| -import { upperFirst, camelCase, map, find, get, startCase } from 'lodash'; |
| 4 | +import { capitalCase, pascalCase } from 'change-case'; |
| 5 | +import { map, find, get } from 'lodash'; |
5 | 6 |
|
6 | 7 | /**
|
7 | 8 | * WordPress dependencies
|
@@ -457,7 +458,9 @@ async function loadPostTypeEntities() {
|
457 | 458 | getTitle: ( record ) =>
|
458 | 459 | record?.title?.rendered ||
|
459 | 460 | record?.title ||
|
460 |
| - ( isTemplate ? startCase( record.slug ) : String( record.id ) ), |
| 461 | + ( isTemplate |
| 462 | + ? capitalCase( record.slug ?? '' ) |
| 463 | + : String( record.id ) ), |
461 | 464 | __unstablePrePersist: isTemplate ? undefined : prePersistPostType,
|
462 | 465 | __unstable_rest_base: postType.rest_base,
|
463 | 466 | };
|
@@ -511,12 +514,11 @@ export const getMethodName = (
|
511 | 514 | usePlural = false
|
512 | 515 | ) => {
|
513 | 516 | const entityConfig = find( rootEntitiesConfig, { kind, name } );
|
514 |
| - const kindPrefix = kind === 'root' ? '' : upperFirst( camelCase( kind ) ); |
515 |
| - const nameSuffix = |
516 |
| - upperFirst( camelCase( name ) ) + ( usePlural ? 's' : '' ); |
| 517 | + const kindPrefix = kind === 'root' ? '' : pascalCase( kind ); |
| 518 | + const nameSuffix = pascalCase( name ) + ( usePlural ? 's' : '' ); |
517 | 519 | const suffix =
|
518 | 520 | usePlural && 'plural' in entityConfig! && entityConfig?.plural
|
519 |
| - ? upperFirst( camelCase( entityConfig.plural ) ) |
| 521 | + ? pascalCase( entityConfig.plural ) |
520 | 522 | : nameSuffix;
|
521 | 523 | return `${ prefix }${ kindPrefix }${ suffix }`;
|
522 | 524 | };
|
|
0 commit comments