Skip to content

Commit f0a6d30

Browse files
committed
feat: Add homepage with latest posts display and Firebase data fetching
1 parent 362920f commit f0a6d30

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import AuthorsLoading from "@/components/Authors/loading";
55
import NewsTicker from "@/components/NewsTicker/NewsTicker";
66
import PageTitle from "@/components/PageTitle";
77
import Subheading from "@/components/Subheading";
8+
import Sidebar from "@/components/Sidebar";
89
import { Suspense } from "react";
910
import type { Metadata } from "next";
1011
import JsonLd from "@/components/JsonLd";
@@ -165,7 +166,7 @@ export default async function Home() {
165166
<NewsTicker />
166167
</Suspense>
167168

168-
<LatestPosts initialPosts={articles} />
169+
<LatestPosts initialPosts={articles} sidebar={<Sidebar />} />
169170

170171
<Subheading className="text-subheading" url="/team" linkText="Full Team">
171172
Team

components/LatestPosts/LatestPosts.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import { useEffect, useState, ReactNode } from "react";
44
import { Timestamp } from "firebase/firestore";
5-
import Sidebar from "../Sidebar";
65
import { Separator } from "@radix-ui/react-separator";
76
import Link from "next/link";
87
import Loading from "./loading";
@@ -42,9 +41,13 @@ const formatDate = (date: string | Timestamp) => {
4241

4342
interface LatestPostsProps {
4443
initialPosts: Article[];
44+
sidebar?: ReactNode;
4545
}
4646

47-
export default function LatestPosts({ initialPosts }: LatestPostsProps) {
47+
export default function LatestPosts({
48+
initialPosts,
49+
sidebar,
50+
}: LatestPostsProps) {
4851
// If initialPosts are passed, just use them.
4952
// We can also just render them directly.
5053
// We need to sort them here if they aren't already sorted, but let's assume parent passes sorted.
@@ -162,9 +165,7 @@ export default function LatestPosts({ initialPosts }: LatestPostsProps) {
162165
</article>
163166
))}
164167
</div>
165-
<div className="lg:w-1/4">
166-
<Sidebar />
167-
</div>
168+
<div className="lg:w-1/4">{sidebar}</div>
168169
</div>
169170
</>
170171
);

0 commit comments

Comments
 (0)