Skip to content

Commit fde7c2f

Browse files
authored
unifying the logic for fetching and setting the document title across the application (#670)
1 parent a89039c commit fde7c2f

File tree

70 files changed

+21599
-27833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+21599
-27833
lines changed

.output.txt

Lines changed: 4538 additions & 0 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 15298 additions & 26210 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"@types/jest": "^29.5.13",
9797
"@types/react-router-dom": "^5.3.3",
9898
"@types/styled-components": "^5.1.34",
99-
"eslint": "^8.57.1",
10099
"gh-pages": "^6.3.0",
101100
"prettier": "^3.5.1",
102101
"react-ga": "^3.3.1",

src/2023/Cfp/CfpSection2023.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("CfpSection2023", () => {
9898
render(<CfpSection2023 />);
9999
await waitFor(() => {
100100
expect(document.title).toBe(
101-
`CFP Committee - DevBcn - ${conferenceData.edition}`,
101+
`CFP Committee DevBcn - Barcelona Developers Conference — ${conferenceData.edition}`,
102102
);
103103
});
104104
});

src/2023/Cfp/CfpSection2023.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
StyledAboutImage,
2222
StyledSocialIconsWrapper,
2323
} from "../../views/About/components/Style.AboutCard";
24+
import { useDocumentTitleUpdater } from "../../hooks/useDocumentTitleUpdate";
2425

2526
const TrackName = styled.h2`
2627
padding-top: 1.2rem;
@@ -75,9 +76,8 @@ const CfpTrackComponent: FC<React.PropsWithChildren<CfpTrackProps>> = ({
7576

7677
const CfpSection2023: FC<React.PropsWithChildren<unknown>> = () => {
7778
const { width } = useWindowSize();
78-
React.useEffect(() => {
79-
document.title = `CFP Committee - DevBcn - ${conferenceData.edition}`;
80-
}, []);
79+
80+
useDocumentTitleUpdater("CFP Committee", conferenceData.edition);
8181
return (
8282
<>
8383
<SectionWrapper color={Color.WHITE} marginTop={5}>

src/2023/Communities/Communities2023.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from "styled-components";
33
import TwitterIcon from "../../components/Icons/Twitter";
44
import { Color } from "../../styles/colors";
55
import WebsiteIcon from "../../components/Icons/website";
6+
import { useDocumentTitleUpdater } from "../../hooks/useDocumentTitleUpdate";
67

78
const Heading = styled.h1`
89
padding-top: 10rem;
@@ -29,9 +30,7 @@ const FoSS = styled.div`
2930
`;
3031

3132
const Communities2023: FC<React.PropsWithChildren<unknown>> = () => {
32-
React.useEffect(() => {
33-
document.title = "Communities";
34-
});
33+
useDocumentTitleUpdater("Communities", "2023");
3534
return (
3635
<>
3736
<Heading>FOSS & Diversity Communities</Heading>

src/2023/Diversity/Diversity2023.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useEffect } from "react";
1+
import { FC } from "react";
22
import { Color } from "../../styles/colors";
33
import data from "../../data/2023.json";
44
import styled from "styled-components";
@@ -8,6 +8,7 @@ import {
88
ROUTE_CODE_OF_CONDUCT,
99
ROUTE_CONDITIONS,
1010
} from "../../constants/routes";
11+
import { useDocumentTitleUpdater } from "../../hooks/useDocumentTitleUpdate";
1112

1213
const StyledSection = styled.section`
1314
{
@@ -96,9 +97,7 @@ const StyledParagraph = styled.section`
9697
}
9798
`;
9899
const Diversity2023: FC<React.PropsWithChildren<unknown>> = () => {
99-
useEffect(() => {
100-
document.title = `Diversity - DevBcn ${data.edition}`;
101-
});
100+
useDocumentTitleUpdater("Diversity", data.edition);
102101

103102
return (
104103
<StyledSection className="styled-section">

src/2023/Home/Home2023Wrapper.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { BIG_BREAKPOINT } from "../../constants/BreakPoints";
22
import React, { FC } from "react";
33
import Faqs from "./components/Faqs/Faqs";
44
import Home from "./components/Home/Home";
5-
import SpeakersCarousel from "./components/SpeakersCarousel/SpeakersCarousel";
65
import Sponsors from "./components/Sponsors/Sponsors";
76
import styled from "styled-components";
87
import data from "../../data/2023.json";
98
import { useLocation } from "react-router";
9+
import SpeakersCarousel from "../../components/Swiper/SpeakersCarousel";
10+
import { ROUTE_2023_SPEAKERS } from "../../constants/routes";
11+
import { useDocumentTitleUpdater } from "../../hooks/useDocumentTitleUpdate";
1012

1113
const StyledContainer = styled.div`
1214
padding-bottom: 10rem;
@@ -20,17 +22,21 @@ export const Home2023Wrapper: FC<React.PropsWithChildren<unknown>> = () => {
2022
const { hash } = useLocation();
2123

2224
React.useEffect(() => {
23-
document.title = `Home - DevBcn - ${data.edition}`;
2425
if (hash != null && hash !== "") {
2526
const scroll = document.getElementById(hash.substring(1));
2627
scroll?.scrollIntoView();
2728
}
2829
}, [hash]);
30+
31+
useDocumentTitleUpdater("Home", data.edition);
2932
return (
3033
<StyledContainer id="home-wrapper">
3134
<Home />
3235
<Faqs />
33-
<SpeakersCarousel />
36+
<SpeakersCarousel
37+
speakersLink={ROUTE_2023_SPEAKERS}
38+
sessionizeUrl={data.sessionizeUrl}
39+
/>
3440
<Sponsors />
3541
</StyledContainer>
3642
);

src/2023/Home/components/SpeakersCarousel/SpeakerSwiper.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "./SpeakersCarousel.scss";
88
import { Link } from "react-router";
99
import { ROUTE_SPEAKER_DETAIL } from "../../../../constants/routes";
1010
import { useFetchSpeakers } from "../../../../hooks/useFetchSpeakers";
11-
import * as Sentry from "@sentry/react";
11+
import { useSentryErrorReport } from "../../../../hooks/useSentryErrorReport";
1212

1313
const StyledSlideImage = styled.img`
1414
display: block;
@@ -39,9 +39,7 @@ const SpeakerSwiper: FC<React.PropsWithChildren<unknown>> = () => {
3939

4040
const swiperSpeakers = data?.sort(() => 0.5 - Math.random()).slice(0, 20);
4141

42-
if (error) {
43-
Sentry.captureException(error);
44-
}
42+
useSentryErrorReport(error);
4543

4644
return (
4745
<>

src/2023/JobOffers/JobOffers2023.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,30 @@ import TitleSection from "../../components/SectionTitle/TitleSection";
1010
import { useWindowSize } from "react-use";
1111
import data from "../../data/2023.json";
1212
import {
13-
Companies, CompanyNameLink, StyledLessIcon, StyledMoreIcon,
14-
StyledTitleContainer
13+
Companies,
14+
CompanyNameLink,
15+
StyledLessIcon,
16+
StyledMoreIcon,
17+
StyledTitleContainer,
1518
} from "../../styles/JobOffers/JobOffers.Style";
1619
import CompanyOffers from "../../components/JobOffers/CompanyOffers";
20+
import { useDocumentTitleUpdater } from "../../hooks/useDocumentTitleUpdate";
1721

1822
const NoOffersAvailable = () => (
19-
<h4 style={{ color: Color.DARK_BLUE }}>No job offers available yet</h4>
23+
<h4 style={{ color: Color.DARK_BLUE }}>No job offers available yet</h4>
2024
);
2125

22-
const MoreThanLessThan = (props: { width: number }) => (
23-
<>
24-
<StyledLessIcon src={LessThanBlueIcon} />
25-
<StyledMoreIcon src={MoreThanBlueIcon} />
26+
const MoreThanLessThan = () => (
27+
<>
28+
<StyledLessIcon src={LessThanBlueIcon} />
29+
<StyledMoreIcon src={MoreThanBlueIcon} />
2630
</>
2731
);
2832

2933
const JobOffers2023: FC<React.PropsWithChildren<unknown>> = () => {
3034
const { width } = useWindowSize();
3135

32-
React.useEffect(() => {
33-
document.title = `Job Offers - DevBcn - ${data.edition}`;
34-
}, []);
36+
useDocumentTitleUpdater("Job Offers", data.edition);
3537

3638
return (
3739
<SectionWrapper color={Color.WHITE} marginTop={6} paddingBottom={100}>
@@ -43,7 +45,7 @@ const JobOffers2023: FC<React.PropsWithChildren<unknown>> = () => {
4345
color={Color.BLACK_BLUE}
4446
/>
4547
</StyledTitleContainer>
46-
{width > MOBILE_BREAKPOINT && <MoreThanLessThan width={width} />}
48+
{width > MOBILE_BREAKPOINT && <MoreThanLessThan />}
4749
{!data.jobOffers.enabled && <NoOffersAvailable />}
4850
{data.jobOffers.enabled && (
4951
<div id="job-offers">

0 commit comments

Comments
 (0)