Skip to content

Commit

Permalink
Release 3.0.0
Browse files Browse the repository at this point in the history
Updated README to reflect new API and use cases for new feature - defaultTitle
  • Loading branch information
cwelch5 committed Mar 25, 2016
1 parent 8e81d51 commit b4696aa
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [3.0.0](#300)
- [2.3.1](#231)
- [2.3.0](#230)
- [2.2.0](#220)
Expand All @@ -18,6 +19,18 @@
- [1.0.0](#100)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## 3.0.0

Features:

- innerHTML for scripts. Originally added to support the use of JSON-LD (https://developers.google.com/schemas/formats/json-ld?hl=en), but this can be used for any inline scripts you would like in your document head.
- New htmlAttributes prop which allows users to add attributes to their html tag. For now, "lang" and "amp" are supported.
- New defaultTitle prop which allows users to have a fallback title in the scenario where a Helmet wants to define a titleTemplate for it's nested routes, but not for itself (for example, at the root component level). See README for use cases.

Bugfixes:

- Removed all polyfills from Helmet. Due to reported conflicts, to remove bloat, and to encourage users to polyfill at the application level. Please double-check that you weren't relying solely on Helmet for polyfilling certain features.

## 2.3.1

Bugfixes:
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function Application () {
htmlAttributes={{"lang": "en", "amp": undefined}} // amp takes no value
title="My Title"
titleTemplate="MySite.com - %s"
defaultTitle="My Default Title"
base={{"target": "_blank", "href": "http://mysite.com/"}}
meta={[
{"name": "description", "content": "Helmet application"},
Expand Down Expand Up @@ -244,6 +245,42 @@ function HTML () {
</head>
```

6. defaultTitle will be used as a fallback when the template does not want to be used in the current Helmet
```javascript
<Helmet
defaultTitle="My Site"
titleTemplate="My Site - %s"
/>
```
Yields:
```
<head>
<title>My Site</title>
</head>
```

But a child route with a title will use the titleTemplate, giving users a way to declare a titleTemplate for their app, but not have it apply to the root.

```javascript
<Helmet
defaultTitle="My Site"
titleTemplate="My Site - %s"
/>

<Helmet
title="Nested Title"
/>
```
Yields:
```
<head>
<title>My Site - Nested Title</title>
</head>
```

And other child route components without a Helmet will inherit the defaultTitle.


## Contributing to this project
Please take a moment to review the [guidelines for contributing](CONTRIBUTING.md).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-helmet",
"description": "A document head manager for React",
"version": "2.3.1",
"version": "3.0.0",
"main": "./lib/Helmet.js",
"author": "NFL <engineers@nfl.com>",
"contributors": [
Expand Down
6 changes: 4 additions & 2 deletions src/test/HelmetTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ describe("Helmet", () => {
describe("title", () => {
it("can update page title", () => {
ReactDOM.render(
<Helmet title={"Test Title"}
defaultTitle={"Fallback"} />,
<Helmet
title={"Test Title"}
defaultTitle={"Fallback"}
/>,
container
);

Expand Down

0 comments on commit b4696aa

Please sign in to comment.