Skip to content

Dynamic page titles #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/common/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TermsOfUseContent } from "@upswyng/common";
export default {
about: {
content: AboutContent.en,
title: "About - Upswyng",
},
alerts: {
closeAlerts: "Close Alerts",
Expand Down Expand Up @@ -38,6 +39,7 @@ export default {
localOnly:
"Favorites are only saved on this device. They will not be saved if you are using a public computer or when you have a private session enabled in your browser (incognito mode).",
noFavorites: "You haven't added any favorites yet!",
title: "Favorites - Upswyng",
},
footer: {
deploysByNetlify: "deploys by Netlify",
Expand Down Expand Up @@ -140,6 +142,11 @@ export default {
"If you, your children or someone else you know is seeking support for abuse, violence or other forms of oppression and discrimination, SPAN is here to help. From abusive relationships, domestic violence, interpersonal violence and elder abuse to oppression and discrimination based on sexual orientation, gender identity, ethnicity, race, religion, age, ability or income level, SPAN offers the support and resources needed to overcome these challenging circumstances.",
},
},
home: {
title: "Upswyng",
description:
"UpSwyng is a mobile-ready, digital directory of resources to assist the unhoused and at-risk communities.",
},
map: {
directions: "Directions",
directionsByBus: "Directions by bus",
Expand All @@ -158,6 +165,7 @@ export default {
},
privacyPolicy: {
content: PrivacyPolicyContent.en,
title: "Privacy Policy - Upswyng",
},
reportIssue: {
title: "Report an Issue",
Expand Down Expand Up @@ -237,6 +245,7 @@ export default {
},
termsOfUse: {
content: TermsOfUseContent.en,
title: "Terms of Use - Upswyng",
},
mainMenu: {
resourcesWithinReach: "Resources within reach",
Expand Down
9 changes: 9 additions & 0 deletions packages/common/src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TermsOfUseContent } from "@upswyng/common";
export default {
about: {
content: AboutContent.es,
title: "Acerca - UpSwyng",
},
alerts: {
closeAlerts: "Cerrar Alertas",
Expand Down Expand Up @@ -38,6 +39,7 @@ export default {
localOnly:
"Los favoritos solo se guardan en este dispositivo. No se guardarán si está utilizando una computadora pública o cuando tiene una sesión privada habilitada en su navegador (modo incógnito).",
noFavorites: "¡No has añadido ningún favorito todavía!",
title: "Favoritos - UpSwyng",
},
footer: {
deploysByNetlify: "despliegues por Netlify",
Expand Down Expand Up @@ -141,6 +143,11 @@ export default {
"Si usted, sus hijos o alguien más que conozca está buscando apoyo para el abuso, la violencia u otras formas de opresión y discriminación, SPAN está aquí para ayudarlo. Desde las relaciones abusivas, la violencia doméstica, la violencia interpersonal y el abuso de ancianos hasta la opresión y la discriminación basadas en la orientación sexual, la identidad de género, el origen étnico, la raza, la religión, la edad, la capacidad o el nivel de ingresos, SPAN ofrece el apoyo y los recursos necesarios para superar estas circunstancias difíciles.",
},
},
home: {
title: "Upswyng",
description:
"UpSwyng es un directorio digital para dispositivos móviles, que continue recursos para ayudar a personas que están a punto de perder su hogar o que ya se encuentran sin hogar.",
},
map: {
directions: "Direcciones",
directionsByBus: "Direcciones via bus",
Expand All @@ -160,6 +167,7 @@ export default {
},
privacyPolicy: {
content: PrivacyPolicyContent.es,
title: "Política de Privacidad - UpSwyng",
},
reportIssue: {
title: "Reportar un Problema",
Expand Down Expand Up @@ -240,6 +248,7 @@ export default {
},
termsOfUse: {
content: TermsOfUseContent.es,
title: "Condiciones De Uso - UpSwyng",
},
mainMenu: {
resourcesWithinReach: "Recursos al Alcance",
Expand Down
2 changes: 2 additions & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@types/react": "^16.8.10",
"@types/react-dom": "^16.8.3",
"@types/react-gtm-module": "^2.0.0",
"@types/react-helmet": "^6.1.4",
"@types/react-router-dom": "^5.1.0",
"@upswyng/common": "0.1.0",
"algoliasearch": "^3.33.0",
Expand All @@ -31,6 +32,7 @@
"react": "16.9.0",
"react-dom": "16.8.6",
"react-gtm-module": "^2.0.8",
"react-helmet": "^6.1.0",
"react-i18next": "^11.7.3",
"react-markdown": "^4.3.1",
"react-query": "^1.5.1",
Expand Down
5 changes: 0 additions & 5 deletions packages/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>UpSwyng</title>
<meta
name="description"
content="UpSwyng is a mobile-ready, digital directory of resources to assist the unhoused and at-risk communities in Boulder County, Colorado."
/>
<script
src="https://kit.fontawesome.com/131ea2b1bb.js"
crossorigin="anonymous"
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/About.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Container from "@material-ui/core/Container";
import { Helmet } from "react-helmet";
import MuiHtml from "./MuiHtml";
import React from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -8,6 +9,9 @@ const About = () => {

return (
<Container>
<Helmet>
<title>{t("title")}</title>
</Helmet>
<MuiHtml html={t("content")} />
</Container>
);
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/CategoryResults.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TResourceCategory, TResourceSubcategory } from "../webTypes";

import { Helmet } from "react-helmet";
import PageBanner from "./PageBanner";
import React from "react";
import ResourceList from "./ResourceList";
Expand Down Expand Up @@ -51,6 +52,9 @@ const CategoryResults = ({

return (
<>
<Helmet>
<title>{t(categoryTranslationKey)} - Upswyng</title>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on creating a utility that centralized appending the "- UpSwyng" to the title? Could create something like seo.js in the utils folder and create a makePageTitle that accepts a string as an argument and just returns that appended with - UpSwyng.

</Helmet>
<PageBanner color={categoryColor}>
<Typography variant="h1">{t(categoryTranslationKey)}</Typography>
</PageBanner>
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/FavoriteResources.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Alert from "@material-ui/lab/Alert";
import Container from "@material-ui/core/Container";
import { Helmet } from "react-helmet";
import PageBanner from "./PageBanner";
import React from "react";
import ResourceList from "./ResourceList";
Expand Down Expand Up @@ -34,6 +35,9 @@ export const FavoriteResources = () => {

return (
<Container>
<Helmet>
<title>{t("title")}</title>
</Helmet>
<PageBanner color={colors.orangePrimary}>
<Typography variant="h1">{t("favorites")}</Typography>
</PageBanner>
Expand Down
7 changes: 6 additions & 1 deletion packages/web/src/components/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import AlgoliaBadge from "./AlgoliaBadge";
import Container from "@material-ui/core/Container";
import { Grid } from "@material-ui/core";
import { Helmet } from "react-helmet";
import HomeButtons from "./HomeButtons";
import React from "react";
import SearchForm from "./SearchForm";
import { useTranslation } from "react-i18next";

const Home = () => {
const { t } = useTranslation("footer");
const { t } = useTranslation(["footer", "home"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another options could be removing the specific name space here and just applying it within the t function, e.g.:

const { t } = useTranslation();

// ...other stuff in between

<Helmet>
   <title>{t("home.title")}</title>
   <meta name="description" content={t("home.description")} />
</Helmet>

NBD either way but thought this may be a bit easier to read.

return (
<Container>
<Helmet>
<title>{t("title", { ns: "home" })}</title>
<meta name="description" content={t("description", { ns: "home" })} />
</Helmet>
<Grid
alignItems="stretch"
container
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/PrivacyPolicy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Container from "@material-ui/core/Container";
import { Helmet } from "react-helmet";
import MuiHtml from "./MuiHtml";
import React from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -8,6 +9,9 @@ const PrivacyPolicy = () => {

return (
<Container>
<Helmet>
<title>{t("title")}</title>
</Helmet>
<MuiHtml html={t("content")} />
</Container>
);
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Button from "@material-ui/core/Button/Button";
import Card from "@material-ui/core/Card";
import Container from "@material-ui/core/Container";
import FavoriteResourceFAB from "./FavoriteResourceFAB";
import { Helmet } from "react-helmet";
import Image from "material-ui-image";
import Link from "@material-ui/core/Link";
import List from "@material-ui/core/List";
Expand Down Expand Up @@ -97,6 +98,9 @@ export const Resource = () => {

return (
<Container>
<Helmet>
<title>{resource.name} - UpSwyng</title>
</Helmet>
<PageBanner
color={resourceColor}
backButtonAction={lastLocation ? history.goBack : null}
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/TermsOfUse.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Container from "@material-ui/core/Container";
import { Helmet } from "react-helmet";
import MuiHtml from "./MuiHtml";
import React from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -8,6 +9,9 @@ const TermsOfUse = () => {

return (
<Container>
<Helmet>
<title>{t("title")}</title>
</Helmet>
<MuiHtml html={t("content")} />
</Container>
);
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,13 @@
resolved "https://registry.yarnpkg.com/@types/react-gtm-module/-/react-gtm-module-2.0.0.tgz#25a118bbcadd518f376ee52626ab0829cb824874"
integrity sha512-2d7TUhOQBG6cSVSSSWaoSu+Ds84VQFTuVKLeGNc2GtfA7JDr+z3ujl4n/rezaRRNEhjn+9SllwHy1iNxxP8jDg==

"@types/react-helmet@^6.1.4":
version "6.1.4"
resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-6.1.4.tgz#3e54a3eb37ba7fb34ffafc64f425be4e68df03b9"
integrity sha512-jyx50RNZXVaTGHY3MsoRPNpeiVk8b0XTPgD/O6KHF6COTDnG/+lRjPYvTK5nfWtR3xDOux0w6bHLAsaHo2ZLTA==
dependencies:
"@types/react" "*"

"@types/react-i18next@^8.1.0":
version "8.1.0"
resolved "https://registry.yarnpkg.com/@types/react-i18next/-/react-i18next-8.1.0.tgz#5faacbfe7dc0f24729c1df6914610bfe861a50de"
Expand Down Expand Up @@ -13441,11 +13448,26 @@ react-error-overlay@^6.0.7:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.7.tgz#1dcfb459ab671d53f660a991513cb2f0a0553108"
integrity sha512-TAv1KJFh3RhqxNvhzxj6LeT5NWklP6rDr2a0jaTfsZ5wSZWHOGeqQyejUp3xxLfPt2UpyJEcVQB/zyPcmonNFA==

react-fast-compare@^3.1.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==

react-gtm-module@^2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/react-gtm-module/-/react-gtm-module-2.0.8.tgz#0d37c4f2a4e3a8efa40c76c8b2aa1b7cacc16c6f"
integrity sha512-OU5FwAHC3gWnnxJ+MLwBMLZO1Pmn1DiVCGHqptwDnNojE3QRrNxjqozkW5cNS4Zp+C6HZ8a4ZIt0QPNlpzua4Q==

react-helmet@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"
integrity sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==
dependencies:
object-assign "^4.1.1"
prop-types "^15.7.2"
react-fast-compare "^3.1.1"
react-side-effect "^2.1.0"

react-i18next@*, react-i18next@^11.7.3:
version "11.7.3"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.7.3.tgz#256461c46baf5b3208c3c6860ca4e569fc7ed053"
Expand Down Expand Up @@ -13719,6 +13741,11 @@ react-scripts@^3.3.0:
optionalDependencies:
fsevents "2.1.2"

react-side-effect@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3"
integrity sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==

react-test-renderer@16.9.0:
version "16.9.0"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.9.0.tgz#7ed657a374af47af88f66f33a3ef99c9610c8ae9"
Expand Down