dev #10
@ -6,6 +6,11 @@ import type { CollectionConfig } from "payload";
|
|||||||
export const Blogs: CollectionConfig = {
|
export const Blogs: CollectionConfig = {
|
||||||
slug: "blogs",
|
slug: "blogs",
|
||||||
labels: { plural: "Posts", singular: "Post" },
|
labels: { plural: "Posts", singular: "Post" },
|
||||||
|
versions: {
|
||||||
|
drafts: {
|
||||||
|
validate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "title",
|
name: "title",
|
||||||
@ -66,15 +71,6 @@ export const Blogs: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "is_published",
|
|
||||||
label: "Published",
|
|
||||||
type: "checkbox",
|
|
||||||
defaultValue: true,
|
|
||||||
admin: {
|
|
||||||
position: "sidebar",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "createdBy",
|
name: "createdBy",
|
||||||
type: "relationship",
|
type: "relationship",
|
||||||
|
@ -13,6 +13,11 @@ import { CollectionConfig } from "payload";
|
|||||||
|
|
||||||
export const Pages: CollectionConfig = {
|
export const Pages: CollectionConfig = {
|
||||||
slug: "pages",
|
slug: "pages",
|
||||||
|
versions: {
|
||||||
|
drafts: {
|
||||||
|
validate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "title",
|
name: "title",
|
||||||
|
@ -146,11 +146,11 @@ export interface Blog {
|
|||||||
description?: string | null;
|
description?: string | null;
|
||||||
canonical_url?: string | null;
|
canonical_url?: string | null;
|
||||||
};
|
};
|
||||||
is_published?: boolean | null;
|
|
||||||
createdBy?: (number | null) | User;
|
createdBy?: (number | null) | User;
|
||||||
updatedBy?: (number | null) | User;
|
updatedBy?: (number | null) | User;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
_status?: ('draft' | 'published') | null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
@ -310,6 +310,7 @@ export interface Page {
|
|||||||
updatedBy?: (number | null) | User;
|
updatedBy?: (number | null) | User;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
_status?: ('draft' | 'published') | null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
@ -646,11 +647,11 @@ export interface BlogsSelect<T extends boolean = true> {
|
|||||||
description?: T;
|
description?: T;
|
||||||
canonical_url?: T;
|
canonical_url?: T;
|
||||||
};
|
};
|
||||||
is_published?: T;
|
|
||||||
createdBy?: T;
|
createdBy?: T;
|
||||||
updatedBy?: T;
|
updatedBy?: T;
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
|
_status?: T;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
@ -753,6 +754,7 @@ export interface PagesSelect<T extends boolean = true> {
|
|||||||
updatedBy?: T;
|
updatedBy?: T;
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
|
_status?: T;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
@ -10,24 +10,11 @@ export async function fetchBlog(page: number | undefined, search: string = "") {
|
|||||||
pagination: true,
|
pagination: true,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
where: !search
|
where: !search
|
||||||
? {
|
? undefined
|
||||||
is_published: {
|
|
||||||
equals: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {
|
: {
|
||||||
and: [
|
title: {
|
||||||
{
|
contains: search,
|
||||||
is_published: {
|
},
|
||||||
equals: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
contains: search,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,9 +38,6 @@ export async function fetchBlogDetail(slug: string | undefined) {
|
|||||||
collection: "blogs",
|
collection: "blogs",
|
||||||
where: {
|
where: {
|
||||||
slug: { equals: slug },
|
slug: { equals: slug },
|
||||||
is_published: {
|
|
||||||
equals: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
limit: 1,
|
limit: 1,
|
||||||
pagination: false,
|
pagination: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user