More complex title templates
See original GitHub issueFeature request
In my application I have a top-level Helmet
component which renders the default title, twitter and open graph meta tags. I have pages, each of which renders a Helmet
component with some custom text, and I have a global Navbar
which has the state of the unread notifications which I want to display in the title.
Essentially, I want my title to look like this: (1) Subpage | MyApp
.
The issue is that the title template doesn’t allow me to have custom titles from the pages and also the unread notification count, so it’d show either Subpage | MyApp
or (1) | MyApp
, but I can’t have both 😢
Is there a way we could adapt the API to make more complex title theming possible? Would be happy to submit a PR if I get some pointers, or maybe I am missing some existing feature that makes this possible?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:16
- Comments:12 (2 by maintainers)
Would be really interested in this as well, my use case is slightly simpler (I would like nested titleTemplate so my page title can be “Nested | Child | MainTitle”) which comes from something like :
@mxstbr @jaysoo Hey, I just published a tiny library react-titled that supports more complex nesting. It uses the new context API that comes with React 16.3.
You can use it as
outputs
Hope you find it useful. 😃
react-helmet is still really great for other
<head>
tags where composing is not needed. I think it doesn’t make sense to dramatically change react-helmet’s API to support that so I’ve create a new lib.