Skip to content

Commit a5f1e16

Browse files
author
John Richard Chipps-Harding
authored
Handle same title (#3)
1 parent 16d9dc5 commit a5f1e16

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ export default App;
5757

5858
### <MetaHeadEmbed />
5959

60-
| Property | Type | Required | Notes |
61-
| ----------------- | -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
62-
| **pageTitle** | string | **Yes** | Every page should have a unique title that describes the page, such as 'Home', 'About' etc. |
63-
| **siteTitle** | string | **Yes** | Title of the site, usually the organization / brand name. |
64-
| **titleTemplate** | string | **No** | Title template used to display `pageTitle` and `siteTitle` in a template, displays the values using corresponding `[pageTitle]` and `[siteTitle]`. Example template: "[pageTitle] | [siteTitle]". |
65-
| **description** | string | **Yes** | A one to two sentence description of your webpage. Keep it within 160 characters, and write it to catch the user's attention. |
66-
| **pageUrl** | string | **Yes** | Url of site page being shared. |
67-
| **canonicalUrl** | string | **Yes** | The canonical URL of your webpage that will be used as its default app URL. |
68-
| **keywords** | string|string[] | **Yes** | List of SEO keywords describing what your webpage does. For example, `"your, tags"` or `["your", "tags"]`. |
69-
| **imageUrl** | string | **Yes** | Image url of asset to share. Recommended aspect ratio for landscape is 1.9:1 (1200x630) or for squares 1:1 (1200x1200). For more info, visit [here](https://iamturns.com/open-graph-image-size/). |
70-
| **imageAlt** | string | **Yes** | Image alt for users who are visually impaired. |
71-
| **locale** | string | **No** | The locale these tags are marked up in, such as; `en_GB`, `fr_FR` and `es_ES`. Defaults to `en_US`. |
60+
| Property | Type | Required | Notes |
61+
| ----------------- | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62+
| **pageTitle** | string | **Yes** | Every page should have a unique title that describes the page, such as 'Home', 'About' etc. |
63+
| **siteTitle** | string | **Yes** | Title of the site, usually the organization / brand name. |
64+
| **titleTemplate** | string | **No** | Title template used to display `pageTitle` and `siteTitle` in a template, displays the values using corresponding `[pageTitle]` and `[siteTitle]`. Example template: "[pageTitle] | [siteTitle]". Note, if `pageTitle` and `siteTitle` are the same only the `siteTitle` is output. |
65+
| **description** | string | **Yes** | A one to two sentence description of your webpage. Keep it within 160 characters, and write it to catch the user's attention. |
66+
| **pageUrl** | string | **Yes** | Url of site page being shared. |
67+
| **canonicalUrl** | string | **Yes** | The canonical URL of your webpage that will be used as its default app URL. |
68+
| **keywords** | string|string[] | **Yes** | List of SEO keywords describing what your webpage does. For example, `"your, tags"` or `["your", "tags"]`. |
69+
| **imageUrl** | string | **Yes** | Image url of asset to share. Recommended aspect ratio for landscape is 1.9:1 (1200x630) or for squares 1:1 (1200x1200). For more info, visit [here](https://iamturns.com/open-graph-image-size/). |
70+
| **imageAlt** | string | **Yes** | Image alt for users who are visually impaired. |
71+
| **locale** | string | **No** | The locale these tags are marked up in, such as; `en_GB`, `fr_FR` and `es_ES`. Defaults to `en_US`. |
7272

7373
To add all page meta properties, add `MetaHeadEmbed` to the `head` of the page.
7474

src/components/MetaHeadEmbed.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ const MetaHeadEmbed = ({
6464
typeof keywords === "string" ? keywords : keywords?.join(", ");
6565

6666
const title = titleTemplate
67-
? titleTemplate
68-
.replace("[pageTitle]", pageTitle)
69-
.replace("[siteTitle]", siteTitle)
67+
? pageTitle === siteTitle
68+
? pageTitle
69+
: titleTemplate
70+
.replace("[pageTitle]", pageTitle)
71+
.replace("[siteTitle]", siteTitle)
7072
: pageTitle;
7173

7274
return (

0 commit comments

Comments
 (0)