forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add page specific head title (airbytehq#3526)
* Add @types/react-helmet * Add page specific head title * Add head titles for onboarding and preference pages * Align react-helmet version to 6.1.0 * Refactor head title to support chained titles * Move head title out of step menu definition * Unify imports
- Loading branch information
Showing
23 changed files
with
177 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import { Helmet } from "react-helmet"; | ||
import { useIntl } from "react-intl"; | ||
|
||
const AIRBYTE = "Airbyte"; | ||
const SEPARATOR = "|"; | ||
|
||
type FormattedHeadTitle = { | ||
id: string; | ||
values?: Record<string, string>; | ||
}; | ||
|
||
type StringHeadTitle = { | ||
title: string; | ||
}; | ||
|
||
type HeadTitleDefinition = FormattedHeadTitle | StringHeadTitle; | ||
|
||
const isStringTitle = (v: HeadTitleDefinition): v is StringHeadTitle => { | ||
return "title" in v; | ||
}; | ||
|
||
type IProps = { | ||
titles: HeadTitleDefinition[]; | ||
}; | ||
|
||
/** | ||
* Titles defined by {@link HeadTitleDefinition} will be | ||
* chained together with the {@link SEPARATOR}. | ||
*/ | ||
const HeadTitle: React.FC<IProps> = ({ titles }) => { | ||
const intl = useIntl(); | ||
|
||
const getTitle = (d: HeadTitleDefinition): string => { | ||
return isStringTitle(d) | ||
? d.title | ||
: intl.formatMessage({ id: d.id }, d.values); | ||
}; | ||
|
||
const headTitle = titles.map(getTitle).join(` ${SEPARATOR} `); | ||
return ( | ||
<Helmet titleTemplate={`${AIRBYTE} ${SEPARATOR} %s`} defaultTitle={AIRBYTE}> | ||
<title>{headTitle}</title> | ||
</Helmet> | ||
); | ||
}; | ||
|
||
export default HeadTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import HeadTitle from "./HeadTitle"; | ||
|
||
export default HeadTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.