dev #18
@ -13,7 +13,10 @@ type FetchBlogParams = {
|
||||
export async function fetchBlog({ page, search = "", categoryId, tagId }: FetchBlogParams = {}) {
|
||||
const payload = await getPayload({ config: payloadConfig });
|
||||
|
||||
const queryCondition: Where = {};
|
||||
const queryCondition: Where = {
|
||||
_status: { equals: "published" },
|
||||
};
|
||||
|
||||
if (!!search) {
|
||||
queryCondition["title"] = {
|
||||
contains: search,
|
||||
@ -57,6 +60,7 @@ export async function fetchBlogSuggestion() {
|
||||
const limitPerPage = 2;
|
||||
const blogCountQuery = await payload.count({
|
||||
collection: "blogs",
|
||||
where: { _status: { equals: "published" } },
|
||||
});
|
||||
|
||||
// randomize page
|
||||
@ -92,6 +96,7 @@ export async function fetchBlogDetail(slug: string | undefined) {
|
||||
const blogDataQuery = await payload.find({
|
||||
collection: "blogs",
|
||||
where: {
|
||||
_status: { equals: "published" },
|
||||
slug: { equals: slug },
|
||||
},
|
||||
limit: 1,
|
||||
@ -118,6 +123,7 @@ export async function fetchBlogCategoryBySlug(slug: string) {
|
||||
const category = await payload.find({
|
||||
collection: "blogCategories",
|
||||
where: {
|
||||
_status: { equals: "published" },
|
||||
slug: { equals: slug },
|
||||
},
|
||||
});
|
||||
@ -134,6 +140,7 @@ export async function fetchBlogTagBySlug(slug: string) {
|
||||
const tag = await payload.find({
|
||||
collection: "blogTags",
|
||||
where: {
|
||||
_status: { equals: "published" },
|
||||
slug: { equals: slug },
|
||||
},
|
||||
});
|
||||
|
@ -11,6 +11,7 @@ export const fetchPageBySlug = async ({ slug }: { slug: string | undefined }) =>
|
||||
pagination: false,
|
||||
// overrideAccess: draft,
|
||||
where: {
|
||||
_status: { equals: "published" },
|
||||
slug: {
|
||||
equals: slug,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user