add title
This commit is contained in:
parent
e7284d29c8
commit
4d03b243e3
1 changed files with 599 additions and 171 deletions
21
src/shared/metadataUtils.ts
Normal file
21
src/shared/metadataUtils.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { BaseMetadata } from "../types.js";
|
||||
|
||||
/**
|
||||
* Utilities for working with BaseMetadata objects.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the display name for an object with BaseMetadata.
|
||||
* Returns the title if available, otherwise falls back to name.
|
||||
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
|
||||
*/
|
||||
export function getDisplayName(metadata: BaseMetadata): string {
|
||||
return metadata.title ?? metadata.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an object has a custom title different from its name.
|
||||
*/
|
||||
export function hasCustomTitle(metadata: BaseMetadata): boolean {
|
||||
return metadata.title !== undefined && metadata.title !== metadata.name;
|
||||
}
|
||||
Loading…
Reference in a new issue