Skip to content

Commit f8174fc

Browse files
authored
Refactor: Improve page and code consistency (#136)
* refactor: implement dry principle * feat: improve page consistency
1 parent 278a103 commit f8174fc

File tree

12 files changed

+174
-145
lines changed

12 files changed

+174
-145
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import type { Metadata } from "next";
12
import Image from "next/image";
23
import Link from "next/link";
34
import { notFound } from "next/navigation";
45

56
import { Button } from "@/components/ui/button";
7+
import data from "@/data.json";
68
import { caseStudyButton, caseStudyMore } from "@/locales/.generated/server";
79
import {
810
supportedLanguages,
@@ -12,7 +14,6 @@ import {
1214
import type { CaseStudy } from "../../data";
1315
import { caseStudyBy, getCaseStudies } from "../data";
1416
import { Content } from "./components/content";
15-
import { Metadata } from "next";
1617
import { dynamicOpengraph } from "@/lib/default-metadata";
1718

1819
type Params = { lang: SupportedLanguage; slug: string };
@@ -25,17 +26,16 @@ export async function generateMetadata({
2526
params
2627
}: CaseStudyProps): Promise<Metadata> {
2728
const { lang, slug } = await params;
29+
const { url } = data;
2830
const caseStudies = caseStudyBy(slug, lang);
29-
30-
const meta = {
31+
const meta: Metadata = {
3132
title: `Case-Studies - ${caseStudies?.title ?? ""}`,
3233
description: caseStudies?.description ?? "",
3334
alternates: {
34-
canonical: `https://hyperjump.tech/${lang}/case-studies/${caseStudies?.slug}`,
35+
canonical: `${url}/${lang}/case-studies/${caseStudies?.slug}`,
3536
languages: (supportedLanguages as SupportedLanguage[]).reduce(
3637
(acc, l) => {
37-
acc[l] =
38-
`https://hyperjump.tech/${l}/case-studies/${caseStudies?.slug}`;
38+
acc[l] = `${url}/${l}/case-studies/${caseStudies?.slug}`;
3939
return acc;
4040
},
4141
{} as Record<string, string>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Link from "next/link";
2-
import { Metadata } from "next";
2+
import type { Metadata } from "next";
33

44
import { Hero } from "@/app/components/hero";
55
import { Button } from "@/components/ui/button";
6+
import data from "@/data.json";
67
import { dynamicOpengraph } from "@/lib/default-metadata";
78
import {
89
supportedLanguages,
@@ -29,15 +30,15 @@ export async function generateMetadata(props: {
2930
params: Promise<{ lang: SupportedLanguage }>;
3031
}): Promise<Metadata> {
3132
const { lang } = await props.params;
32-
33-
const meta: any = {
33+
const { url } = data;
34+
const meta: Metadata = {
3435
title: `Case Studies - ${caseStudyHeroHeading(lang)}`,
3536
description: caseStudyHeroDesc(lang),
3637
alternates: {
37-
canonical: `https://hyperjump.tech/${lang}/case-studies`,
38+
canonical: `${url}/${lang}/case-studies`,
3839
languages: (supportedLanguages as SupportedLanguage[]).reduce(
3940
(acc, l) => {
40-
acc[l] = `https://hyperjump.tech/${l}/case-studies`;
41+
acc[l] = `${url}/${l}/case-studies`;
4142
return acc;
4243
},
4344
{} as Record<string, string>
@@ -70,7 +71,7 @@ export default async function CaseStudiesPage({ params }: CaseStudyProps) {
7071
function CaseStudies({ lang }: { lang: SupportedLanguage }) {
7172
return (
7273
<section className="bg-white pt-5 pb-10">
73-
<div className="mx-auto max-w-6xl">
74+
<div className="mx-auto max-w-5xl">
7475
<div className="grid gap-6 md:grid-cols-2">
7576
{getCaseStudies(lang).map(
7677
({ category, description, slug, title }) => (

app/[lang]/(hyperjump)/page.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from "next";
12
import Image from "next/image";
23
import Link from "next/link";
34
import type { Organization, WebPage, WithContext } from "schema-dts";
@@ -46,24 +47,22 @@ import {
4647
pageData,
4748
services
4849
} from "./data";
49-
import { Metadata } from "next";
5050
import { dynamicOpengraph } from "@/lib/default-metadata";
5151

52-
const { github, socials, title, url, description } = data;
52+
const { github, socials, title, url } = data;
5353

5454
export async function generateMetadata(props: {
5555
params: Promise<{ lang: SupportedLanguage }>;
5656
}): Promise<Metadata> {
5757
const { lang } = await props.params;
58-
59-
const meta: any = {
58+
const meta: Metadata = {
6059
title: mainHeroHeading(lang),
6160
description: mainHeroDesc(lang),
6261
alternates: {
63-
canonical: `https://hyperjump.tech/${lang}`,
62+
canonical: `${url}/${lang}`,
6463
languages: (supportedLanguages as SupportedLanguage[]).reduce(
6564
(acc, l) => {
66-
acc[l] = `https://hyperjump.tech/${l}`;
65+
acc[l] = `${url}/${l}`;
6766
return acc;
6867
},
6968
{} as Record<string, string>
@@ -290,7 +289,7 @@ function JsonLdOrganization() {
290289
"@type": "Organization",
291290
name: title,
292291
url,
293-
logo: "https://hyperjump.tech/images/hyperjump-colored.png",
292+
logo: `${url}/images/hyperjump-colored.png`,
294293
address: {
295294
"@type": "PostalAddress",
296295
streetAddress:

app/[lang]/(hyperjump)/products/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
22

33
import { GridItems } from "@/app/components/grid-items";
44
import { Hero } from "@/app/components/hero";
5+
import data from "@/data.json";
56
import { dynamicOpengraph } from "@/lib/default-metadata";
67
import {
78
supportedLanguages,
@@ -26,15 +27,15 @@ export async function generateMetadata({
2627
params
2728
}: ProductsProps): Promise<Metadata> {
2829
const { lang } = await params;
29-
30-
const meta = {
30+
const { url } = data;
31+
const meta: Metadata = {
3132
title: productsHeroHeading(lang),
3233
description: productsHeroDesc(lang),
3334
alternates: {
34-
canonical: `https://hyperjump.tech/${lang}/products`,
35+
canonical: `${url}/${lang}/products`,
3536
languages: supportedLanguages.reduce(
3637
(acc, l) => {
37-
acc[l] = `https://hyperjump.tech/${l}/products`;
38+
acc[l] = `https${url}${l}/products`;
3839
return acc;
3940
},
4041
{} as Record<string, string>

app/[lang]/(hyperjump)/services/[slug]/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import type { Metadata } from "next";
12
import Image from "next/image";
23
import Link from "next/link";
34
import { notFound } from "next/navigation";
45

56
import { Avatar, AvatarImage } from "@/components/ui/avatar";
67
import { Button } from "@/components/ui/button";
8+
import data from "@/data.json";
79
import {
810
supportedLanguages,
911
type SupportedLanguage
@@ -23,7 +25,6 @@ import {
2325

2426
import type { CaseStudy, Service } from "../../data";
2527
import { serviceBySlug, ServiceSlug } from "../../data";
26-
import { Metadata } from "next";
2728
import { dynamicOpengraph } from "@/lib/default-metadata";
2829

2930
type LangProps = {
@@ -36,16 +37,16 @@ export async function generateMetadata(props: {
3637
params: Promise<{ lang: SupportedLanguage; slug: ServiceSlug }>;
3738
}): Promise<Metadata> {
3839
const { lang, slug } = await props.params;
40+
const { url } = data;
3941
const service = serviceBySlug({ lang, slug });
40-
41-
const meta = {
42+
const meta: Metadata = {
4243
title: `Services - ${service?.title ?? ""}`,
4344
description: service?.description ?? "",
4445
alternates: {
45-
canonical: `https://hyperjump.tech/${lang}/services/${service?.slug}`,
46+
canonical: `${url}/${lang}/services/${service?.slug}`,
4647
languages: (supportedLanguages as SupportedLanguage[]).reduce(
4748
(acc, l) => {
48-
acc[l] = `https://hyperjump.tech/${l}/services/${service?.slug}`;
49+
acc[l] = `${url}/${l}/services/${service?.slug}`;
4950
return acc;
5051
},
5152
{} as Record<string, string>

app/[lang]/(hyperjump)/services/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ import {
2323
import { Clients } from "../components/clients";
2424
import { serviceBySlug, services, ServiceSlug } from "../data";
2525

26+
const { clients, url } = data;
27+
2628
export async function generateMetadata(props: {
2729
params: Promise<{ lang: SupportedLanguage }>;
2830
}): Promise<Metadata> {
2931
const { lang } = await props.params;
30-
31-
const meta: any = {
32+
const meta: Metadata = {
3233
title: `Services - ${servicesHeroHeading(lang)}`,
3334
description: servicesHeroDesc(lang),
3435
alternates: {
35-
canonical: `https://hyperjump.tech/${lang}/services`,
36+
canonical: `${url}/${lang}/services`,
3637
languages: (supportedLanguages as SupportedLanguage[]).reduce(
3738
(acc, l) => {
38-
acc[l] = `https://hyperjump.tech/${l}/services`;
39+
acc[l] = `${url}/${l}/services`;
3940
return acc;
4041
},
4142
{} as Record<string, string>
@@ -82,7 +83,7 @@ export default async function Services({ params }: ServicesProps) {
8283
<p className="text-hyperjump-gray mx-auto mb-8 w-full max-w-3xl text-center text-base md:text-lg">
8384
{servicesPartnersDesc(lang)}
8485
</p>
85-
<Clients clients={data.clients} />
86+
<Clients clients={clients} />
8687
</section>
8788
</div>
8889
</main>

app/[lang]/(inferenceai)/inferenceai/data.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ReactNode } from "react";
22

33
import type { Item } from "@/app/components/grid-items";
4+
import data from "@/data.json";
45
import type { SupportedLanguage } from "@/locales/.generated/types";
56
import {
67
inferenceaiNavItems0Label,
@@ -422,7 +423,7 @@ export const getFaqs = (lang: SupportedLanguage): Faq[] => {
422423

423424
export const getData = (lang: SupportedLanguage) => ({
424425
name: "Inference AI",
425-
baseUrl: `https://hyperjump.tech/${lang}/inferenceai`,
426+
baseUrl: `${data.url}/${lang}/inferenceai`,
426427
socials: [
427428
{
428429
platform: "GitHub",

app/components/console.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"use client";
22

3+
import data from "@/data.json";
34
import ClientOnly from "./client-only";
45

56
const messages = [
67
"👨‍💻 Suka ngoprek JavaScript/CSS/TypeScript/Node.js/React/Vue.js/Kotlin/Go/Swift?",
78
"🏃‍♂️‍➡️ Pengen maju bersama tukang coding yang menggandrungi dunia open-source?",
89
"👨‍🔬 Ingin eksplorasi teknologi keren kayak CI/CD, Docker, microservice, dkk?",
910
"✅ UDAH DEH: Gabung kita aja",
10-
"👉 https://hyperjump.tech/jobs"
11+
`👉 ${data.url}/jobs`
1112
];
1213

1314
export default function Console() {

0 commit comments

Comments
 (0)