-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: restrict access for guest accounts
- Loading branch information
Showing
14 changed files
with
251 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 20 additions & 16 deletions
36
projects/rawkode.academy/cms/src/collections/Categories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { CollectionConfig } from 'payload/types'; | ||
import { isAdmin } from "../utilities/isAdmin"; | ||
|
||
const Categories: CollectionConfig = { | ||
slug: 'categories', | ||
admin: { | ||
useAsTitle: 'name', | ||
}, | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'name', | ||
type: 'text', | ||
}, | ||
], | ||
timestamps: false, | ||
} | ||
slug: "categories", | ||
admin: { | ||
useAsTitle: "name", | ||
}, | ||
access: { | ||
read: () => true, | ||
create: isAdmin, | ||
update: isAdmin, | ||
delete: isAdmin, | ||
}, | ||
fields: [ | ||
{ | ||
name: "name", | ||
type: "text", | ||
}, | ||
], | ||
timestamps: false, | ||
}; | ||
|
||
export default Categories; | ||
export default Categories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,61 @@ | ||
import { CollectionConfig } from "payload/types"; | ||
import { isAdmin } from "../utilities/isAdmin"; | ||
import { People } from "./people"; | ||
|
||
const Posts: CollectionConfig = { | ||
slug: "posts", | ||
admin: { | ||
defaultColumns: ["title", "author", "category", "status"], | ||
useAsTitle: "title", | ||
}, | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: "title", | ||
type: "text", | ||
}, | ||
{ | ||
name: "author", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
}, | ||
{ | ||
name: "publishedDate", | ||
type: "date", | ||
}, | ||
{ | ||
name: "category", | ||
type: "relationship", | ||
relationTo: "categories", | ||
}, | ||
{ | ||
name: "content", | ||
type: "richText", | ||
}, | ||
{ | ||
name: "status", | ||
type: "select", | ||
options: [ | ||
{ | ||
value: "draft", | ||
label: "Draft", | ||
}, | ||
{ | ||
value: "published", | ||
label: "Published", | ||
}, | ||
], | ||
defaultValue: "draft", | ||
admin: { | ||
position: "sidebar", | ||
}, | ||
}, | ||
], | ||
slug: "posts", | ||
admin: { | ||
defaultColumns: ["title", "author", "category", "status"], | ||
useAsTitle: "title", | ||
}, | ||
access: { | ||
read: () => true, | ||
create: isAdmin, | ||
update: isAdmin, | ||
delete: isAdmin, | ||
}, | ||
fields: [ | ||
{ | ||
name: "title", | ||
type: "text", | ||
}, | ||
{ | ||
name: "author", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
}, | ||
{ | ||
name: "publishedDate", | ||
type: "date", | ||
}, | ||
{ | ||
name: "category", | ||
type: "relationship", | ||
relationTo: "categories", | ||
}, | ||
{ | ||
name: "content", | ||
type: "richText", | ||
}, | ||
{ | ||
name: "status", | ||
type: "select", | ||
options: [ | ||
{ | ||
value: "draft", | ||
label: "Draft", | ||
}, | ||
{ | ||
value: "published", | ||
label: "Published", | ||
}, | ||
], | ||
defaultValue: "draft", | ||
admin: { | ||
position: "sidebar", | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
export default Posts; |
79 changes: 43 additions & 36 deletions
79
projects/rawkode.academy/cms/src/collections/media/logo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
import { ImageUploadFormatOptions } from "payload/dist/uploads/types"; | ||
import type { CollectionConfig } from "payload/types"; | ||
import { isAdmin } from "../../utilities/isAdmin"; | ||
|
||
const formatOptions: ImageUploadFormatOptions = { | ||
format: "webp", | ||
}; | ||
|
||
export const Logo: CollectionConfig = { | ||
slug: "logo", | ||
upload: { | ||
disableLocalStorage: false, | ||
adminThumbnail: "thumbnail", | ||
imageSizes: [ | ||
{ | ||
name: "thumbnail", | ||
height: 400, | ||
width: 400, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq960", | ||
width: 960, | ||
height: 960, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq1440", | ||
width: 1440, | ||
height: 1440, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq1920", | ||
width: 1920, | ||
height: 1920, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
], | ||
}, | ||
fields: [], | ||
slug: "logo", | ||
access: { | ||
read: () => true, | ||
create: isAdmin, | ||
update: isAdmin, | ||
delete: isAdmin, | ||
}, | ||
upload: { | ||
disableLocalStorage: false, | ||
adminThumbnail: "thumbnail", | ||
imageSizes: [ | ||
{ | ||
name: "thumbnail", | ||
height: 400, | ||
width: 400, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq960", | ||
width: 960, | ||
height: 960, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq1440", | ||
width: 1440, | ||
height: 1440, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
{ | ||
name: "sq1920", | ||
width: 1920, | ||
height: 1920, | ||
crop: "center", | ||
formatOptions, | ||
}, | ||
], | ||
}, | ||
fields: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 30 additions & 26 deletions
56
projects/rawkode.academy/cms/src/collections/shows/episodes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
import { CollectionConfig } from 'payload/types'; | ||
import { isAdmin } from "../../utilities/isAdmin"; | ||
import { People } from "../people"; | ||
import { Shows } from "./shows"; | ||
|
||
export const Episodes: CollectionConfig = { | ||
slug: 'episodes', | ||
admin: { | ||
useAsTitle: 'name', | ||
}, | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'name', | ||
type: 'text', | ||
}, | ||
{ | ||
name: "show", | ||
type: "relationship", | ||
relationTo: Shows.slug, | ||
}, | ||
{ | ||
name: "guests", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
hasMany: true, | ||
} | ||
], | ||
timestamps: false, | ||
} | ||
slug: "episodes", | ||
admin: { | ||
useAsTitle: "name", | ||
}, | ||
access: { | ||
read: () => true, | ||
create: isAdmin, | ||
update: isAdmin, | ||
delete: isAdmin, | ||
}, | ||
fields: [ | ||
{ | ||
name: "name", | ||
type: "text", | ||
}, | ||
{ | ||
name: "show", | ||
type: "relationship", | ||
relationTo: Shows.slug, | ||
}, | ||
{ | ||
name: "guests", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
hasMany: true, | ||
}, | ||
], | ||
timestamps: false, | ||
}; |
48 changes: 26 additions & 22 deletions
48
projects/rawkode.academy/cms/src/collections/shows/shows.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import { CollectionConfig } from "payload/types"; | ||
import { People } from "../people"; | ||
import { slugField } from "../../fields/slug"; | ||
import { isAdmin } from "../../utilities/isAdmin"; | ||
import { People } from "../people"; | ||
|
||
export const Shows: CollectionConfig = { | ||
slug: "shows", | ||
admin: { | ||
useAsTitle: "name", | ||
}, | ||
access: { | ||
read: () => true, | ||
}, | ||
fields: [ | ||
{ | ||
name: "name", | ||
type: "text", | ||
}, | ||
{ | ||
name: "hosts", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
hasMany: true, | ||
}, | ||
slugField(), | ||
], | ||
timestamps: false, | ||
slug: "shows", | ||
admin: { | ||
useAsTitle: "name", | ||
}, | ||
access: { | ||
read: () => true, | ||
create: isAdmin, | ||
update: isAdmin, | ||
delete: isAdmin, | ||
}, | ||
fields: [ | ||
{ | ||
name: "name", | ||
type: "text", | ||
}, | ||
{ | ||
name: "hosts", | ||
type: "relationship", | ||
relationTo: People.slug, | ||
hasMany: true, | ||
}, | ||
slugField("name"), | ||
], | ||
timestamps: false, | ||
}; |
Oops, something went wrong.