Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Display only published elements from the CMS #863

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/services/cms/fetchArticlePageContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function fetchArticlePageContent({
'populate[3]': 'author.image',
'filters[slug][$eq]': articleSlug,
sort: 'publishedAt:desc',
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const articleResponse = await cmsClient<{
Expand Down Expand Up @@ -60,6 +60,7 @@ export async function fetchArticlePageContent({
sort: 'createdAt:desc',
'pagination[start]': '0',
'pagination[limit]': '3',
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const otherArticlesResponse = await cmsClient<{
Expand Down
2 changes: 1 addition & 1 deletion src/services/cms/fetchArticlePageMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function fetchArticlePageMetadata({
'populate[0]': 'image',
'populate[1]': 'pageMetadata',
'filters[slug][$eq]': articleSlug,
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})
const articleResponse = await cmsClient<{
data: [PopulatedArticleType<'image' | 'pageMetadata'>]
Expand Down
2 changes: 1 addition & 1 deletion src/services/cms/fetchCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function fetchCategories(): Promise<CategoryType[]> {
const categoriesSearchParams = new URLSearchParams({
locale: defaultLocale,
sort: 'order',
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const categoriesResponse = await cmsClient<{ data: CategoryType[] }>(
Expand Down
4 changes: 2 additions & 2 deletions src/services/cms/fetchCategoryPageContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function fetchCategoryPageContent({
'populate[2]': 'mainArticle',
'populate[3]': 'mainArticle.image',
sort: 'questions.order:asc',
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const categoryResponse = await cmsClient<{
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function fetchCategoryPageContent({
'pagination[page]': page.toString(),
'pagination[pageSize]': PAGE_SIZE.toString(),
sort: 'createdAt:desc',
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const articlesResponse = await cmsClient<{
Expand Down
2 changes: 1 addition & 1 deletion src/services/cms/fetchCategoryPageMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function fetchCategoryPageMetadata({
'populate[0]': 'image',
'populate[1]': 'pageMetadata',
'filters[slug][$eq]': slug,
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
})

const categoryResponse = await cmsClient<{
Expand Down
2 changes: 1 addition & 1 deletion src/services/cms/fetchHomepageContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function fetchHomepageContent({ page }: { page: number }): Promise<
'pagination[page]': page.toString(),
'pagination[pageSize]': PAGE_SIZE.toString(),
sort: 'createdAt:desc',
...(isProduction ? {} : { status: 'draft' }),
...(isProduction ? { status: 'published' } : { status: 'draft' }),
}

if (mainArticle) {
Expand Down
Loading