committing summative
This commit is contained in:
1 parent
73ac8e85be
commit
95b138f29e
44 files changed
+5319
-755
No files matched your search
@@ -0,0 +1,7 @@
|
||||
export default function Loading() {
|
||||
return (
|
||||
<p className="mx-auto w-full max-w-3xl px-6 py-10">
|
||||
Loading newsletter…
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { getPubNewsletter } from "@/app/actions/NewsletterActions";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export default async function NewsletterPage({ params }: { params: Promise<{ id: string }>; }) { // next passes in params object when this comp is called
|
||||
const { id } = await params; // [id] catches the value from the url and gives it a param value with the key of id
|
||||
const newsletter = await getPubNewsletter(id);
|
||||
|
||||
if (!newsletter) { // otherwise tries to reference things that dont exist
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-3xl px-6 py-10">
|
||||
<article>
|
||||
<h1 className="text-4xl font-bold tracking-tight">
|
||||
{newsletter.title}
|
||||
</h1>
|
||||
|
||||
<p className="mt-3 text-sm text-base-content/60">
|
||||
By {newsletter.author.name || "Unnamed author"}
|
||||
</p>
|
||||
|
||||
{newsletter.imageUrl && (
|
||||
<img
|
||||
src={newsletter.imageUrl}
|
||||
alt={newsletter.title}
|
||||
className="mt-6 h-auto w-full rounded-lg"
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="mt-8 whitespace-pre-wrap leading-relaxed">
|
||||
{newsletter.content}
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export default function Loading() {
|
||||
return (
|
||||
<p className="mx-auto w-full max-w-6xl px-6 py-10">
|
||||
Loading newsletters…
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { getPubNewsletters } from "../actions/NewsletterActions";
|
||||
import Link from "next/link";
|
||||
import { Suspense } from "react";
|
||||
import ExternalNewsletters from "../components/ExternalNewsletters";
|
||||
|
||||
export default async function NewslettersPage() {
|
||||
const newsletters = await getPubNewsletters();
|
||||
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-6xl px-6 py-10">
|
||||
<h1 className="text-4xl font-bold tracking-tight">
|
||||
Newsletters
|
||||
</h1>
|
||||
|
||||
<p className="mt-3 text-base-content/70">
|
||||
Read our latest published newsletters.
|
||||
</p>
|
||||
|
||||
<div className="mt-8 overflow-x-auto">
|
||||
<div className="mt-8">
|
||||
{newsletters.length === 0 ? (
|
||||
<p>No newsletters have been published yet.</p>
|
||||
) : (
|
||||
<ul className="space-y-10">
|
||||
{newsletters.map((newsletter) => ( // maps each newsletter into a list item
|
||||
<li
|
||||
key={newsletter.id}
|
||||
className="border-b border-base-content/20 pb-8"
|
||||
>
|
||||
<article>
|
||||
<h2 className="text-2xl font-semibold">
|
||||
<Link
|
||||
href={`/newsletters/${newsletter.id}`} // creates a custom link for the newsletter
|
||||
className="hover:underline"
|
||||
>
|
||||
{newsletter.title}
|
||||
</Link>
|
||||
</h2>
|
||||
|
||||
<p className="mt-2 text-sm text-base-content/60">
|
||||
By {newsletter.author.name || "Unnamed author"}
|
||||
</p>
|
||||
|
||||
{newsletter.imageUrl && ( // when this is an image it renders it
|
||||
<Link href={`/newsletters/${newsletter.id}`} className="mt-4 block">
|
||||
<img
|
||||
src={newsletter.imageUrl} // above also makes the image link to the custom link for specific newsletter
|
||||
alt={newsletter.title}
|
||||
className="mt-4 h-48 w-full rounded-lg object-cover"
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
</article>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
<div className="divider"> From other sources</div>
|
||||
<div>
|
||||
<Suspense fallback={<p className="mt-12">Loading external feed…</p>}>
|
||||
<ExternalNewsletters />
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user