export default async function ArticlesPage() {
const getCachedPublicArticles = unstable_cache(
// Cache public articles
async () => getPublicArticles(),
['articles'],
{
revalidate: 30, // for 30 seconds
},
)
const publicArticles = (await getCachedPublicArticles()) ?? []
const user = await getUser()
const articles = user
? [...publicArticles, ...((await getDraftArticles()) ?? [])] // If user is logged in, mix public and draft articles
: publicArticles // Otherwise, only show public articles
export default async function ArticlesPage() {
const getCachedPublicArticles = unstable_cache(
// Cache public articles
async () => getPublicArticles(),
['articles'],
{
revalidate: 30, // for 30 seconds
},
)
const publicArticles = (await getCachedPublicArticles()) ?? []
const user = await getUser()
const articles = user
? [...publicArticles, ...((await getDraftArticles()) ?? [])] // If user is logged in, mix public and draft articles
: publicArticles // Otherwise, only show public articles