From 130e7928d15e09181b75205b1dd56c1454a82f5b Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Sat, 9 Aug 2025 13:19:01 +1200 Subject: [PATCH] caching, revalidating, docker-compose working next/payload --- Dockerfile | 28 +++++ docker-compose.yml | 52 +++++++-- next.config.ts | 2 + package.json | 6 +- pnpm-lock.yaml | 161 ++++++++++++++++++++++---- src/globals/General.ts | 7 ++ src/globals/Home/Hero.ts | 4 + src/globals/Home/Projects.ts | 4 + src/globals/Home/hooks/refreshHome.ts | 5 + 9 files changed, 232 insertions(+), 37 deletions(-) create mode 100644 Dockerfile create mode 100644 src/globals/Home/hooks/refreshHome.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6107c2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM node:22-slim AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +# Stage 1: Install dependencies +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +# Stage 2: Build the application +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN pnpm run build + +# Stage 3: Production server +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml index b607af8..e5e6744 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,46 @@ ---- services: - postgres: - image: postgres:12.18 - restart: always + web: + build: . ports: - - "5432:5432" + - "3000:3000" environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=admin - - POSTGRES_DB=website - volumes: - - ial-website-data:/var/lib/postgresql/data + - NODE_ENV=production + # depends_on: + # - db + # networks: + # - my_network + # volumes: + # - payload_media:/data/media + + # db: + # image: postgres:latest + # environment: + # POSTGRES_USER: ${POSTGRES_USER} + # POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + # POSTGRES_DB: ${POSTGRES_DB} + # ports: + # - "5432:5432" + # volumes: + # - postgres_data:/var/lib/postgresql/data + # networks: + # - my_network + + # cron: + # image: alpine/curl + # command: > + # sh -c " + # echo '*/10 * * * * curl -X POST http://web:3000/db/clear' > /etc/crontabs/root && \ + # crond -f -l 2 + # " + # depends_on: + # - web + # networks: + # - my_network volumes: - ial-website-data: + postgres_data: + # payload_media: +# networks: +# my_network: +# name: my_network +# driver: bridge diff --git a/next.config.ts b/next.config.ts index dc4cf9e..f9bb9bc 100644 --- a/next.config.ts +++ b/next.config.ts @@ -3,12 +3,14 @@ import withPayload from "@payloadcms/next/withPayload"; const nextConfig: NextConfig = { /* config options here */ + output: "standalone", images: { remotePatterns: [ new URL("http://localhost:3000/**"), new URL("https://inzight.co.nz/**"), ], }, + compress: false, }; export default withPayload(nextConfig); diff --git a/package.json b/package.json index 005c0a3..6ab4934 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next start", + "prestart": "cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/", + "start": "node .next/standalone/server.js", "lint": "next lint" }, "dependencies": { @@ -32,11 +33,14 @@ }, "devDependencies": { "@eslint/eslintrc": "^3", + "@next/eslint-plugin-next": "^15.4.6", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.3.1", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^5.2.0", "prettier": "^3.5.3", "typescript": "^5" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8053fd6..128074e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,6 +69,9 @@ importers: '@eslint/eslintrc': specifier: ^3 version: 3.3.1 + '@next/eslint-plugin-next': + specifier: ^15.4.6 + version: 15.4.6 '@types/node': specifier: ^20 version: 20.17.30 @@ -84,6 +87,12 @@ importers: eslint-config-next: specifier: 15.3.1 version: 15.3.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + eslint-plugin-react: + specifier: ^7.37.5 + version: 7.37.5(eslint@9.25.0(jiti@2.4.2)) + eslint-plugin-react-hooks: + specifier: ^5.2.0 + version: 5.2.0(eslint@9.25.0(jiti@2.4.2)) prettier: specifier: ^3.5.3 version: 3.5.3 @@ -651,6 +660,12 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + '@eslint-community/eslint-utils@4.7.0': + resolution: {integrity: sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + '@eslint-community/regexpp@4.12.1': resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} @@ -966,6 +981,9 @@ packages: '@next/eslint-plugin-next@15.3.1': resolution: {integrity: sha512-oEs4dsfM6iyER3jTzMm4kDSbrQJq8wZw5fmT6fg2V3SMo+kgG+cShzLfEV20senZzv8VF+puNLheiGPlBGsv2A==} + '@next/eslint-plugin-next@15.4.6': + resolution: {integrity: sha512-2NOu3ln+BTcpnbIDuxx6MNq+pRrCyey4WSXGaJIyt0D2TYicHeO9QrUENNjcf673n3B1s7hsiV5xBYRCK1Q8kA==} + '@next/swc-darwin-arm64@15.3.1': resolution: {integrity: sha512-hjDw4f4/nla+6wysBL07z52Gs55Gttp5Bsk5/8AncQLJoisvTBP0pRIBK/B16/KqQyH+uN4Ww8KkcAqJODYH3w==} engines: {node: '>= 10'} @@ -1344,13 +1362,13 @@ packages: '@types/uuid@10.0.0': resolution: {integrity: sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==} - '@typescript-eslint/eslint-plugin@8.30.1': - resolution: {integrity: sha512-v+VWphxMjn+1t48/jO4t950D6KR8JaJuNXzi33Ve6P8sEmPr5k6CEXjdGwT6+LodVnEa91EQCtwjWNUCPweo+Q==} + '@typescript-eslint/eslint-plugin@8.39.0': + resolution: {integrity: sha512-bhEz6OZeUR+O/6yx9Jk6ohX6H9JSFTaiY0v9/PuKT3oGK0rn0jNplLmyFUGV+a9gfYnVNwGDwS/UkLIuXNb2Rw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 + '@typescript-eslint/parser': ^8.39.0 eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/parser@8.30.1': resolution: {integrity: sha512-H+vqmWwT5xoNrXqWs/fesmssOW70gxFlgcMlYcBaWNPIEWDgLa4W9nkSPmhuOgLnXq9QYgkZ31fhDyLhleCsAg==} @@ -1359,38 +1377,68 @@ packages: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' + '@typescript-eslint/project-service@8.39.0': + resolution: {integrity: sha512-CTzJqaSq30V/Z2Og9jogzZt8lJRR5TKlAdXmWgdu4hgcC9Kww5flQ+xFvMxIBWVNdxJO7OifgdOK4PokMIWPew==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.0.0' + '@typescript-eslint/scope-manager@8.30.1': resolution: {integrity: sha512-+C0B6ChFXZkuaNDl73FJxRYT0G7ufVPOSQkqkpM/U198wUwUFOtgo1k/QzFh1KjpBitaK7R1tgjVz6o9HmsRPg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.30.1': - resolution: {integrity: sha512-64uBF76bfQiJyHgZISC7vcNz3adqQKIccVoKubyQcOnNcdJBvYOILV1v22Qhsw3tw3VQu5ll8ND6hycgAR5fEA==} + '@typescript-eslint/scope-manager@8.39.0': + resolution: {integrity: sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.39.0': + resolution: {integrity: sha512-Fd3/QjmFV2sKmvv3Mrj8r6N8CryYiCS8Wdb/6/rgOXAWGcFuc+VkQuG28uk/4kVNVZBQuuDHEDUpo/pQ32zsIQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.0.0' + + '@typescript-eslint/type-utils@8.39.0': + resolution: {integrity: sha512-6B3z0c1DXVT2vYA9+z9axjtc09rqKUPRmijD5m9iv8iQpHBRYRMBcgxSiKTZKm6FwWw1/cI4v6em35OsKCiN5Q==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/types@8.30.1': resolution: {integrity: sha512-81KawPfkuulyWo5QdyG/LOKbspyyiW+p4vpn4bYO7DM/hZImlVnFwrpCTnmNMOt8CvLRr5ojI9nU1Ekpw4RcEw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/types@8.39.0': + resolution: {integrity: sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/typescript-estree@8.30.1': resolution: {integrity: sha512-kQQnxymiUy9tTb1F2uep9W6aBiYODgq5EMSk6Nxh4Z+BDUoYUSa029ISs5zTzKBFnexQEh71KqwjKnRz58lusQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/utils@8.30.1': - resolution: {integrity: sha512-T/8q4R9En2tcEsWPQgB5BQ0XJVOtfARcUvOa8yJP3fh9M/mXraLxZrkCfGb6ChrO/V3W+Xbd04RacUEqk1CFEQ==} + '@typescript-eslint/typescript-estree@8.39.0': + resolution: {integrity: sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.0.0' + + '@typescript-eslint/utils@8.39.0': + resolution: {integrity: sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/visitor-keys@8.30.1': resolution: {integrity: sha512-aEhgas7aJ6vZnNFC7K4/vMGDGyOiqWcYZPpIWrTKuTAlsvDNKy2GFDqh9smL+iq069ZvR0YzEeq0B8NJlLzjFA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/visitor-keys@8.39.0': + resolution: {integrity: sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@unrs/resolver-binding-darwin-arm64@1.5.0': resolution: {integrity: sha512-YmocNlEcX/AgJv8gI41bhjMOTcKcea4D2nRIbZj+MhRtSH5+vEU8r/pFuTuoF+JjVplLsBueU+CILfBPVISyGQ==} cpu: [arm64] @@ -2185,6 +2233,10 @@ packages: resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint-visitor-keys@4.2.1: + resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint@9.25.0: resolution: {integrity: sha512-MsBdObhM4cEwkzCiraDv7A6txFXEqtNXOb877TsSp2FCkBNl8JfVQrmiuDqC1IkejT6JLPzYBXx/xAiYhyzgGA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2439,6 +2491,10 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.5: + resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} + engines: {node: '>= 4'} + image-size@2.0.2: resolution: {integrity: sha512-IRqXKlaXwgSMAMtpNzZa1ZAe8m+Sa1770Dhk8VkSsP9LS+iHD62Zd8FQKs8fbPiagBE7BzoFX23cxFnwshpV6w==} engines: {node: '>=16.x'} @@ -4139,6 +4195,11 @@ snapshots: eslint: 9.25.0(jiti@2.4.2) eslint-visitor-keys: 3.4.3 + '@eslint-community/eslint-utils@4.7.0(eslint@9.25.0(jiti@2.4.2))': + dependencies: + eslint: 9.25.0(jiti@2.4.2) + eslint-visitor-keys: 3.4.3 + '@eslint-community/regexpp@4.12.1': {} '@eslint/config-array@0.20.0': @@ -4504,6 +4565,10 @@ snapshots: dependencies: fast-glob: 3.3.1 + '@next/eslint-plugin-next@15.4.6': + dependencies: + fast-glob: 3.3.1 + '@next/swc-darwin-arm64@15.3.1': optional: true @@ -5009,17 +5074,17 @@ snapshots: '@types/uuid@10.0.0': {} - '@typescript-eslint/eslint-plugin@8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.39.0(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@eslint-community/regexpp': 4.12.1 '@typescript-eslint/parser': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/scope-manager': 8.30.1 - '@typescript-eslint/type-utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.30.1 + '@typescript-eslint/scope-manager': 8.39.0 + '@typescript-eslint/type-utils': 8.39.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.39.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.39.0 eslint: 9.25.0(jiti@2.4.2) graphemer: 1.4.0 - ignore: 5.3.2 + ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.1.0(typescript@5.8.3) typescript: 5.8.3 @@ -5038,15 +5103,34 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/project-service@8.39.0(typescript@5.8.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.39.0(typescript@5.8.3) + '@typescript-eslint/types': 8.39.0 + debug: 4.4.0 + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + '@typescript-eslint/scope-manager@8.30.1': dependencies: '@typescript-eslint/types': 8.30.1 '@typescript-eslint/visitor-keys': 8.30.1 - '@typescript-eslint/type-utils@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/scope-manager@8.39.0': dependencies: - '@typescript-eslint/typescript-estree': 8.30.1(typescript@5.8.3) - '@typescript-eslint/utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/types': 8.39.0 + '@typescript-eslint/visitor-keys': 8.39.0 + + '@typescript-eslint/tsconfig-utils@8.39.0(typescript@5.8.3)': + dependencies: + typescript: 5.8.3 + + '@typescript-eslint/type-utils@8.39.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/types': 8.39.0 + '@typescript-eslint/typescript-estree': 8.39.0(typescript@5.8.3) + '@typescript-eslint/utils': 8.39.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) debug: 4.4.0 eslint: 9.25.0(jiti@2.4.2) ts-api-utils: 2.1.0(typescript@5.8.3) @@ -5056,6 +5140,8 @@ snapshots: '@typescript-eslint/types@8.30.1': {} + '@typescript-eslint/types@8.39.0': {} + '@typescript-eslint/typescript-estree@8.30.1(typescript@5.8.3)': dependencies: '@typescript-eslint/types': 8.30.1 @@ -5070,12 +5156,28 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.39.0(typescript@5.8.3)': dependencies: - '@eslint-community/eslint-utils': 4.6.1(eslint@9.25.0(jiti@2.4.2)) - '@typescript-eslint/scope-manager': 8.30.1 - '@typescript-eslint/types': 8.30.1 - '@typescript-eslint/typescript-estree': 8.30.1(typescript@5.8.3) + '@typescript-eslint/project-service': 8.39.0(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.39.0(typescript@5.8.3) + '@typescript-eslint/types': 8.39.0 + '@typescript-eslint/visitor-keys': 8.39.0 + debug: 4.4.0 + fast-glob: 3.3.3 + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.7.1 + ts-api-utils: 2.1.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.39.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@eslint-community/eslint-utils': 4.7.0(eslint@9.25.0(jiti@2.4.2)) + '@typescript-eslint/scope-manager': 8.39.0 + '@typescript-eslint/types': 8.39.0 + '@typescript-eslint/typescript-estree': 8.39.0(typescript@5.8.3) eslint: 9.25.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: @@ -5086,6 +5188,11 @@ snapshots: '@typescript-eslint/types': 8.30.1 eslint-visitor-keys: 4.2.0 + '@typescript-eslint/visitor-keys@8.39.0': + dependencies: + '@typescript-eslint/types': 8.39.0 + eslint-visitor-keys: 4.2.1 + '@unrs/resolver-binding-darwin-arm64@1.5.0': optional: true @@ -5854,7 +5961,7 @@ snapshots: dependencies: '@next/eslint-plugin-next': 15.3.1 '@rushstack/eslint-patch': 1.11.0 - '@typescript-eslint/eslint-plugin': 8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/eslint-plugin': 8.39.0(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) '@typescript-eslint/parser': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) eslint: 9.25.0(jiti@2.4.2) eslint-import-resolver-node: 0.3.9 @@ -5987,6 +6094,8 @@ snapshots: eslint-visitor-keys@4.2.0: {} + eslint-visitor-keys@4.2.1: {} + eslint@9.25.0(jiti@2.4.2): dependencies: '@eslint-community/eslint-utils': 4.6.1(eslint@9.25.0(jiti@2.4.2)) @@ -6261,6 +6370,8 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.5: {} + image-size@2.0.2: {} immutable@4.3.7: {} diff --git a/src/globals/General.ts b/src/globals/General.ts index 629f274..b384092 100644 --- a/src/globals/General.ts +++ b/src/globals/General.ts @@ -1,3 +1,4 @@ +import { revalidatePath } from "next/cache"; import { GlobalConfig } from "payload"; export const General: GlobalConfig = { @@ -12,4 +13,10 @@ export const General: GlobalConfig = { relationTo: "images", }, ], + hooks: { + afterChange: [ + // revalidate ALL pages ... + () => revalidatePath("/", "layout"), + ], + }, }; diff --git a/src/globals/Home/Hero.ts b/src/globals/Home/Hero.ts index af60d9d..3bc6732 100644 --- a/src/globals/Home/Hero.ts +++ b/src/globals/Home/Hero.ts @@ -1,4 +1,5 @@ import { GlobalConfig } from "payload"; +import refreshHome from "./hooks/refreshHome"; export const HomeHero: GlobalConfig = { slug: "homeHero", @@ -111,4 +112,7 @@ export const HomeHero: GlobalConfig = { admin: { group: "Home page", }, + hooks: { + afterChange: [refreshHome], + }, }; diff --git a/src/globals/Home/Projects.ts b/src/globals/Home/Projects.ts index 74a5fa3..a2fa1b3 100644 --- a/src/globals/Home/Projects.ts +++ b/src/globals/Home/Projects.ts @@ -1,4 +1,5 @@ import { GlobalConfig } from "payload"; +import refreshHome from "./hooks/refreshHome"; export const HomeProjects: GlobalConfig = { slug: "homeProjects", @@ -19,4 +20,7 @@ export const HomeProjects: GlobalConfig = { admin: { group: "Home page", }, + hooks: { + afterChange: [refreshHome], + }, }; diff --git a/src/globals/Home/hooks/refreshHome.ts b/src/globals/Home/hooks/refreshHome.ts new file mode 100644 index 0000000..8722fdd --- /dev/null +++ b/src/globals/Home/hooks/refreshHome.ts @@ -0,0 +1,5 @@ +import { revalidatePath } from "next/cache"; + +export default function refreshHome() { + revalidatePath("/"); +}