diff --git a/media/images/project_inzight.png b/media/images/project_inzight.png new file mode 100644 index 0000000..b399406 Binary files /dev/null and b/media/images/project_inzight.png differ diff --git a/media/images/project_matau.png b/media/images/project_matau.png new file mode 100644 index 0000000..e7cbdb7 Binary files /dev/null and b/media/images/project_matau.png differ diff --git a/payload-types.ts b/payload-types.ts index 08585cc..fbe7b7f 100644 --- a/payload-types.ts +++ b/payload-types.ts @@ -159,6 +159,7 @@ export interface Project { * Show this project on the homepage. */ featured?: boolean | null; + banner?: (number | null) | Image; links?: | { link: string; @@ -173,36 +174,6 @@ export interface Project { updatedAt: string; createdAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "news". - */ -export interface News { - id: number; - title: string; - /** - * The slug is used to identify the news item in the URL. - */ - slug: string; - content: { - root: { - type: string; - children: { - type: string; - version: number; - [k: string]: unknown; - }[]; - direction: ('ltr' | 'rtl') | null; - format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; - indent: number; - version: number; - }; - [k: string]: unknown; - }; - updatedAt: string; - createdAt: string; - _status?: ('draft' | 'published') | null; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "images". @@ -249,6 +220,36 @@ export interface Image { }; }; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "news". + */ +export interface News { + id: number; + title: string; + /** + * The slug is used to identify the news item in the URL. + */ + slug: string; + content: { + root: { + type: string; + children: { + type: string; + version: number; + [k: string]: unknown; + }[]; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; + indent: number; + version: number; + }; + [k: string]: unknown; + }; + updatedAt: string; + createdAt: string; + _status?: ('draft' | 'published') | null; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "documents". @@ -389,6 +390,7 @@ export interface ProjectsSelect { slug?: T; content?: T; featured?: T; + banner?: T; links?: | T | { diff --git a/src/app/(website)/components/Home/Hero/02-data.tsx b/src/app/(website)/components/Home/Hero/02-data.tsx index 2d556ea..b3713b4 100644 --- a/src/app/(website)/components/Home/Hero/02-data.tsx +++ b/src/app/(website)/components/Home/Hero/02-data.tsx @@ -72,7 +72,7 @@ const Item = ({ return (
= 1024; + return (
@@ -54,20 +62,84 @@ export default function Projects({
-
+
{[...projects, ...projects].map((project, i) => ( -
setActive(i)} > -

{project.title}

+ {project.banner && typeof project.banner !== "number" && ( + + + + )} + {(!largeScreen || active === i) && ( + +
+

+ {project.title} +

-
- -
-
+ + + +
+ + )} + ))}
+ +
+
+

Have a project idea?

+ +

Get in touch >

+ +
+
); } diff --git a/src/app/(website)/components/PayloadImage.tsx b/src/app/(website)/components/PayloadImage.tsx new file mode 100644 index 0000000..2d000f8 --- /dev/null +++ b/src/app/(website)/components/PayloadImage.tsx @@ -0,0 +1,28 @@ +import type { Image as PImage } from "@payload-types"; +import Image from "next/image"; + +export default function PayloadImage({ + img, + className, +}: { + img: PImage; + className: string; +}) { + const url = img.url; + const width = img.width; + const height = img.height; + + if (!url || !width || !height) return <>; + + console.log("URL: ", url); + + return ( + {img.alt + ); +} diff --git a/src/app/(website)/globals.css b/src/app/(website)/globals.css index ef4dcaa..e8eb517 100644 --- a/src/app/(website)/globals.css +++ b/src/app/(website)/globals.css @@ -35,3 +35,7 @@ /* Other vars */ --header-height: 100px; } + +.payload-richtext p { + @apply mb-2; +} diff --git a/src/app/(website)/page.tsx b/src/app/(website)/page.tsx index f2c79c4..fe1cf42 100644 --- a/src/app/(website)/page.tsx +++ b/src/app/(website)/page.tsx @@ -7,7 +7,6 @@ import HeroData from "./components/Home/Hero/02-data"; import bgImage from "./bg.jpg"; import Image from "next/image"; import Projects from "./components/Home/Projects"; -import Link from "next/link"; export default async function Home() { const payload = await getPayload({ config }); @@ -47,15 +46,6 @@ export default async function Home() { /> - -
-
-

Have a project idea?

- -

Get in touch >

- -
-
); diff --git a/src/collections/Projects.ts b/src/collections/Projects.ts index 6b98ea9..e33a595 100644 --- a/src/collections/Projects.ts +++ b/src/collections/Projects.ts @@ -2,83 +2,86 @@ import { formatSlug } from "@/lib/slugs"; import { CollectionConfig } from "payload"; export const Projects: CollectionConfig = { - slug: 'projects', - fields: [ + slug: "projects", + fields: [ + { + name: "title", + label: "Title", + type: "text", + required: true, + }, + { + name: "slug", + label: "Slug", + type: "text", + required: true, + unique: true, + admin: { + position: "sidebar", + description: "The slug is used to identify the news item in the URL.", + // readOnly: true, + }, + hooks: { + beforeValidate: [formatSlug("title")], + }, + }, + { + name: "content", + label: "Content", + type: "richText", + required: true, + }, + // list of files + // gallery + // keywords + // is featured? + { + name: "featured", + label: "Featured", + type: "checkbox", + defaultValue: false, + admin: { + position: "sidebar", + description: "Show this project on the homepage.", + }, + }, + { + name: "banner", + label: "Banner", + type: "upload", + relationTo: "images", + }, + // links + { + name: "links", + label: "Links", + type: "array", + fields: [ { - name: 'title', - label: 'Title', - type: 'text', - required: true, + name: "link", + label: "Link", + type: "text", + required: true, }, { - name: 'slug', - label: 'Slug', - type: 'text', - required: true, - unique: true, - admin: { - position: 'sidebar', - description: 'The slug is used to identify the news item in the URL.', - // readOnly: true, - }, - hooks: { - beforeValidate: [ - formatSlug('title'), - ] - } + name: "description", + label: "Description", + type: "text", + required: false, }, { - name: 'content', - label: 'Content', - type: 'richText', - required: true, + name: "group", + label: "Group", + type: "text", + required: false, + admin: { + description: "Optional: organise link under this heading", + }, }, - // list of files - // gallery - // keywords - // is featured? - { - name: 'featured', - label: 'Featured', - type: 'checkbox', - defaultValue: false, - admin: { - position: 'sidebar', - description: 'Show this project on the homepage.', - } - }, - // links - { - name: 'links', - label: 'Links', - type: 'array', - fields: [ - { - name: 'link', - label: 'Link', - type: 'text', - required: true, - }, - { - name: 'description', - label: 'Description', - type: 'text', - required: false, - }, - { - name: 'group', - label: 'Group', - type: 'text', - required: false, - admin: { - description: 'Optional: organise link under this heading', - }, - } - ], - admin: { - position: 'sidebar', - - } - }, - ] -} + ], + admin: { + position: "sidebar", + }, + }, + ], +}; diff --git a/src/collections/media/Images.ts b/src/collections/media/Images.ts index 7094f60..8c0f6b7 100644 --- a/src/collections/media/Images.ts +++ b/src/collections/media/Images.ts @@ -1,45 +1,49 @@ import type { CollectionConfig } from "payload"; export const Images: CollectionConfig = { - slug: 'images', - upload: { - staticDir: 'media/images', - imageSizes: [ - { - name: 'thumbnail', - width: 400, - height: 300, - position: 'centre', - }, - { - name: 'card', - width: 768, - height: 1024, - position: 'centre', - }, - { - name: 'tablet', - width: 1024, - height: undefined, - position: 'centre', - } - ], - adminThumbnail: 'thumbnail', - mimeTypes: ['image/*'], - }, - fields: [ - { - name: 'alt', - label: 'Alt Text', - type: 'text', - }, - { - name: 'description', - label: 'Description', - type: 'textarea', - } + slug: "images", + access: { + // TODO: fix this + read: () => true, + }, + upload: { + staticDir: "media/images", + imageSizes: [ + { + name: "thumbnail", + width: 400, + height: 300, + position: "centre", + }, + { + name: "card", + width: 768, + height: 1024, + position: "centre", + }, + { + name: "tablet", + width: 1024, + height: undefined, + position: "centre", + }, ], - admin: { - group: 'Media', - } -} + adminThumbnail: "thumbnail", + mimeTypes: ["image/*"], + }, + fields: [ + { + name: "alt", + label: "Alt Text", + type: "text", + }, + { + name: "description", + label: "Description", + type: "textarea", + }, + ], + admin: { + group: "Media", + }, +}; diff --git a/src/globals/Home/Projects.ts b/src/globals/Home/Projects.ts index 39c7eb1..74a5fa3 100644 --- a/src/globals/Home/Projects.ts +++ b/src/globals/Home/Projects.ts @@ -1,22 +1,22 @@ import { GlobalConfig } from "payload"; export const HomeProjects: GlobalConfig = { - slug: 'homeProjects', - label: 'Projects', - fields: [ - { - name: 'projectsTitle', - label: 'Projects Title', - type: 'text', - defaultValue: 'We do data differently' - }, - { - name: 'projectsDescription', - label: 'Projects Description', - type: 'richText' - } - ], - admin: { - group: 'Home page' - } + slug: "homeProjects", + label: "Projects", + fields: [ + { + name: "projectsTitle", + label: "Projects Title", + type: "text", + defaultValue: "We do data differently", + }, + { + name: "projectsDescription", + label: "Projects Description", + type: "richText", + }, + ], + admin: { + group: "Home page", + }, };