DocumentationAmertaPayloadUtilitiesFormatAuthorsFunctions

Format Authors

amerta


amerta / amerta/payload/utilities/formatAuthors / formatAuthors

Function: formatAuthors()

formatAuthors(authors): string | null | undefined

Defined in: amerta/payload/utilities/formatAuthors.ts:13

Formats an array of populatedAuthors from Posts into a prettified string.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | authors | { id?: string | null; name?: string | null; }[] | The populatedAuthors array from a Post. |

Returns

string | null | undefined

A prettified string of authors.

Example

[Author1, Author2] becomes 'Author1 and Author2'
[Author1, Author2, Author3] becomes 'Author1, Author2, and Author3'