fix: blogs and pages draft/publish
This commit is contained in:
parent
807e78aa70
commit
6fc4988506
@ -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",
|
||||
|
@ -13,6 +13,11 @@ import { CollectionConfig } from "payload";
|
||||
|
||||
export const Pages: CollectionConfig = {
|
||||
slug: "pages",
|
||||
versions: {
|
||||
drafts: {
|
||||
validate: true,
|
||||
},
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "title",
|
||||
|
@ -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
|
||||
|
@ -10,24 +10,11 @@ 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,
|
||||
},
|
||||
},
|
||||
],
|
||||
title: {
|
||||
contains: search,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user