20 lines
803 B
JavaScript
20 lines
803 B
JavaScript
/** Which part comes first in a composed title. */ /**
|
|
* Composes a full document title from a page title and the site name.
|
|
*
|
|
* - both, page-first: "About Us | Acme Inc"
|
|
* - both, site-first: "Acme Inc | About Us"
|
|
* - page only: "About Us"
|
|
* - site only: "Acme Inc"
|
|
* - neither: ""
|
|
*
|
|
* Pure function — no dependency on Payload or request state.
|
|
*/ export function composeTitle({ order = 'page-first', pageTitle, separator = ' | ', siteName }) {
|
|
const page = pageTitle?.trim();
|
|
const site = siteName?.trim();
|
|
if (page && site) {
|
|
return order === 'site-first' ? `${site}${separator}${page}` : `${page}${separator}${site}`;
|
|
}
|
|
return page || site || '';
|
|
} //# sourceMappingURL=composeTitle.js.map
|
|
|
|
//# sourceMappingURL=composeTitle.js.map
|