Skip to content

Commit

Permalink
Merge pull request #14 from frorong/feature/meta
Browse files Browse the repository at this point in the history
Add metadata
  • Loading branch information
frorong committed Jun 5, 2024
2 parents c8e7373 + 58e1cc6 commit bf98a8d
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 14 deletions.
27 changes: 21 additions & 6 deletions src/app/gallery/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ import { NotionDetailPage } from "@/pageContainer";
import { notion } from "@/lib";
import { gallery } from "@/constant";

import { redirect } from "next/navigation";
import { redirect, notFound } from "next/navigation";
import type { Metadata } from "next";

export const metadata: Metadata = {
title: "빛고을배드민턴클럽 홈패이지",
description: "빛고을배드민턴클럽의 홈패이지입니다.",
};

const GALLERY_LIST_PAGE = "/gallery" as const;

interface Params {
Expand All @@ -20,6 +15,26 @@ interface Params {
};
}

export const generateMetadata = async ({
params,
}: Params): Promise<Metadata> => {
try {
const { title, description } = gallery[parseInt(params.id)];

return {
title: { absolute: title },
description: description.slice(120),
openGraph: {
title: title,
description: description.slice(120),
url: `https://www.frorong.shop/gallery/${params.id}`,
},
};
} catch (e) {
return notFound();
}
};

export default async function Gallery({ params: { id } }: Params) {
const currentGallery = gallery[parseInt(id)];

Expand Down
7 changes: 7 additions & 0 deletions src/app/gallery/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { NotionPage } from "@/pageContainer";

import { Metadata } from "next";

export const metadata: Metadata = {
title: "갤러리 | Bitguoel",
description: "빛고을배드민턴클럽의 행사갤러리 페이지입니다.",
};

export default function Gallery() {
return <NotionPage postType="gallery" />;
}
10 changes: 8 additions & 2 deletions src/app/inquiry/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { cookies } from "next/headers";

import { InquiryPage } from "@/pageContainer";

import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "문의 | Bitguoel",
description: "빛고을배드민턴클럽의 문의하기 페이지입니다.",
};

export default async function Inquiry() {
const isMailed = cookies().get("isMailed")?.value;
Expand Down
7 changes: 7 additions & 0 deletions src/app/introduce/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { IntroducePage } from "@/pageContainer";

import { Metadata } from "next";

export const metadata: Metadata = {
title: "소개 | Bitguoel",
description: "빛고을배드민턴클럽의 소개 페이지입니다.",
};

export default async function Introduce() {
return <IntroducePage />;
}
27 changes: 21 additions & 6 deletions src/app/notice/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ import { NotionDetailPage } from "@/pageContainer";
import { notion } from "@/lib";
import { notice } from "@/constant";

import { redirect } from "next/navigation";
import { redirect, notFound } from "next/navigation";
import type { Metadata } from "next";

export const metadata: Metadata = {
title: "빛고을배드민턴클럽 홈패이지",
description: "빛고을배드민턴클럽의 홈패이지입니다.",
};

const NOTICE_LIST_PATH = "/notice" as const;

interface Params {
Expand All @@ -20,6 +15,26 @@ interface Params {
};
}

export const generateMetadata = async ({
params,
}: Params): Promise<Metadata> => {
try {
const { title, description } = notice[parseInt(params.id)];

return {
title: { absolute: title },
description: description.slice(120),
openGraph: {
title: title,
description: description.slice(120),
url: `https://www.frorong.shop/gallery/${params.id}`,
},
};
} catch (e) {
return notFound();
}
};

export default async function Notice({ params: { id } }: Params) {
const currentNotice = notice[parseInt(id)];

Expand Down
7 changes: 7 additions & 0 deletions src/app/notice/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { NotionPage } from "@/pageContainer";

import { Metadata } from "next";

export const metadata: Metadata = {
title: "공지 | Bitguoel",
description: "빛고을배드민턴클럽의 공지 페이지입니다.",
};

export default function Notice() {
return <NotionPage postType="notice" />;
}

0 comments on commit bf98a8d

Please sign in to comment.