dev #10

Merged
RizqiSyahrendra merged 8 commits from dev into main 2025-03-04 22:43:48 +00:00
4 changed files with 18 additions and 31 deletions
Showing only changes of commit 6fc4988506 - Show all commits

View File

@ -6,6 +6,11 @@ import type { CollectionConfig } from "payload";
export const Blogs: CollectionConfig = {
slug: "blogs",
labels: { plural: "Posts", singular: "Post" },
versions: {
drafts: {
validate: true,
},
},
fields: [
{
name: "title",
@ -66,15 +71,6 @@ export const Blogs: CollectionConfig = {
},
],
},
{
name: "is_published",
label: "Published",
type: "checkbox",
defaultValue: true,
admin: {
position: "sidebar",
},
},
{
name: "createdBy",
type: "relationship",

View File

@ -13,6 +13,11 @@ import { CollectionConfig } from "payload";
export const Pages: CollectionConfig = {
slug: "pages",
versions: {
drafts: {
validate: true,
},
},
fields: [
{
name: "title",

View File

@ -146,11 +146,11 @@ export interface Blog {
description?: string | null;
canonical_url?: string | null;
};
is_published?: boolean | null;
createdBy?: (number | null) | User;
updatedBy?: (number | null) | User;
updatedAt: string;
createdAt: string;
_status?: ('draft' | 'published') | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@ -310,6 +310,7 @@ export interface Page {
updatedBy?: (number | null) | User;
updatedAt: string;
createdAt: string;
_status?: ('draft' | 'published') | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@ -646,11 +647,11 @@ export interface BlogsSelect<T extends boolean = true> {
description?: T;
canonical_url?: T;
};
is_published?: T;
createdBy?: T;
updatedBy?: T;
updatedAt?: T;
createdAt?: T;
_status?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@ -753,6 +754,7 @@ export interface PagesSelect<T extends boolean = true> {
updatedBy?: T;
updatedAt?: T;
createdAt?: T;
_status?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema

View File

@ -10,25 +10,12 @@ export async function fetchBlog(page: number | undefined, search: string = "") {
pagination: true,
limit: 6,
where: !search
? {
is_published: {
equals: true,
},
}
? undefined
: {
and: [
{
is_published: {
equals: true,
},
},
{
title: {
contains: search,
},
},
],
},
});
const formattedData = blogDataQuery.docs.map((item) => {
@ -51,9 +38,6 @@ export async function fetchBlogDetail(slug: string | undefined) {
collection: "blogs",
where: {
slug: { equals: slug },
is_published: {
equals: true,
},
},
limit: 1,
pagination: false,