Skip to content

Commit 04b5c1a

Browse files
authored
Fix: case study does not appear on home and service page (#181)
* copy: improve consistency
1 parent ce4a73f commit 04b5c1a

22 files changed

Lines changed: 440 additions & 512 deletions

File tree

app/[lang]/(hyperjump)/case-studies/[slug]/components/content.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,32 @@ import {
88
CaseStudiesVolunteeringPlatform
99
} from "@/locales/.generated/locales-markdown";
1010
import type { SupportedLanguage } from "@/locales/.generated/types";
11+
import { CaseStudySlug } from "../../../data";
1112

1213
type ContentProps = {
1314
lang: SupportedLanguage;
1415
slug: string;
1516
};
1617

17-
const caseStudies = [
18-
{
19-
slug: "erp-fisheries",
20-
content: CaseStudiesFisheries
21-
},
22-
{
23-
slug: "ctoaas-media",
24-
content: CaseStudiesMedia
25-
},
26-
{
27-
slug: "saas-volunteering-platform",
28-
content: CaseStudiesVolunteeringPlatform
29-
}
30-
];
31-
3218
export function Content({ lang, slug }: ContentProps) {
19+
const caseStudies = [
20+
{
21+
slug: CaseStudySlug.Fisheries,
22+
content: CaseStudiesFisheries
23+
},
24+
{
25+
slug: CaseStudySlug.Media,
26+
content: CaseStudiesMedia
27+
},
28+
{
29+
slug: CaseStudySlug.VolunteeringPlatform,
30+
content: CaseStudiesVolunteeringPlatform
31+
}
32+
];
3333
const caseStudy = caseStudies.find((caseStudy) => caseStudy.slug === slug);
3434

3535
if (!caseStudy) {
36+
console.error(`Case study content for "${slug}" is not registered.`);
3637
notFound();
3738
}
3839

app/[lang]/(hyperjump)/case-studies/[slug]/page.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ import {
1515
import type { SupportedLanguage } from "@/locales/.generated/types";
1616
import { supportedLanguages } from "@/locales/.generated/types";
1717

18-
import type { CaseStudy } from "../../data";
19-
import { caseStudyBy, getCaseStudies } from "../data";
18+
import {
19+
caseStudyBy,
20+
getCaseStudies,
21+
serviceBySlug,
22+
type CaseStudy
23+
} from "../../data";
2024
import { Content } from "./components/content";
2125

2226
type Params = { lang: SupportedLanguage; slug: string };
@@ -30,7 +34,7 @@ export async function generateMetadata({
3034
}: CaseStudyProps): Promise<Metadata> {
3135
const { lang, slug } = await params;
3236
const { url } = data;
33-
const caseStudies = caseStudyBy(slug, lang);
37+
const caseStudies = caseStudyBy({ lang, slug });
3438
const meta: Metadata = {
3539
title: `Case-Studies - ${caseStudies?.title ?? ""}`,
3640
description: caseStudies?.description ?? "",
@@ -60,7 +64,7 @@ export async function generateStaticParams(): Promise<Params[]> {
6064

6165
export default async function CaseStudy({ params }: CaseStudyProps) {
6266
const { lang, slug } = await params;
63-
const caseStudy = caseStudyBy(slug, lang);
67+
const caseStudy = caseStudyBy({ lang, slug });
6468
if (!caseStudy) {
6569
notFound();
6670
}
@@ -140,13 +144,13 @@ function Recommendation({ caseStudies, lang }: RecommendationProps) {
140144
{caseStudyMore(lang)}
141145
</h2>
142146
<div className="grid gap-6 md:grid-cols-2">
143-
{caseStudies.map(({ description, slug, title, category }) => (
147+
{caseStudies.map(({ description, serviceSlug, slug, title }) => (
144148
<div
145149
key={slug}
146150
className="flex h-full flex-col justify-between rounded-xl border border-gray-200 p-6 text-left shadow-sm transition duration-300 hover:shadow-md">
147151
<div>
148152
<span className="mb-4 inline-block rounded-full bg-gray-100 px-3 py-1 text-sm font-medium text-gray-800">
149-
{category}
153+
{serviceBySlug({ lang, slug: serviceSlug })?.title}
150154
</span>
151155
<h3 className="text-hyperjump-black mb-2 text-lg font-semibold md:text-[22px]">
152156
{title}

app/[lang]/(hyperjump)/case-studies/data.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import Link from "next/link";
21
import type { Metadata } from "next";
32

43
import { Hero } from "@/app/components/hero";
5-
import { Button } from "@/components/ui/button";
64
import data from "@/data.json";
75
import { dynamicOpengraph } from "@/lib/default-metadata";
86
import {
97
supportedLanguages,
108
type SupportedLanguage
119
} from "@/locales/.generated/types";
1210
import {
13-
caseStudyButton,
1411
caseStudyExplore,
1512
caseStudyHeroDesc,
1613
caseStudyHeroHeading,
1714
caseStudyTitle
1815
} from "@/locales/.generated/strings";
1916

20-
import { getCaseStudies } from "./data";
17+
import { getCaseStudies } from "../data";
18+
import { CaseStudyCard } from "../components/case-study-card";
2119

2220
export const generateStaticParams = async () => {
2321
return supportedLanguages.map((lang) => ({ lang }));
@@ -63,47 +61,20 @@ export default async function CaseStudiesPage({ params }: CaseStudyProps) {
6361
<h3 className="text-hyperjump-black w-72 text-[28px] font-medium md:w-full md:text-[40px]">
6462
{caseStudyExplore(lang)}
6563
</h3>
66-
<CaseStudies lang={lang} />
64+
<section className="bg-white pt-5 pb-10">
65+
<div className="mx-auto max-w-5xl">
66+
<div className="grid gap-6 md:grid-cols-3">
67+
{getCaseStudies(lang).map((caseStudy) => (
68+
<CaseStudyCard
69+
key={caseStudy.slug}
70+
caseStudy={caseStudy}
71+
lang={lang}
72+
/>
73+
))}
74+
</div>
75+
</div>
76+
</section>
6777
</div>
6878
</main>
6979
);
7080
}
71-
72-
function CaseStudies({ lang }: { lang: SupportedLanguage }) {
73-
return (
74-
<section className="bg-white pt-5 pb-10">
75-
<div className="mx-auto max-w-5xl">
76-
<div className="grid gap-6 md:grid-cols-2">
77-
{getCaseStudies(lang).map(
78-
({ category, description, slug, title }) => (
79-
<div
80-
key={slug}
81-
className="flex h-full flex-col justify-between rounded-xl border border-gray-200 p-6 text-left shadow-sm transition duration-300 hover:shadow-md">
82-
<div>
83-
<span className="mb-4 inline-block rounded-full bg-gray-100 px-3 py-1 text-sm font-medium text-gray-800">
84-
{category}
85-
</span>
86-
<h3 className="text-hyperjump-black mb-2 text-lg font-semibold md:text-[22px]">
87-
{title}
88-
</h3>
89-
<p className="text-hyperjump-gray mb-4 text-sm md:text-base">
90-
{description}
91-
</p>
92-
</div>
93-
94-
<Button
95-
asChild
96-
variant="outline"
97-
className="text-hyperjump-blue hover:bg-hyperjump-blue mt-4 w-full border-gray-300 hover:text-white">
98-
<Link href={`/${lang}/case-studies/${slug}`}>
99-
{caseStudyButton(lang)}
100-
</Link>
101-
</Button>
102-
</div>
103-
)
104-
)}
105-
</div>
106-
</div>
107-
</section>
108-
);
109-
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Link from "next/link";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { caseStudyButton } from "@/locales/.generated/strings";
5+
import type { SupportedLanguage } from "@/locales/.generated/types";
6+
7+
import type { CaseStudy } from "../data";
8+
import { serviceBySlug } from "../data";
9+
10+
type CaseStudyCardProps = {
11+
caseStudy: CaseStudy;
12+
lang: SupportedLanguage;
13+
};
14+
15+
export function CaseStudyCard({
16+
caseStudy: { description, serviceSlug, slug, title, url },
17+
lang
18+
}: CaseStudyCardProps) {
19+
return (
20+
<div
21+
key={slug}
22+
className="flex h-full flex-col justify-between rounded-xl border border-gray-200 bg-white p-6 text-left shadow-sm transition duration-300 hover:shadow-md">
23+
<div>
24+
<span className="mb-4 inline-block rounded-full bg-gray-100 px-3 py-1 text-sm font-medium text-gray-800">
25+
{serviceBySlug({ lang, slug: serviceSlug })?.title}
26+
</span>
27+
<h3 className="text-hyperjump-black mb-2 text-lg font-semibold md:text-[22px]">
28+
{title}
29+
</h3>
30+
<p className="text-hyperjump-gray mb-4 text-sm md:text-base">
31+
{description}
32+
</p>
33+
</div>
34+
35+
<Button
36+
asChild
37+
variant="outline"
38+
className="text-hyperjump-blue hover:bg-hyperjump-blue mt-4 w-full border-gray-300 hover:text-white">
39+
<Link href={url}>{caseStudyButton(lang)}</Link>
40+
</Button>
41+
</div>
42+
);
43+
}

0 commit comments

Comments
 (0)