2022-10-24 12:07:51 +08:00
|
|
|
import React from 'react';
|
2023-05-09 15:16:11 -07:00
|
|
|
import { Helmet } from 'react-helmet-async';
|
2022-10-24 12:07:51 +08:00
|
|
|
import { useEntityData } from '../entity/shared/EntityContext';
|
|
|
|
import { useEntityRegistry } from '../useEntityRegistry';
|
|
|
|
import { capitalizeFirstLetterOnly } from './textUtil';
|
|
|
|
|
|
|
|
export const EntityHead = () => {
|
|
|
|
const entityRegistry = useEntityRegistry();
|
|
|
|
const { entityType, entityData } = useEntityData();
|
|
|
|
|
|
|
|
if (!entityData) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const entityDisplayName = entityRegistry.getDisplayName(entityType, entityData);
|
|
|
|
const type =
|
|
|
|
capitalizeFirstLetterOnly(entityData?.subTypes?.typeNames?.[0]) || entityRegistry.getEntityName(entityType);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Helmet>
|
|
|
|
<title>
|
|
|
|
{entityDisplayName} | {type}
|
|
|
|
</title>
|
|
|
|
</Helmet>
|
|
|
|
);
|
|
|
|
};
|