From 15c676796a25fefeaae8453a58ba77a0f233d6a9 Mon Sep 17 00:00:00 2001 From: Adam Joseph Arling Date: Thu, 23 May 2024 13:52:32 -0500 Subject: [PATCH] Add News page content from Contentful --- src/app/news/page.tsx | 10 +++- src/components/features/implementations.tsx | 2 +- src/components/news/list.tsx | 59 +++++++++++++++++++++ src/lib/format-date.ts | 7 +++ src/lib/types.ts | 0 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 src/components/news/list.tsx create mode 100644 src/lib/format-date.ts create mode 100644 src/lib/types.ts diff --git a/src/app/news/page.tsx b/src/app/news/page.tsx index 26f5714..43819bc 100644 --- a/src/app/news/page.tsx +++ b/src/app/news/page.tsx @@ -1,6 +1,7 @@ import Container from "@/components/layout/container"; import Header from "@/components/layout/header"; import MainWrapper from "@/components/layout/main-wrapper"; +import NewsList from "@/components/news/list"; import PageHeader from "@/components/page-header"; export default function Homepage() { @@ -8,8 +9,13 @@ export default function Homepage() {
- - asdf + + + +
); diff --git a/src/components/features/implementations.tsx b/src/components/features/implementations.tsx index b7efdb4..011c064 100644 --- a/src/components/features/implementations.tsx +++ b/src/components/features/implementations.tsx @@ -6,7 +6,7 @@ import useGetContentfulData from "@/hooks/use-get-contentful-data"; export default function Implementations() { const data = useGetContentfulData("integration"); - console.log("data", data); + return (
{data && diff --git a/src/components/news/list.tsx b/src/components/news/list.tsx new file mode 100644 index 0000000..c233a68 --- /dev/null +++ b/src/components/news/list.tsx @@ -0,0 +1,59 @@ +"use client"; + +import RichTextContent from "../rich-text-content"; +import { UserGroupIcon } from "@heroicons/react/20/solid"; +import { formatDate } from "@/lib/format-date"; +import useGetContentfulData from "@/hooks/use-get-contentful-data"; + +export default function NewsList() { + const data = useGetContentfulData("newsItem"); + console.log("data", data); + + return ( +
+
+
+
+ {data.map(({ fields, sys }: { fields: any; sys: any }) => ( +
+
+ + + {fields.title} + +
+
+

+ {/* */} + {fields.title} +

+ +
+
+ +
+

+ + + {fields.author} + +

+

Hyku Administrator

+
+
+
+ ))} +
+
+
+
+ ); +} diff --git a/src/lib/format-date.ts b/src/lib/format-date.ts new file mode 100644 index 0000000..d3dc9a4 --- /dev/null +++ b/src/lib/format-date.ts @@ -0,0 +1,7 @@ +export function formatDate(date: string) { + return new Date(date).toLocaleDateString("en-US", { + year: "numeric", + month: "long", + day: "numeric", + }); +} diff --git a/src/lib/types.ts b/src/lib/types.ts new file mode 100644 index 0000000..e69de29