Skip to content

Commit

Permalink
fix: public digest preview and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn committed Oct 13, 2023
1 parent 4cc58c8 commit ddb0017
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 45 deletions.
3 changes: 3 additions & 0 deletions src/app/(routes)/[teamSlug]/[digestSlug]/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { redirect } from 'next/navigation';
import { getSession } from '@/lib/sessions';
import DigestPublicPage from '@/components/pages/DigestPublicPage';

export const dynamic = 'force-dynamic';
export const revalidate = 0;

interface PageProps {
params: { teamSlug: string; digestSlug: string };
}
Expand Down
92 changes: 47 additions & 45 deletions src/lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,58 +360,60 @@ export const getPublicTeam = unstable_cache((slug: string) =>
})
);

export const getPublicDigest = unstable_cache(
(digestSlug: string, teamSlug: string, isPreview?: boolean) =>
db.digest.findFirst({
select: {
publishedAt: true,
title: true,
description: true,
team: {
select: {
id: true,
slug: true,
name: true,
bio: true,
website: true,
github: true,
twitter: true,
},
export const getPublicDigest = (
digestSlug: string,
teamSlug: string,
isPreview?: boolean
) =>
db.digest.findFirst({
select: {
publishedAt: true,
title: true,
description: true,
team: {
select: {
id: true,
slug: true,
name: true,
bio: true,
website: true,
github: true,
twitter: true,
},
digestBlocks: {
select: {
id: true,
order: true,
title: true,
style: true,
bookmarkId: true,
description: true,
text: true,
type: true,
bookmark: {
include: {
link: {
select: {
url: true,
description: true,
image: true,
title: true,
blurHash: true,
},
},
digestBlocks: {
select: {
id: true,
order: true,
title: true,
style: true,
bookmarkId: true,
description: true,
text: true,
type: true,
bookmark: {
include: {
link: {
select: {
url: true,
description: true,
image: true,
title: true,
blurHash: true,
},
},
},
},
orderBy: { order: 'asc' },
},
orderBy: { order: 'asc' },
},
where: {
slug: digestSlug,
team: { slug: teamSlug },
...(!isPreview ? { publishedAt: { lte: new Date() } } : {}),
},
})
);
},
where: {
slug: digestSlug,
team: { slug: teamSlug },
...(!isPreview ? { publishedAt: { lte: new Date() } } : {}),
},
});

export const getDigestDataForTypefully = async (
digestId: string,
Expand Down

1 comment on commit ddb0017

@vercel
Copy link

@vercel vercel bot commented on ddb0017 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

digestclub – ./

digestclub-premieroctet.vercel.app
digestclub-git-main-premieroctet.vercel.app
digestclub.vercel.app

Please sign in to comment.