DocumentHead
<DocumentHead /> is a React component used in assigning a title, unread count, link, or meta to the global application state. It also sets document.title on the client, based on those parameters.
Usage
Render the component, passing title, skipTitleFormatting, unreadCount, link or meta. It does not accept any children, nor does it render any elements to the page.
import DocumentHead from 'calypso/components/data/document-head';
export default function HomeSection() {
const count = 123;
const metas = [ { rel: 'some-rel', content: 'some-content' } ];
const links = [ { href: 'https://automattic.com', rel: 'some-rel' } ];
return (
<main>
<DocumentHead title="Home" link={ links } meta={ metas } unreadCount={ count } />
</main>
);
}
Props
title
The window title will be formatted using the title property plus some other internal application state (like the application name, or the number of unread messages). Pass skipTitleFormatting=true if you want to set the window title without any extra formatting.
| Type | String |
| Required | No |
| Default | "" |
skipTitleFormatting
| Type | Boolean |
| Required | No |
| Default | false |
unreadCount
| Type | Number |
| Required | No |
| Default | 0 |
meta
| Type | Array of objects |
| Required | No |
link
| Type | Array of objects |
| Required | No |