Skip to content

Commit f5a2f11

Browse files
authored
fix: Added Metadata for all the routes (#5)
1 parent 2c2f3c1 commit f5a2f11

File tree

19 files changed

+104
-53
lines changed

19 files changed

+104
-53
lines changed

src/app/[slug]/page.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { twMerge } from "tailwind-merge";
66
import Author from "./components/Author";
77
import LeftSection from "./components/LeftSection";
88
import RightSection from "./components/RightSection";
9+
import { DynamicPagePropsType } from "../types";
10+
import { Metadata } from "next/types";
11+
import { removeDashAndCapitalize } from "@/utils/utils";
912

1013
export const dynamicParams = false;
1114

@@ -15,11 +18,18 @@ export async function generateStaticParams() {
1518
}));
1619
}
1720

21+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
22+
const slug = (await params).slug
23+
24+
return {
25+
title: removeDashAndCapitalize(slug),
26+
description: ""
27+
};
28+
}
29+
1830
export default async function Page({
1931
params,
20-
}: {
21-
params: Promise<{ slug: string }>;
22-
}) {
32+
}: DynamicPagePropsType) {
2333
const slug = (await params).slug;
2434
const pageData = blogsPageData[slug];
2535

src/app/about/[slug]/layout.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import React from "react";
22
import Image from "next/image";
33
import Link from "next/link";
4+
import { DynamicPagePropsType } from "@/app/types";
5+
import { Metadata } from "next/types";
6+
import { removeDashAndCapitalize } from "@/utils/utils";
7+
8+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
9+
const slug = (await params).slug
10+
11+
return {
12+
title: removeDashAndCapitalize(slug),
13+
description: ""
14+
};
15+
}
416

517
const Layout = ({
618
children,

src/app/about/[slug]/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { aboutPageData } from "@/data";
33
import Image from "next/image";
44
import { twMerge } from "tailwind-merge";
55
import TeamCard from "../components/TeamCard";
6+
import { DynamicPagePropsType } from "@/app/types";
67

78
export const dynamicParams = false;
89

@@ -14,9 +15,7 @@ export async function generateStaticParams() {
1415

1516
export default async function Page({
1617
params,
17-
}: {
18-
params: Promise<{ slug: string }>;
19-
}) {
18+
}: DynamicPagePropsType) {
2019
const slug = (await params).slug;
2120
const pageData = aboutPageData[slug];
2221

src/app/about/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TeamsData from "./components/TeamsData";
99
import { Metadata } from "next";
1010

1111
export const metadata: Metadata = {
12-
title: "About | Procedure",
12+
title: "About",
1313
description: "",
1414
};
1515

src/app/capabilities/[slug]/page.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ import Consultation from "../../../components/Consultation";
44
import Pointers from "../../../components/Pointers";
55
import { capabilitiesPagesData } from "@/data";
66
import RoundedLeftImage from "@/components/RoundedLeftImage";
7+
import type { Metadata } from 'next'
8+
import { DynamicPagePropsType } from "@/app/types";
9+
import { removeDashAndCapitalize } from "@/utils/utils";
710

8-
import { Metadata } from "next";
11+
export const dynamicParams = false;
912

10-
export const metadata: Metadata = {
11-
title: "Capabilities | Procedure",
12-
description: "",
13-
};
13+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
14+
const slug = (await params).slug
1415

15-
export const dynamicParams = false;
16+
return {
17+
title: removeDashAndCapitalize(slug),
18+
description: ""
19+
};
20+
}
1621

1722
export async function generateStaticParams() {
1823
return Object.keys(capabilitiesPagesData).map((pageName) => ({
@@ -22,9 +27,7 @@ export async function generateStaticParams() {
2227

2328
export default async function Page({
2429
params,
25-
}: {
26-
params: Promise<{ slug: string }>;
27-
}) {
30+
}: DynamicPagePropsType) {
2831
const slug = (await params).slug;
2932
const pageData = capabilitiesPagesData[slug];
3033

src/app/capabilities/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CapabilitiesNavigation from "./components/CapablitiesNavigation";
77
import { Metadata } from "next";
88

99
export const metadata: Metadata = {
10-
title: "Capabilities | Procedure",
10+
title: "Capabilities",
1111
description: "",
1212
};
1313

src/app/case_study/[slug]/page.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ import { twMerge } from "tailwind-merge";
88
import DownloadForm from "./components/DownloadForm";
99
import ContentSection from "./components/ContentSection";
1010
import { Metadata } from "next";
11-
12-
export const metadata: Metadata = {
13-
title: "Case Study | Procedure",
14-
description: "",
15-
};
11+
import { DynamicPagePropsType } from "@/app/types";
12+
import { removeDashAndCapitalize } from "@/utils/utils";
1613

1714
export const dynamicParams = false;
1815

16+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
17+
const slug = (await params).slug
18+
19+
return {
20+
title: removeDashAndCapitalize(slug),
21+
description: ""
22+
};
23+
}
24+
1925
export async function generateStaticParams() {
2026
return Object.keys(caseStudiesData).map((pageName) => ({
2127
slug: pageName,
@@ -24,9 +30,7 @@ export async function generateStaticParams() {
2430

2531
export default async function Page({
2632
params,
27-
}: {
28-
params: Promise<{ slug: string }>;
29-
}) {
33+
}: DynamicPagePropsType) {
3034
const slug = (await params).slug;
3135
const pageData = caseStudiesData[slug];
3236

src/app/contact/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PageBackgroundImage from "@/components/PageBackgroundImage";
55
import { Metadata } from "next";
66

77
export const metadata: Metadata = {
8-
title: "Contact | Procedure",
8+
title: "Contact",
99
description: "",
1010
};
1111

src/app/industries/[slug]/page.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ import RoundedLeftImage from "@/components/RoundedLeftImage";
55
import { industriesPagesData } from "@/data";
66
import { twMerge } from "tailwind-merge";
77
import { Metadata } from "next";
8+
import { DynamicPagePropsType } from "@/app/types";
9+
import { removeDashAndCapitalize } from "@/utils/utils";
810

9-
export const metadata: Metadata = {
10-
title: "Industries | Procedure",
11-
description: "",
12-
};
11+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
12+
const slug = (await params).slug
13+
14+
return {
15+
title: removeDashAndCapitalize(slug),
16+
description: ""
17+
};
18+
}
1319

1420
export const dynamicParams = false;
1521

@@ -21,9 +27,7 @@ export async function generateStaticParams() {
2127

2228
export default async function Page({
2329
params,
24-
}: {
25-
params: Promise<{ slug: string }>;
26-
}) {
30+
}: DynamicPagePropsType) {
2731
const slug = (await params).slug;
2832
const pageData = industriesPagesData[slug];
2933

src/app/industries/case-studies/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { tabs } from "@/constants/constant";
77
import { Metadata } from "next";
88

99
export const metadata: Metadata = {
10-
title: "Case Study | Procedure",
10+
title: "Case Study",
1111
description: "",
1212
};
1313

src/app/industries/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import BackgroundImage from "../../components/PageBackgroundImage";
77
import { Metadata } from "next";
88

99
export const metadata: Metadata = {
10-
title: "Industries | Procedure",
10+
title: "Industries",
1111
description: "",
1212
};
1313

src/app/layout.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import Header from "@/components/AppLayout/Header";
44
import Footer from "@/components/AppLayout/Footer";
55

66
export const metadata: Metadata = {
7-
title: "Procedure",
7+
title: {
8+
template: '%s | Procedure',
9+
default: 'Home | Procedure', // a default is required when creating a template
10+
},
811
description: "Think. Build. Measure.",
912
};
1013

src/app/lifeprocedure/[slug]/page.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ import { twMerge } from "tailwind-merge";
55
import PhotoSlider from "../components/PhotoSlider";
66
import Pointers from "@/components/Pointers";
77
import { lifeProcedureData } from "@/data";
8+
import { DynamicPagePropsType } from "@/app/types";
9+
import { removeDashAndCapitalize } from "@/utils/utils";
10+
import { Metadata } from "next/types";
811

9-
import { Metadata } from "next";
12+
export const dynamicParams = false;
1013

11-
export const metadata: Metadata = {
12-
title: "Life at Procedure",
13-
description: "",
14-
};
14+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
15+
const slug = (await params).slug
1516

16-
export const dynamicParams = false;
17+
return {
18+
title: removeDashAndCapitalize(slug),
19+
description: ""
20+
};
21+
}
1722

1823
export async function generateStaticParams() {
1924
return Object.keys(lifeProcedureData).map((pageName) => ({
@@ -23,9 +28,7 @@ export async function generateStaticParams() {
2328

2429
export default async function Page({
2530
params,
26-
}: {
27-
params: Promise<{ slug: string }>;
28-
}) {
31+
}: DynamicPagePropsType) {
2932
const slug = (await params).slug;
3033
const pageData = lifeProcedureData[slug];
3134

src/app/page.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import TeamSection from "@/app/components/TeamSection";
44
import Link from "next/link";
55
import JoinProcedure from "@/components/JoinProcedure";
66
import AgileDeliverySection from "./components/AgileDeliverySection";
7-
import { Metadata } from "next";
8-
9-
export const metadata: Metadata = {
10-
title: "Home | Procedure",
11-
description: "",
12-
};
137

148
export default function Home() {
159
return (

src/app/privacy-policy/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33
import { Metadata } from "next";
44

55
export const metadata: Metadata = {
6-
title: "Privacy Policy | Procedure",
6+
title: "Privacy Policy",
77
description: "",
88
};
99

src/app/resources/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { twMerge } from "tailwind-merge";
66
import { Metadata } from "next";
77

88
export const metadata: Metadata = {
9-
title: "Resources | Procedure",
9+
title: "Resources",
1010
description: "",
1111
};
1212

src/app/tag/[slug]/page.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
import { DynamicPagePropsType } from "@/app/types";
12
import PageNavbar from "@/components/PageNavbar";
23
import { blogsPageData, caseStudiesData } from "@/data";
4+
import { removeDashAndCapitalize } from "@/utils/utils";
5+
import { Metadata } from "next";
36
import Link from "next/link";
47
import { notFound } from "next/navigation";
58

9+
export async function generateMetadata({ params }: DynamicPagePropsType): Promise<Metadata> {
10+
const slug = (await params).slug
11+
12+
return {
13+
title: `${removeDashAndCapitalize(slug)} Tag`,
14+
description: ""
15+
};
16+
}
17+
618
export async function generateStaticParams() {
719
const allTags = [
820
...Object.values(blogsPageData).flatMap((blog) => blog.tags),

src/app/types/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type DynamicPagePropsType = {
2+
params: Promise<{ slug: string }>
3+
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
4+
}

src/utils/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const removeDashAndCapitalize = (slug: string) => {
2+
return slug.replace(/-/g, " ").replace(/\b\w/g, char => char.toUpperCase())
3+
}

0 commit comments

Comments
 (0)