diff --git a/package.json b/package.json index 9d41671..b96e39e 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,6 @@ "tailwindcss-animate": "^1.0.5", "ts-jest": "^29.1.0", "ts-node": "^10.9.1", - "typescript": "^4.9.5" + "typescript": "^5.2.2" } } diff --git a/prisma/json-schema/json-schema.json b/prisma/json-schema/json-schema.json index 224a9d4..05af8a7 100644 --- a/prisma/json-schema/json-schema.json +++ b/prisma/json-schema/json-schema.json @@ -509,6 +509,10 @@ "hasSentNewsletter": { "type": "boolean", "default": false + }, + "isFeatured": { + "type": "boolean", + "default": false } } }, diff --git a/prisma/migrations/20230912152515_add_featured_flag/migration.sql b/prisma/migrations/20230912152515_add_featured_flag/migration.sql new file mode 100644 index 0000000..d162d25 --- /dev/null +++ b/prisma/migrations/20230912152515_add_featured_flag/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "digests" ADD COLUMN "isFeatured" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a50aa8c..2182b2d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -189,6 +189,7 @@ model Digest { digestBlocks DigestBlock[] typefullyThreadUrl String? hasSentNewsletter Boolean @default(false) + isFeatured Boolean @default(false) @@unique([slug, teamId]) @@map("digests") diff --git a/src/components/digests/SearchInput.tsx b/src/components/digests/SearchInput.tsx index f856a91..90dea4c 100644 --- a/src/components/digests/SearchInput.tsx +++ b/src/components/digests/SearchInput.tsx @@ -18,7 +18,7 @@ const SearchInput = ({ /* eslint-disable react-hooks/exhaustive-deps */ const onSearch = useCallback( debounce((e: React.ChangeEvent) => { - const params = new URLSearchParams(searchParams); + const params = new URLSearchParams(searchParams.toString()); params.set('search', e.target.value); startTransition(() => { diff --git a/src/components/home/HomeDigests.tsx b/src/components/home/HomeDigests.tsx new file mode 100644 index 0000000..c71c782 --- /dev/null +++ b/src/components/home/HomeDigests.tsx @@ -0,0 +1,45 @@ +import db from '@/lib/db'; +import React from 'react'; +import PublicDigestCard from '../teams/PublicDigestCard'; + +const HomeDigests = async () => { + const digests = await db.digest.findMany({ + take: 3, + orderBy: { publishedAt: 'desc' }, + where: { publishedAt: { not: null }, isFeatured: true }, + select: { + id: true, + publishedAt: true, + title: true, + description: true, + slug: true, + team: { select: { slug: true } }, + _count: { + select: { + digestBlocks: true, + }, + }, + }, + }); + + return ( +
+

+ Community digests +

+
+
+ {digests.map((digest) => ( + + ))} +
+
+
+ ); +}; + +export default HomeDigests; diff --git a/src/components/pages/Homepage.tsx b/src/components/pages/Homepage.tsx index 8a597b6..163aac1 100644 --- a/src/components/pages/Homepage.tsx +++ b/src/components/pages/Homepage.tsx @@ -2,6 +2,7 @@ import Hero from '@/components/home/Hero'; import HomeFooter from '../home/HomeFooter'; import HomeSteps from '../home/HomeSteps'; import { Session } from 'next-auth'; +import HomeDigests from '../home/HomeDigests'; const Homepage = ({ user }: { user?: Session['user'] }) => { return ( @@ -12,6 +13,9 @@ const Homepage = ({ user }: { user?: Session['user'] }) => {
+
+ +
); diff --git a/src/components/pages/TeamPublicPage.tsx b/src/components/pages/TeamPublicPage.tsx index 8f7ffc0..996810e 100644 --- a/src/components/pages/TeamPublicPage.tsx +++ b/src/components/pages/TeamPublicPage.tsx @@ -36,7 +36,6 @@ const TeamPublicPage = ({ team }: Props) => { key={digest.slug} digest={digest} teamSlug={team.slug} - teamName={team.name} /> )) )} diff --git a/src/components/teams/PublicDigestCard.tsx b/src/components/teams/PublicDigestCard.tsx index 6eb9260..1a134fd 100644 --- a/src/components/teams/PublicDigestCard.tsx +++ b/src/components/teams/PublicDigestCard.tsx @@ -1,17 +1,15 @@ import { PublicTeamResult } from '@/lib/queries'; import { generateDigestOGUrl } from '@/utils/open-graph'; import { format } from 'date-fns'; -import Image from 'next/image'; import Link from 'next/link'; interface Props { digest: NonNullable['Digest'][number]; teamSlug: string; - teamName: string; } -const PublicDigestCard = ({ digest, teamSlug, teamName }: Props) => { - const { title, description, publishedAt, _count } = digest; +const PublicDigestCard = ({ digest, teamSlug }: Props) => { + const { title, description, publishedAt } = digest; const url = new URL(generateDigestOGUrl(digest.slug)); return ( diff --git a/src/pages/admin/[[...nextadmin]].tsx b/src/pages/admin/[[...nextadmin]].tsx index ed4c27b..b508691 100644 --- a/src/pages/admin/[[...nextadmin]].tsx +++ b/src/pages/admin/[[...nextadmin]].tsx @@ -183,6 +183,9 @@ export const getServerSideProps: GetServerSideProps = async ({ req, res }) => { description: { display: true, }, + isFeatured: { + display: true, + }, createdAt: { display: true, }, diff --git a/yarn.lock b/yarn.lock index 26e479c..e1a859f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12283,10 +12283,10 @@ typescript@5.0.2: resolved "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz" integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw== -typescript@^4.9.5: - version "4.9.5" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== uglify-js@^3.5.1: version "3.17.4"