feat/infrastructure-upgrade #3

Merged
LiamPietralla merged 5 commits from feat/infrastructure-upgrade into main 2026-01-16 16:11:46 +11:00
35 changed files with 4258 additions and 1855 deletions

View File

@@ -6,3 +6,4 @@ README.md
.next
.git
portfolio-data
compose.yml

9
.env.development Normal file
View File

@@ -0,0 +1,9 @@
# App Configuration
PAYLOAD_SECRET=123ABC
# S3 Configuration
S3_BUCKET="payload-media"
S3_REGION="us-east-1"
S3_ACCESS_KEY_ID="dev_key"
S3_SECRET_ACCESS_KEY="dev_secret"
S3_ENDPOINT="http://localhost:9000"

View File

@@ -1 +1,3 @@
PAYLOAD_SECRET=123
# App Configuration
DATABASE_URL=postgres://<user>:<password>@<host>:5432/<database>
PAYLOAD_SECRET=123ABC

View File

@@ -29,6 +29,11 @@ jobs:
- name: Install Dependencies
run: pnpm i --frozen-lockfile
- name: Write Environment File
run: |
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
echo "PAYLOAD_SECRET=BUILD" >> .env
- name: Build App
run: pnpm run build
@@ -67,4 +72,26 @@ jobs:
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
DATABASE_URL=${{ secrets.DATABASE_URL }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Migrations
run: pnpm payload migrate
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Setup Nomad
uses: hashicorp/setup-nomad@main
with:
nomad_version: '1.10.5'
- name: Deploy Job to Nomad
run: |
export DEPLOYMENT_VERSION="${GITHUB_SHA:0:7}-$(date +%s)"
nomad job run -var="deployment_version=$DEPLOYMENT_VERSION" infra/nomad/portfolio.nomad.hcl
env:
NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}

1
.gitignore vendored
View File

@@ -33,6 +33,7 @@ yarn-error.log*
# env files (can opt-in for committing if needed)
.env*
!.env.template
!.env.development
# vercel
.vercel

View File

@@ -1,29 +1,65 @@
FROM node:24-alpine AS base
ENV NODE_ENV=production
# Install curl for health checks
RUN apk add --no-cache curl
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml* .npmrc* ./
RUN corepack enable pnpm && pnpm i --frozen-lockfile;
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable pnpm && pnpm build
# Set build args and environment variables
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ENV NEXT_TELEMETRY_DISABLED=1
RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
RUN corepack enable pnpm
RUN mkdir -p /app/portfolio-data && chown node:node /app/portfolio-data
COPY --chown=node --from=deps /app/node_modules ./node_modules
COPY --chown=node --from=builder /app/public ./public
COPY --chown=node --from=builder /app/next.config.ts ./next.config.ts
COPY --chown=node --from=builder /app/.next ./.next
COPY --chown=node --from=builder /app/package.json ./package.json
COPY --chown=node --from=builder /app/tsconfig.json ./tsconfig.json
COPY --chown=node --from=builder /app/src ./src
USER node
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
CMD ["pnpm", "start"]
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]

View File

@@ -2,8 +2,6 @@
The portfolio is built using Next.JS and Payload CMS. Payload is running directly in the Next app, and can be accessed by appending /admin to the route.
Next is currently using a sqlite database and local file storage. Both are output to a `portfolio-data` directory.
## Development
To develop the application use pnpm to install the dependencies:
@@ -37,9 +35,11 @@ pnpm run payload:migrate:create
Deploying the portfolio is done as a docker container. It can be built with the following command:
```bash
docker build -t liam-portfolio .
docker build --add-host=host.docker.internal:host-gateway --build-arg HOST_GATEWAY=host.docker.internal -t liam-portfolio .
```
NOTE: Ensure a .env exists with the correct environment variables, including the DATABASE_URL and PAYLOAD_SECRET.
### Running the Container
Once the container is built, you can run it with the following command:

49
compose.yml Normal file
View File

@@ -0,0 +1,49 @@
services:
s3:
image: ghcr.io/achtungsoftware/alarik:latest
restart: unless-stopped
ports:
- "9000:8080"
environment:
- API_BASE_URL=http://localhost:9000
- CONSOLE_BASE_URL=http://localhost:9001
- ADMIN_USERNAME=portfolio
- ADMIN_PASSWORD=portfolio
- JWT=DEV_SECRET_JWT_KEY
- ALLOW_ACCOUNT_CREATION=false
- DEFAULT_ACCESS_KEY=dev_key
- DEFAULT_SECRET_KEY=dev_secret
volumes:
- portfolio_s3_data:/app/Storage
s3-ui:
image: ghcr.io/achtungsoftware/alarik-console:latest
restart: unless-stopped
ports:
- "9001:3000"
environment:
- NUXT_PUBLIC_API_BASE_URL=http://localhost:9000
- NUXT_PUBLIC_CONSOLE_BASE_URL=http://localhost:9001
- NUXT_PUBLIC_ALLOW_ACCOUNT_CREATION=false
depends_on:
- s3
bucket-creation-helper:
image: minio/mc:latest
depends_on:
- s3
entrypoint: >
sh -c "
sleep 2 &&
mc alias set alarik http://s3:8080 dev_key dev_secret &&
if mc ls alarik/payload-media > /dev/null 2>&1; then
echo 'S3 bucket already exists';
else
mc mb alarik/payload-media &&
echo 'S3 bucket created';
fi
"
volumes:
portfolio_s3_data:

70
infra/portfolio.nomad.hcl Normal file
View File

@@ -0,0 +1,70 @@
variable "deployment_version" {
type = string
description = "The deployment version from CI/CD"
default = "unknown"
}
job "portfolio_v2" {
datacenters = ["dc1"]
type = "service"
meta {
version = var.deployment_version
}
group "portfolio.v2" {
count = 1
network {
port "web" {
to = 3000
}
}
service {
name = "portfolio_v2"
port = "web"
# tags = [
# "traefik.enable=true",
# "traefik.http.routers.portfolio-v2.rule=Host(`liampietralla.com`)",
# "traefik.http.routers.portfolio-v2.entrypoints=websecure",
# "traefik.http.routers.portfolio-v2.tls.certresolver=letsencrypt"
# ]
check {
type = "http"
path = "/api/health"
interval = "10s"
timeout = "3s"
}
}
task "portfolio_v2" {
driver = "docker"
config {
image = "liamsgit.dev/liampietralla/liam-portfolio:latest"
force_pull = true
ports = ["web"]
}
template {
data = <<EOF
{{- range service "postgres" }}
DATABASE_URL=postgres://portfolio-user:{{ with nomadVar "nomad/jobs/portfolio_v2/portfolio_v2/portfolio_v2" }}{{ .DATABASE_URL_PASSWORD }}{{ end }}@{{ .Address }}:{{ .Port }}/portfolio
{{- end }}
PAYLOAD_SECRET={{ with nomadVar "nomad/jobs/portfolio_v2/portfolio_v2/portfolio_v2" }}{{ .PAYLOAD_SECRET }}{{ end }}
S3_BUCKET="portfolio"
S3_REGION="us-east-1"
{{- range service "s3-api" }}
S3_ENDPOINT=http://{{ .Address }}:{{ .Port }}
{{- end }}
S3_ACCESS_KEY_ID={{ with nomadVar "nomad/jobs/portfolio_v2/portfolio_v2/portfolio_v2" }}{{ .S3_ACCESS_KEY_ID }}{{ end }}
S3_SECRET_ACCESS_KEY={{ with nomadVar "nomad/jobs/portfolio_v2/portfolio_v2/portfolio_v2" }}{{ .S3_SECRET_ACCESS_KEY }}{{ end }}
EOF
destination = "secrets/env"
env = true
}
}
}
}

View File

@@ -1,6 +1,8 @@
import { withPayload } from "@payloadcms/next/withPayload";
import type { NextConfig } from "next";
const nextConfig: NextConfig = { };
const nextConfig: NextConfig = {
output: "standalone",
};
export default withPayload(nextConfig);

View File

@@ -1,6 +1,6 @@
{
"name": "liam-portfolio",
"version": "1.0.2",
"version": "1.0.3",
"private": true,
"type": "module",
"scripts": {
@@ -12,16 +12,18 @@
"payload:migrate:create": "payload migrate:create"
},
"dependencies": {
"@payloadcms/db-sqlite": "^3.53.0",
"@payloadcms/next": "^3.53.0",
"@payloadcms/richtext-lexical": "^3.53.0",
"@payloadcms/db-postgres": "^3.71.1",
"@payloadcms/next": "^3.71.1",
"@payloadcms/richtext-lexical": "^3.71.1",
"@payloadcms/storage-s3": "^3.71.1",
"@payloadcms/ui": "^3.71.1",
"clsx": "^2.1.1",
"graphql": "^16.11.0",
"lucide-react": "^0.541.0",
"next": "15.5.8",
"payload": "^3.53.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"next": "16.1.2",
"payload": "^3.71.1",
"react": "19.2.3",
"react-dom": "19.2.3",
"sharp": "^0.34.3",
"tailwind-merge": "^3.3.1"
},
@@ -29,12 +31,18 @@
"@eslint/eslintrc": "^3",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react": "19.2.8",
"@types/react-dom": "19.2.3",
"eslint": "^9",
"eslint-config-next": "15.5.0",
"eslint-config-next": "16.1.2",
"tailwindcss": "^4",
"typescript": "^5"
},
"packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a"
"packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
"pnpm": {
"overrides": {
"@types/react": "19.2.8",
"@types/react-dom": "19.2.3"
}
}
}

4269
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

Before

Width:  |  Height:  |  Size: 391 B

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 128 B

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

Before

Width:  |  Height:  |  Size: 385 B

View File

@@ -1,17 +1,17 @@
export const dynamic = 'force-dynamic'
import IndexLink from "@/components/home-page-link";
import Rule from "@/components/horizontal-rule";
import { getHome } from "@/services/home-service";
import { Mail } from "lucide-react";
import Image from "next/image";
import ProfileImage from "../../../public/images/liam_pietralla.jpg";
const IndexPage = async () => {
const home = await getHome();
return (
<div className="flex flex-col gap-4 justify-center items-center h-screen">
<Image className="rounded-full" src="/images/liam_pietralla.jpg" width={200} height={200} alt="Liam Pietralla" />
<Image className="rounded-full max-w-[200px]" src={ProfileImage} alt="Liam Pietralla" />
<h1 className="text-5xl font-bold">Liam Pietralla</h1>
<div className="flex flex-col md:flex-row gap-0 md:gap-[7px]">
<h2 className="text-xl text-center">Enthusiastic Software Developer</h2>

View File

@@ -1,5 +1,3 @@
export const dynamic = 'force-dynamic'
import ProjectCard from "@/components/project-card";
import Rule from "@/components/horizontal-rule";
import { getProjects } from "@/services/projects-service";
@@ -7,12 +5,14 @@ import Image from "next/image";
import Link from "next/link";
import { Fragment } from "react";
import ProfileImage from "../../../../public/images/liam_pietralla.jpg";
const ProjectsPage = async () => {
const projects = await getProjects();
return (
<div className="flex flex-col gap-4 justify-center items-center my-15">
<div className="flex flex-row items-center gap-2 my-2">
<Image src="/images/liam_pietralla.jpg" width={50} height={50} alt="Liam Pietralla" className="rounded-full" />
<Image src={ProfileImage} alt="Liam Pietralla" className="rounded-full max-w-[50px]" />
<Link href="/" className="group leading-relaxed font-semi-bold">
Liam Pietralla
<span className="block max-w-0 group-hover:max-w-full transition-all duration-500 h-0.5 bg-white"></span>

View File

@@ -1,5 +1,7 @@
import { S3ClientUploadHandler as S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24 } from '@payloadcms/storage-s3/client'
import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
export const importMap = {
"@payloadcms/storage-s3/client#S3ClientUploadHandler": S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24,
"@payloadcms/ui/rsc#CollectionCards": CollectionCards_ab83ff7e88da8d3530831f296ec4756a
}

View File

@@ -1,27 +1,26 @@
import type { CollectionConfig } from 'payload'
import type { CollectionConfig } from "payload"
export const Media: CollectionConfig = {
slug: 'media',
slug: "media",
access: {
read: () => true,
},
fields: [
{
name: 'alt',
type: 'text',
name: "alt",
type: "text",
required: true,
},
],
upload: {
staticDir: 'portfolio-data/media',
imageSizes: [
{
name: "thumbnail",
width: 150,
height: 150,
position: 'centre',
position: "centre",
}
],
adminThumbnail: 'thumbnail',
adminThumbnail: "thumbnail",
}
}

View File

@@ -1,3 +1,4 @@
import { revalidatePath } from "next/cache";
import { CollectionConfig } from "payload";
export const Projects: CollectionConfig = {
@@ -44,5 +45,17 @@ export const Projects: CollectionConfig = {
type: "text",
required: false,
}
],
hooks: {
afterChange: [
async () => {
revalidatePath("/projects");
}
],
afterDelete: [
async () => {
revalidatePath("/projects");
}
]
}
}

View File

@@ -1,9 +1,9 @@
import type { CollectionConfig } from 'payload'
import type { CollectionConfig } from "payload"
export const Users: CollectionConfig = {
slug: 'users',
slug: "users",
admin: {
useAsTitle: 'email',
useAsTitle: "email",
},
auth: true,
fields: [

View File

@@ -1,5 +1,6 @@
import Link from "next/link";
import { DynamicIcon, IconName } from 'lucide-react/dynamic';
import { DynamicIcon, IconName } from "lucide-react/dynamic";
import { lucidIconMap } from "@/lib/lucid-options";
interface HomePageLinkProps {
title: string;
@@ -11,14 +12,14 @@ interface HomePageLinkProps {
const HomePageLink = ({ title, icon, url, isPopover }: HomePageLinkProps) => {
const isRelative = !url.startsWith("http");
const dynIcon = <DynamicIcon name={icon as IconName} />
const IconComponent = lucidIconMap[icon as IconName];
if (isPopover) {
if (isRelative) {
return (
<div className="relative group">
<Link href={url} className="flex items-center space-x-2">
{dynIcon}
{icon && <IconComponent />}
</Link>
<div className="absolute left-1/2 -translate-x-1/2 z-10 hidden p-2 px-4 text-sm text-black bg-white rounded-md group-hover:block text-center">
{title}
@@ -29,7 +30,7 @@ const HomePageLink = ({ title, icon, url, isPopover }: HomePageLinkProps) => {
return (
<div className="relative group">
<a href={url} className="flex items-center space-x-2">
{dynIcon}
{icon && <IconComponent />}
</a>
<div className="absolute left-1/2 -translate-x-1/2 z-10 hidden p-2 px-4 text-sm text-black bg-white rounded-md group-hover:block text-center">
{title}
@@ -41,14 +42,14 @@ const HomePageLink = ({ title, icon, url, isPopover }: HomePageLinkProps) => {
if (isRelative) {
return (
<Link href={url} className="group leading-relaxed">
<span className="flex flex-row gap-2">{dynIcon} {title}</span>
<span className="flex flex-row gap-2">{icon && <IconComponent />} {title}</span>
<span className="block max-w-0 group-hover:max-w-full transition-all duration-500 h-0.5 bg-white"></span>
</Link>
)
} else {
return (
<a href={url} className="group leading-relaxed">
<span className="flex flex-row gap-2">{dynIcon} {title}</span>
<span className="flex flex-row gap-2">{icon && <IconComponent />} {title}</span>
<span className="block max-w-0 group-hover:max-w-full transition-all duration-500 h-0.5 bg-white"></span>
</a>
)

View File

@@ -1,4 +1,5 @@
import { lucideOptions } from "@/lib/lucid-options";
import { revalidatePath } from "next/cache";
import { GlobalConfig } from "payload";
export const Home: GlobalConfig = {
@@ -54,4 +55,11 @@ export const Home: GlobalConfig = {
],
},
],
hooks: {
afterChange: [
async () => {
revalidatePath("/projects");
}
],
}
}

View File

@@ -1,6 +1,15 @@
import { Code2, Github, Linkedin, LucideIcon, Notebook } from "lucide-react"
export const lucideOptions: { label: string, value: string }[] = [
{ label: "Code 2", value: "code-2" },
{ label: "Notebook", value: "notebook" },
{ label: "Github", value: "github" },
{ label: "Linkedin", value: "linkedin" },
]
];
export const lucidIconMap: Record<string, LucideIcon> = {
"code-2": Code2,
"notebook": Notebook,
"github": Github,
"linkedin": Linkedin,
};

View File

@@ -1,193 +0,0 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.run(sql`CREATE TABLE \`users_sessions\` (
\`_order\` integer NOT NULL,
\`_parent_id\` integer NOT NULL,
\`id\` text PRIMARY KEY NOT NULL,
\`created_at\` text,
\`expires_at\` text NOT NULL,
FOREIGN KEY (\`_parent_id\`) REFERENCES \`users\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`users_sessions_order_idx\` ON \`users_sessions\` (\`_order\`);`)
await db.run(sql`CREATE INDEX \`users_sessions_parent_id_idx\` ON \`users_sessions\` (\`_parent_id\`);`)
await db.run(sql`CREATE TABLE \`users\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`email\` text NOT NULL,
\`reset_password_token\` text,
\`reset_password_expiration\` text,
\`salt\` text,
\`hash\` text,
\`login_attempts\` numeric DEFAULT 0,
\`lock_until\` text
);
`)
await db.run(sql`CREATE INDEX \`users_updated_at_idx\` ON \`users\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`users_created_at_idx\` ON \`users\` (\`created_at\`);`)
await db.run(sql`CREATE UNIQUE INDEX \`users_email_idx\` ON \`users\` (\`email\`);`)
await db.run(sql`CREATE TABLE \`media\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`alt\` text NOT NULL,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`url\` text,
\`thumbnail_u_r_l\` text,
\`filename\` text,
\`mime_type\` text,
\`filesize\` numeric,
\`width\` numeric,
\`height\` numeric,
\`focal_x\` numeric,
\`focal_y\` numeric,
\`sizes_thumbnail_url\` text,
\`sizes_thumbnail_width\` numeric,
\`sizes_thumbnail_height\` numeric,
\`sizes_thumbnail_mime_type\` text,
\`sizes_thumbnail_filesize\` numeric,
\`sizes_thumbnail_filename\` text
);
`)
await db.run(sql`CREATE INDEX \`media_updated_at_idx\` ON \`media\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`media_created_at_idx\` ON \`media\` (\`created_at\`);`)
await db.run(sql`CREATE UNIQUE INDEX \`media_filename_idx\` ON \`media\` (\`filename\`);`)
await db.run(sql`CREATE INDEX \`media_sizes_thumbnail_sizes_thumbnail_filename_idx\` ON \`media\` (\`sizes_thumbnail_filename\`);`)
await db.run(sql`CREATE TABLE \`project_tags\` (
\`_order\` integer NOT NULL,
\`_parent_id\` integer NOT NULL,
\`id\` text PRIMARY KEY NOT NULL,
\`tag\` text NOT NULL,
FOREIGN KEY (\`_parent_id\`) REFERENCES \`project\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`project_tags_order_idx\` ON \`project_tags\` (\`_order\`);`)
await db.run(sql`CREATE INDEX \`project_tags_parent_id_idx\` ON \`project_tags\` (\`_parent_id\`);`)
await db.run(sql`CREATE TABLE \`project\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`title\` text NOT NULL,
\`description\` text NOT NULL,
\`featured_image_id\` integer,
\`view_link\` text,
\`repository_link\` text,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
FOREIGN KEY (\`featured_image_id\`) REFERENCES \`media\`(\`id\`) ON UPDATE no action ON DELETE set null
);
`)
await db.run(sql`CREATE INDEX \`project_featured_image_idx\` ON \`project\` (\`featured_image_id\`);`)
await db.run(sql`CREATE INDEX \`project_updated_at_idx\` ON \`project\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`project_created_at_idx\` ON \`project\` (\`created_at\`);`)
await db.run(sql`CREATE TABLE \`payload_locked_documents\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`global_slug\` text,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL
);
`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_global_slug_idx\` ON \`payload_locked_documents\` (\`global_slug\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_updated_at_idx\` ON \`payload_locked_documents\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_created_at_idx\` ON \`payload_locked_documents\` (\`created_at\`);`)
await db.run(sql`CREATE TABLE \`payload_locked_documents_rels\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`order\` integer,
\`parent_id\` integer NOT NULL,
\`path\` text NOT NULL,
\`users_id\` integer,
\`media_id\` integer,
\`project_id\` integer,
FOREIGN KEY (\`parent_id\`) REFERENCES \`payload_locked_documents\`(\`id\`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (\`users_id\`) REFERENCES \`users\`(\`id\`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (\`media_id\`) REFERENCES \`media\`(\`id\`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (\`project_id\`) REFERENCES \`project\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_order_idx\` ON \`payload_locked_documents_rels\` (\`order\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_parent_idx\` ON \`payload_locked_documents_rels\` (\`parent_id\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_path_idx\` ON \`payload_locked_documents_rels\` (\`path\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_users_id_idx\` ON \`payload_locked_documents_rels\` (\`users_id\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_media_id_idx\` ON \`payload_locked_documents_rels\` (\`media_id\`);`)
await db.run(sql`CREATE INDEX \`payload_locked_documents_rels_project_id_idx\` ON \`payload_locked_documents_rels\` (\`project_id\`);`)
await db.run(sql`CREATE TABLE \`payload_preferences\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`key\` text,
\`value\` text,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL
);
`)
await db.run(sql`CREATE INDEX \`payload_preferences_key_idx\` ON \`payload_preferences\` (\`key\`);`)
await db.run(sql`CREATE INDEX \`payload_preferences_updated_at_idx\` ON \`payload_preferences\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`payload_preferences_created_at_idx\` ON \`payload_preferences\` (\`created_at\`);`)
await db.run(sql`CREATE TABLE \`payload_preferences_rels\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`order\` integer,
\`parent_id\` integer NOT NULL,
\`path\` text NOT NULL,
\`users_id\` integer,
FOREIGN KEY (\`parent_id\`) REFERENCES \`payload_preferences\`(\`id\`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (\`users_id\`) REFERENCES \`users\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`payload_preferences_rels_order_idx\` ON \`payload_preferences_rels\` (\`order\`);`)
await db.run(sql`CREATE INDEX \`payload_preferences_rels_parent_idx\` ON \`payload_preferences_rels\` (\`parent_id\`);`)
await db.run(sql`CREATE INDEX \`payload_preferences_rels_path_idx\` ON \`payload_preferences_rels\` (\`path\`);`)
await db.run(sql`CREATE INDEX \`payload_preferences_rels_users_id_idx\` ON \`payload_preferences_rels\` (\`users_id\`);`)
await db.run(sql`CREATE TABLE \`payload_migrations\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`name\` text,
\`batch\` numeric,
\`updated_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
\`created_at\` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL
);
`)
await db.run(sql`CREATE INDEX \`payload_migrations_updated_at_idx\` ON \`payload_migrations\` (\`updated_at\`);`)
await db.run(sql`CREATE INDEX \`payload_migrations_created_at_idx\` ON \`payload_migrations\` (\`created_at\`);`)
await db.run(sql`CREATE TABLE \`home_main_links\` (
\`_order\` integer NOT NULL,
\`_parent_id\` integer NOT NULL,
\`id\` text PRIMARY KEY NOT NULL,
\`title\` text NOT NULL,
\`url\` text NOT NULL,
\`icon\` text NOT NULL,
FOREIGN KEY (\`_parent_id\`) REFERENCES \`home\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`home_main_links_order_idx\` ON \`home_main_links\` (\`_order\`);`)
await db.run(sql`CREATE INDEX \`home_main_links_parent_id_idx\` ON \`home_main_links\` (\`_parent_id\`);`)
await db.run(sql`CREATE TABLE \`home_popover_links\` (
\`_order\` integer NOT NULL,
\`_parent_id\` integer NOT NULL,
\`id\` text PRIMARY KEY NOT NULL,
\`title\` text NOT NULL,
\`url\` text NOT NULL,
\`icon\` text NOT NULL,
FOREIGN KEY (\`_parent_id\`) REFERENCES \`home\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`)
await db.run(sql`CREATE INDEX \`home_popover_links_order_idx\` ON \`home_popover_links\` (\`_order\`);`)
await db.run(sql`CREATE INDEX \`home_popover_links_parent_id_idx\` ON \`home_popover_links\` (\`_parent_id\`);`)
await db.run(sql`CREATE TABLE \`home\` (
\`id\` integer PRIMARY KEY NOT NULL,
\`updated_at\` text,
\`created_at\` text
);
`)
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.run(sql`DROP TABLE \`users_sessions\`;`)
await db.run(sql`DROP TABLE \`users\`;`)
await db.run(sql`DROP TABLE \`media\`;`)
await db.run(sql`DROP TABLE \`project_tags\`;`)
await db.run(sql`DROP TABLE \`project\`;`)
await db.run(sql`DROP TABLE \`payload_locked_documents\`;`)
await db.run(sql`DROP TABLE \`payload_locked_documents_rels\`;`)
await db.run(sql`DROP TABLE \`payload_preferences\`;`)
await db.run(sql`DROP TABLE \`payload_preferences_rels\`;`)
await db.run(sql`DROP TABLE \`payload_migrations\`;`)
await db.run(sql`DROP TABLE \`home_main_links\`;`)
await db.run(sql`DROP TABLE \`home_popover_links\`;`)
await db.run(sql`DROP TABLE \`home\`;`)
}

View File

@@ -0,0 +1,207 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TYPE "public"."enum_home_main_links_icon" AS ENUM('code-2', 'notebook', 'github', 'linkedin');
CREATE TYPE "public"."enum_home_popover_links_icon" AS ENUM('code-2', 'notebook', 'github', 'linkedin');
CREATE TABLE "users_sessions" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"created_at" timestamp(3) with time zone,
"expires_at" timestamp(3) with time zone NOT NULL
);
CREATE TABLE "users" (
"id" serial PRIMARY KEY NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"email" varchar NOT NULL,
"reset_password_token" varchar,
"reset_password_expiration" timestamp(3) with time zone,
"salt" varchar,
"hash" varchar,
"login_attempts" numeric DEFAULT 0,
"lock_until" timestamp(3) with time zone
);
CREATE TABLE "media" (
"id" serial PRIMARY KEY NOT NULL,
"alt" varchar NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"url" varchar,
"thumbnail_u_r_l" varchar,
"filename" varchar,
"mime_type" varchar,
"filesize" numeric,
"width" numeric,
"height" numeric,
"focal_x" numeric,
"focal_y" numeric,
"sizes_thumbnail_url" varchar,
"sizes_thumbnail_width" numeric,
"sizes_thumbnail_height" numeric,
"sizes_thumbnail_mime_type" varchar,
"sizes_thumbnail_filesize" numeric,
"sizes_thumbnail_filename" varchar
);
CREATE TABLE "project_tags" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"tag" varchar NOT NULL
);
CREATE TABLE "project" (
"id" serial PRIMARY KEY NOT NULL,
"title" varchar NOT NULL,
"description" varchar NOT NULL,
"featured_image_id" integer,
"view_link" varchar,
"repository_link" varchar,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE "payload_kv" (
"id" serial PRIMARY KEY NOT NULL,
"key" varchar NOT NULL,
"data" jsonb NOT NULL
);
CREATE TABLE "payload_locked_documents" (
"id" serial PRIMARY KEY NOT NULL,
"global_slug" varchar,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE "payload_locked_documents_rels" (
"id" serial PRIMARY KEY NOT NULL,
"order" integer,
"parent_id" integer NOT NULL,
"path" varchar NOT NULL,
"users_id" integer,
"media_id" integer,
"project_id" integer
);
CREATE TABLE "payload_preferences" (
"id" serial PRIMARY KEY NOT NULL,
"key" varchar,
"value" jsonb,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE "payload_preferences_rels" (
"id" serial PRIMARY KEY NOT NULL,
"order" integer,
"parent_id" integer NOT NULL,
"path" varchar NOT NULL,
"users_id" integer
);
CREATE TABLE "payload_migrations" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar,
"batch" numeric,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE "home_main_links" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"title" varchar NOT NULL,
"url" varchar NOT NULL,
"icon" "enum_home_main_links_icon" NOT NULL
);
CREATE TABLE "home_popover_links" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"title" varchar NOT NULL,
"url" varchar NOT NULL,
"icon" "enum_home_popover_links_icon" NOT NULL
);
CREATE TABLE "home" (
"id" serial PRIMARY KEY NOT NULL,
"updated_at" timestamp(3) with time zone,
"created_at" timestamp(3) with time zone
);
ALTER TABLE "users_sessions" ADD CONSTRAINT "users_sessions_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "project_tags" ADD CONSTRAINT "project_tags_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "project" ADD CONSTRAINT "project_featured_image_id_media_id_fk" FOREIGN KEY ("featured_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_locked_documents"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_media_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_project_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_preferences"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "home_main_links" ADD CONSTRAINT "home_main_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."home"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "home_popover_links" ADD CONSTRAINT "home_popover_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."home"("id") ON DELETE cascade ON UPDATE no action;
CREATE INDEX "users_sessions_order_idx" ON "users_sessions" USING btree ("_order");
CREATE INDEX "users_sessions_parent_id_idx" ON "users_sessions" USING btree ("_parent_id");
CREATE INDEX "users_updated_at_idx" ON "users" USING btree ("updated_at");
CREATE INDEX "users_created_at_idx" ON "users" USING btree ("created_at");
CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email");
CREATE INDEX "media_updated_at_idx" ON "media" USING btree ("updated_at");
CREATE INDEX "media_created_at_idx" ON "media" USING btree ("created_at");
CREATE UNIQUE INDEX "media_filename_idx" ON "media" USING btree ("filename");
CREATE INDEX "media_sizes_thumbnail_sizes_thumbnail_filename_idx" ON "media" USING btree ("sizes_thumbnail_filename");
CREATE INDEX "project_tags_order_idx" ON "project_tags" USING btree ("_order");
CREATE INDEX "project_tags_parent_id_idx" ON "project_tags" USING btree ("_parent_id");
CREATE INDEX "project_featured_image_idx" ON "project" USING btree ("featured_image_id");
CREATE INDEX "project_updated_at_idx" ON "project" USING btree ("updated_at");
CREATE INDEX "project_created_at_idx" ON "project" USING btree ("created_at");
CREATE UNIQUE INDEX "payload_kv_key_idx" ON "payload_kv" USING btree ("key");
CREATE INDEX "payload_locked_documents_global_slug_idx" ON "payload_locked_documents" USING btree ("global_slug");
CREATE INDEX "payload_locked_documents_updated_at_idx" ON "payload_locked_documents" USING btree ("updated_at");
CREATE INDEX "payload_locked_documents_created_at_idx" ON "payload_locked_documents" USING btree ("created_at");
CREATE INDEX "payload_locked_documents_rels_order_idx" ON "payload_locked_documents_rels" USING btree ("order");
CREATE INDEX "payload_locked_documents_rels_parent_idx" ON "payload_locked_documents_rels" USING btree ("parent_id");
CREATE INDEX "payload_locked_documents_rels_path_idx" ON "payload_locked_documents_rels" USING btree ("path");
CREATE INDEX "payload_locked_documents_rels_users_id_idx" ON "payload_locked_documents_rels" USING btree ("users_id");
CREATE INDEX "payload_locked_documents_rels_media_id_idx" ON "payload_locked_documents_rels" USING btree ("media_id");
CREATE INDEX "payload_locked_documents_rels_project_id_idx" ON "payload_locked_documents_rels" USING btree ("project_id");
CREATE INDEX "payload_preferences_key_idx" ON "payload_preferences" USING btree ("key");
CREATE INDEX "payload_preferences_updated_at_idx" ON "payload_preferences" USING btree ("updated_at");
CREATE INDEX "payload_preferences_created_at_idx" ON "payload_preferences" USING btree ("created_at");
CREATE INDEX "payload_preferences_rels_order_idx" ON "payload_preferences_rels" USING btree ("order");
CREATE INDEX "payload_preferences_rels_parent_idx" ON "payload_preferences_rels" USING btree ("parent_id");
CREATE INDEX "payload_preferences_rels_path_idx" ON "payload_preferences_rels" USING btree ("path");
CREATE INDEX "payload_preferences_rels_users_id_idx" ON "payload_preferences_rels" USING btree ("users_id");
CREATE INDEX "payload_migrations_updated_at_idx" ON "payload_migrations" USING btree ("updated_at");
CREATE INDEX "payload_migrations_created_at_idx" ON "payload_migrations" USING btree ("created_at");
CREATE INDEX "home_main_links_order_idx" ON "home_main_links" USING btree ("_order");
CREATE INDEX "home_main_links_parent_id_idx" ON "home_main_links" USING btree ("_parent_id");
CREATE INDEX "home_popover_links_order_idx" ON "home_popover_links" USING btree ("_order");
CREATE INDEX "home_popover_links_parent_id_idx" ON "home_popover_links" USING btree ("_parent_id");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
DROP TABLE "users_sessions" CASCADE;
DROP TABLE "users" CASCADE;
DROP TABLE "media" CASCADE;
DROP TABLE "project_tags" CASCADE;
DROP TABLE "project" CASCADE;
DROP TABLE "payload_kv" CASCADE;
DROP TABLE "payload_locked_documents" CASCADE;
DROP TABLE "payload_locked_documents_rels" CASCADE;
DROP TABLE "payload_preferences" CASCADE;
DROP TABLE "payload_preferences_rels" CASCADE;
DROP TABLE "payload_migrations" CASCADE;
DROP TABLE "home_main_links" CASCADE;
DROP TABLE "home_popover_links" CASCADE;
DROP TABLE "home" CASCADE;
DROP TYPE "public"."enum_home_main_links_icon";
DROP TYPE "public"."enum_home_popover_links_icon";`)
}

View File

@@ -1,9 +1,9 @@
import * as migration_20250828_224637 from './20250828_224637';
import * as migration_20260116_050059 from './20260116_050059';
export const migrations = [
{
up: migration_20250828_224637.up,
down: migration_20250828_224637.down,
name: '20250828_224637'
up: migration_20260116_050059.up,
down: migration_20260116_050059.down,
name: '20260116_050059'
},
];

View File

@@ -70,6 +70,7 @@ export interface Config {
users: User;
media: Media;
project: Project;
'payload-kv': PayloadKv;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
@@ -79,6 +80,7 @@ export interface Config {
users: UsersSelect<false> | UsersSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
project: ProjectSelect<false> | ProjectSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@@ -86,6 +88,7 @@ export interface Config {
db: {
defaultIDType: number;
};
fallbackLocale: null;
globals: {
home: Home;
};
@@ -192,6 +195,23 @@ export interface Project {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv".
*/
export interface PayloadKv {
id: number;
key: string;
data:
| {
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
@@ -326,6 +346,14 @@ export interface ProjectSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv_select".
*/
export interface PayloadKvSelect<T extends boolean = true> {
key?: T;
data?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".

View File

@@ -1,14 +1,15 @@
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload'
import { fileURLToPath } from 'url'
import sharp from 'sharp'
import { sqliteAdapter } from '@payloadcms/db-sqlite'
import { postgresAdapter } from "@payloadcms/db-postgres"
import { lexicalEditor } from "@payloadcms/richtext-lexical"
import path from "path"
import { buildConfig } from "payload"
import { s3Storage } from "@payloadcms/storage-s3"
import sharp from "sharp"
import { fileURLToPath } from "url"
import { Users } from './collections/Users'
import { Media } from './collections/Media'
import { Media } from "./collections/Media"
import { Projects } from "./collections/Projects"
import { Home } from './globals/home'
import { Users } from "./collections/Users"
import { Home } from "./globals/home"
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
@@ -23,17 +24,31 @@ export default buildConfig({
collections: [Users, Media, Projects],
globals: [Home],
editor: lexicalEditor(),
secret: process.env.PAYLOAD_SECRET || '',
secret: process.env.PAYLOAD_SECRET || "",
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
outputFile: path.resolve(dirname, "payload-types.ts"),
},
db: postgresAdapter({
pool: {
connectionString: process.env.DATABASE_URL || "",
},
/**
* Both our media and db will reside in the 'portfolio-data' directory
* We can use a docker volume to persist this data
*/
db: sqliteAdapter({
client: { url: "file:./portfolio-data/data.db" }
}),
sharp,
plugins: [],
plugins: [
s3Storage({
collections: {
media: true,
},
bucket: process.env.S3_BUCKET || "",
config: {
forcePathStyle: true,
region: process.env.S3_REGION || "",
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID || "",
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY || "",
},
endpoint: process.env.S3_ENDPOINT || undefined,
}
}),
],
})

View File

@@ -15,7 +15,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
@@ -35,7 +35,8 @@
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"