Compare commits

...

16 Commits

Author SHA1 Message Date
e1101f2e60 fix(ci): update to v1.8.21 for x86 base images
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🧪 QA (push) Failing after 13s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
2026-02-26 19:44:29 +01:00
0be6076512 chore: trigger x86 ci build
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 1m48s
Build & Deploy / 🏗️ Build (push) Failing after 29s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
2026-02-26 19:04:46 +01:00
62400943c2 chore: trigger x86 build for klz-2026
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 1m52s
Build & Deploy / 🏗️ Build (push) Failing after 1m38s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 18:45:51 +01:00
4c60029e21 fix(ci): update build platform from arm64 to amd64
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 1m0s
Build & Deploy / 🏗️ Build (push) Failing after 22s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
2026-02-26 17:44:59 +01:00
b3c5b911d9 perf(ci): safely relax Turbopack and Node thread pools from 1 to 3 cores to restore build speeds
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 QA (push) Has been cancelled
2026-02-26 15:12:02 +01:00
89f00c79a1 fix(ci): throttle build CPU usage by limiting rayon and libuv threads to prevent host resource starvation
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m46s
Build & Deploy / 🏗️ Build (push) Successful in 12m0s
Build & Deploy / 🚀 Deploy (push) Successful in 34s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
2026-02-26 14:29:50 +01:00
98ac3dbd10 fix(routing): restore middleware.ts to fix catastrophic next-intl 404s on staging and testing
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Successful in 1m46s
Build & Deploy / 🏗️ Build (push) Failing after 37m19s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
2026-02-26 14:12:01 +01:00
0db4c819ff fix(ci): disable next.js memory workers to prevent drone runner deadline exceeded crashes and suppress payload nodemailer verification spam during static export
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 2m47s
Build & Deploy / 🏗️ Build (push) Successful in 3m53s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 12m9s
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 13:18:38 +01:00
08a3b0be7b fix(routing): restore middleware.ts to fix next-intl 404s and resolve testing host poisoning
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Successful in 2m6s
Build & Deploy / 🏗️ Build (push) Failing after 8m33s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 12:45:37 +01:00
a953820241 style(blog): reduce hero image overlays for better visibility
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 2m10s
Build & Deploy / 🏗️ Build (push) Successful in 3m59s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 9m10s
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 12:19:08 +01:00
fa02ac597f fix: resolve pipeline timeouts, 418 hydration errors, and english category link 404s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 14s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
2026-02-26 12:13:35 +01:00
925765233e fix: retrieve drafts on staging
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 2m44s
Build & Deploy / 🏗️ Build (push) Successful in 3m56s
Build & Deploy / 🚀 Deploy (push) Successful in 18s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 34m12s
Build & Deploy / ⚡ Performance & Accessibility (push) Successful in 5m55s
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 03:13:33 +01:00
0487bd8ebe feat: show draft posts and products on testing and staging
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m44s
Build & Deploy / 🏗️ Build (push) Successful in 3m55s
Build & Deploy / 🚀 Deploy (push) Successful in 19s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 33m41s
Build & Deploy / ⚡ Performance & Accessibility (push) Successful in 8m15s
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 02:59:30 +01:00
87b2624ab3 fix(docker): remove outdated 120in password fallback causing prod auth issues
Some checks failed
Build & Deploy / 🧪 QA (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / ⚡ Performance & Accessibility (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🔍 Prepare (push) Has been cancelled
2026-02-26 02:57:43 +01:00
7cad437eb4 chore: optimize nextjs build memory and rename middleware
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 11s
Build & Deploy / 🧪 QA (push) Successful in 2m5s
Build & Deploy / 🏗️ Build (push) Successful in 4m3s
Build & Deploy / 🚀 Deploy (push) Successful in 20s
Build & Deploy / ⚡ Performance & Accessibility (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
2026-02-26 02:47:49 +01:00
f8b7d4f59d feat: add asset sync scripts and fix payload seeding
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 2m2s
Build & Deploy / 🏗️ Build (push) Failing after 4m13s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / ⚡ Performance & Accessibility (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-26 02:39:18 +01:00
23 changed files with 340 additions and 204 deletions

10
.env
View File

@@ -25,3 +25,13 @@ MAIL_RECIPIENTS=marc@cablecreations.de,info@klz-cables.com
PAYLOAD_DB_NAME=payload
PAYLOAD_DB_USER=payload
PAYLOAD_DB_PASSWORD=120in09oenaoinsd9iaidon
# ────────────────────────────────────────────────────────────────────────────
# Hetzner S3 Object Storage
# ────────────────────────────────────────────────────────────────────────────
S3_ENDPOINT=https://fsn1.your-objectstorage.com
S3_ACCESS_KEY=ROB3MSWMEIGRL7N94ZKS
S3_SECRET_KEY=9QJV3NE8xeLxhyufhNU7lsUB0RffJxPhGuEuFSH3
S3_BUCKET=mintel
S3_REGION=fsn1
S3_PREFIX=klz-cables

View File

@@ -94,6 +94,8 @@ jobs:
TRAEFIK_RULE="Host(\"$TRAEFIK_HOST\")"
PRIMARY_HOST="$TRAEFIK_HOST"
fi
GATEKEEPER_HOST="gatekeeper.$PRIMARY_HOST"
{
echo "target=$TARGET"
@@ -101,6 +103,7 @@ jobs:
echo "env_file=$ENV_FILE"
echo "traefik_host=$PRIMARY_HOST"
echo "traefik_rule=$TRAEFIK_RULE"
echo "gatekeeper_host=$GATEKEEPER_HOST"
echo "next_public_url=https://$PRIMARY_HOST"
if [[ "$TARGET" == "production" ]]; then
echo "project_name=klz-cablescom"
@@ -205,7 +208,7 @@ jobs:
context: .
push: true
provenance: false
platforms: linux/arm64
platforms: linux/amd64
build-args: |
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_url }}
NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }}
@@ -231,6 +234,7 @@ jobs:
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_url }}
TRAEFIK_HOST: ${{ needs.prepare.outputs.traefik_host }}
GATEKEEPER_HOST: ${{ needs.prepare.outputs.gatekeeper_host }}
# Secrets mapping (Payload CMS)
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET || vars.PAYLOAD_SECRET || 'you-need-to-set-a-payload-secret' }}
@@ -282,7 +286,7 @@ jobs:
AUTH_MIDDLEWARE_UNPROTECTED="$STD_MW"
# Gatekeeper Origin
GATEKEEPER_ORIGIN="$NEXT_PUBLIC_BASE_URL/gatekeeper"
GATEKEEPER_ORIGIN="https://$GATEKEEPER_HOST"
{
echo "# Generated by CI - $TARGET"
@@ -318,6 +322,7 @@ jobs:
echo "PROJECT_NAME=$PROJECT_NAME"
printf 'TRAEFIK_HOST_RULE=%s\n' "$TRAEFIK_RULE"
echo "TRAEFIK_HOST=$TRAEFIK_HOST"
echo "GATEKEEPER_HOST=$GATEKEEPER_HOST"
echo "TRAEFIK_ENTRYPOINT=websecure"
echo "TRAEFIK_TLS=true"
echo "TRAEFIK_CERT_RESOLVER=le"
@@ -431,7 +436,21 @@ jobs:
- name: Install dependencies
id: deps
run: pnpm install --frozen-lockfile
- name: 🔍 Install Chromium (for Asset Scan)
- name: 📦 Cache APT Packages
uses: actions/cache@v4
with:
path: /var/cache/apt/archives
key: apt-cache-${{ runner.os }}-${{ runner.arch }}-chromium
- name: 💾 Cache Chromium
id: cache-chromium
uses: actions/cache@v4
with:
path: /usr/bin/chromium
key: ${{ runner.os }}-chromium-native-${{ hashFiles('package.json') }}
- name: 🔍 Install Chromium (Native & ARM64)
if: steps.cache-chromium.outputs.cache-hit != 'true'
run: |
rm -f /etc/apt/apt.conf.d/docker-clean
apt-get update
@@ -502,70 +521,9 @@ jobs:
PUPPETEER_EXECUTABLE_PATH: /usr/bin/chromium
CHROME_PATH: /usr/bin/chromium
run: pnpm check:assets
# ──────────────────────────────────────────────────────────────────────────────
# JOB 6: Performance & Accessibility (Lighthouse + WCAG)
# ──────────────────────────────────────────────────────────────────────────────
performance:
name: ⚡ Performance & Accessibility
needs: [prepare, post_deploy_checks]
continue-on-error: true
if: needs.post_deploy_checks.result == 'success' && needs.prepare.outputs.target != 'branch'
runs-on: docker
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 🔐 Registry Auth
run: |
echo "@mintel:registry=https://${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}" > .npmrc
echo "//${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: 🔍 Install Chromium (Native & ARM64)
run: |
rm -f /etc/apt/apt.conf.d/docker-clean
apt-get update
apt-get install -y gnupg wget ca-certificates
# Detect OS
OS_ID=$(. /etc/os-release && echo $ID)
CODENAME=$(. /etc/os-release && echo $VERSION_CODENAME)
if [ "$OS_ID" = "debian" ]; then
echo "🎯 Debian detected - installing native chromium"
apt-get install -y chromium
else
echo "🎯 Ubuntu detected - adding xtradeb PPA"
mkdir -p /etc/apt/keyrings
KEY_ID="82BB6851C64F6880"
# Fetch PPA key
wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$KEY_ID" | gpg --dearmor > /etc/apt/keyrings/xtradeb.gpg
# Add PPA repository
echo "deb [signed-by=/etc/apt/keyrings/xtradeb.gpg] http://ppa.launchpad.net/xtradeb/apps/ubuntu $CODENAME main" > /etc/apt/sources.list.d/xtradeb-ppa.list
# PRIORITY PINNING: Force PPA over Snap-dummy
printf "Package: *\nPin: release o=LP-PPA-xtradeb-apps\nPin-Priority: 1001\n" > /etc/apt/preferences.d/xtradeb
apt-get update
apt-get install -y --allow-downgrades chromium
fi
# Standardize binary paths
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/google-chrome
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/chromium-browser
- name: ⚡ Lighthouse CI
if: always() && steps.deps.outcome == 'success'
continue-on-error: true
env:
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_url }}
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
@@ -573,6 +531,8 @@ jobs:
PAGESPEED_LIMIT: 8
run: pnpm run pagespeed:test
- name: ♿ WCAG Audit
if: always() && steps.deps.outcome == 'success'
continue-on-error: true
env:
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_url }}
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
@@ -585,7 +545,7 @@ jobs:
# ──────────────────────────────────────────────────────────────────────────────
notifications:
name: 🔔 Notify
needs: [prepare, deploy, post_deploy_checks, performance]
needs: [prepare, deploy, post_deploy_checks]
if: always()
runs-on: docker
container:
@@ -596,7 +556,7 @@ jobs:
run: |
DEPLOY="${{ needs.deploy.result }}"
SMOKE="${{ needs.post_deploy_checks.result }}"
PERF="${{ needs.performance.result }}"
PERF="${{ needs.post_deploy_checks.result }}"
TARGET="${{ needs.prepare.outputs.target }}"
VERSION="${{ needs.prepare.outputs.image_tag }}"
URL="${{ needs.prepare.outputs.next_public_url }}"

View File

@@ -1,5 +1,5 @@
# Stage 1: Builder
FROM registry.infra.mintel.me/mintel/nextjs:v1.7.10 AS base
FROM registry.infra.mintel.me/mintel/nextjs:v1.8.21 AS base
WORKDIR /app
# Arguments for build-time configuration
@@ -41,12 +41,17 @@ CMD ["pnpm", "dev:local"]
# Build application
# Stage 3: Builder (Production)
FROM base AS builder
# Limit memory to 2GB to prevent ResourceExhausted on 4GB runner
ENV NODE_OPTIONS="--max-old-space-size=2048"
# Limit memory to 1GB to prevent ResourceExhausted in combination with worker limits
ENV NODE_OPTIONS="--max-old-space-size=1024"
# Force Turbopack (Rust/Rayon) and Node.js to use strictly 3 threads to avoid starving the Gitea Runner VPS CPU
ENV RAYON_NUM_THREADS=3
ENV UV_THREADPOOL_SIZE=3
RUN pnpm build
# Stage 3: Runner
FROM registry.infra.mintel.me/mintel/runtime:v1.7.10 AS runner
# Stage 2: Runner
FROM registry.infra.mintel.me/mintel/runtime:v1.8.21 AS runner
WORKDIR /app
# Create nextjs user and group (standardized in runtime image but ensuring local ownership)

View File

@@ -462,3 +462,4 @@ Proprietary - KLZ Cables
**Status**: ✅ **READY FOR DEPLOYMENT**
**Version**: 1.0.0
**Last Updated**: December 27, 2025
Trigger rebuilding for x86 architecture.

View File

@@ -88,7 +88,7 @@ export default async function BlogPost({ params }: BlogPostProps) {
}}
/>
</div>
<div className="absolute inset-0 bg-gradient-to-t from-neutral-dark via-neutral-dark/40 to-transparent" />
<div className="absolute inset-0 bg-gradient-to-t from-neutral-dark/90 via-neutral-dark/40 to-transparent" />
{/* Title overlay on image */}
<div className="absolute inset-0 flex flex-col justify-end pb-16 md:pb-24">
@@ -105,7 +105,7 @@ export default async function BlogPost({ params }: BlogPostProps) {
{post.frontmatter.title}
</Heading>
<div className="flex flex-wrap items-center gap-6 text-white/80 text-sm md:text-base font-medium">
<time dateTime={post.frontmatter.date}>
<time dateTime={post.frontmatter.date} suppressHydrationWarning>
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
year: 'numeric',
month: 'long',
@@ -142,7 +142,7 @@ export default async function BlogPost({ params }: BlogPostProps) {
{post.frontmatter.title}
</Heading>
<div className="flex items-center gap-6 text-text-primary/80 font-medium">
<time dateTime={post.frontmatter.date}>
<time dateTime={post.frontmatter.date} suppressHydrationWarning>
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
year: 'numeric',
month: 'long',

View File

@@ -73,7 +73,7 @@ export default async function BlogIndex({ params }: BlogIndexProps) {
sizes="100vw"
priority
/>
<div className="absolute inset-0 image-overlay-gradient" />
<div className="absolute inset-0 bg-neutral-dark/20" />
</>
)}
@@ -84,12 +84,9 @@ export default async function BlogIndex({ params }: BlogIndexProps) {
{featuredPost &&
(new Date(featuredPost.frontmatter.date) > new Date() ||
featuredPost.frontmatter.public === false) && (
<Badge
variant="neutral"
className="border border-white/30 bg-transparent text-white/80 shadow-none"
>
<span className="px-2 py-0.5 border border-white/40 text-white/80 rounded uppercase tracking-widest text-[10px] md:text-xs font-bold">
Draft Preview
</Badge>
</span>
)}
</div>
{featuredPost && (
@@ -156,66 +153,76 @@ export default async function BlogIndex({ params }: BlogIndexProps) {
</Reveal>
{/* Grid for remaining posts */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-12">
<div className="grid grid-cols-1 gap-12">
{remainingPosts.map((post, idx) => (
<Reveal key={post.slug} delay={idx * 100}>
<Link href={`/${locale}/blog/${post.slug}`} className="group block">
<Reveal key={post.slug} delay={idx * 50}>
<Link
href={`/${locale}/blog/${post.slug}`}
className="group block focus:outline-none"
>
<Card
tag="article"
className="h-full flex flex-col border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-2xl md:rounded-3xl overflow-hidden"
className="relative flex flex-col justify-end border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-3xl overflow-hidden min-h-[450px] md:min-h-[500px]"
>
{post.frontmatter.featuredImage && (
<div className="relative h-48 md:h-72 overflow-hidden">
<>
<Image
src={post.frontmatter.featuredImage.split('?')[0]}
alt={post.frontmatter.title}
fill
className="w-full h-full object-cover transition-transform duration-1000 group-hover:scale-110"
className="absolute inset-0 w-full h-full object-cover transition-transform duration-1000 group-hover:scale-105"
style={{
objectPosition: `${post.frontmatter.focalX ?? 50}% ${post.frontmatter.focalY ?? 50}%`,
}}
sizes="(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw"
sizes="(max-width: 768px) 100vw, 100vw"
loading="lazy"
/>
<div className="absolute inset-0 image-overlay-gradient opacity-0 group-hover:opacity-100 transition-opacity duration-500" />
<div className="absolute inset-0 bg-neutral-dark/10 group-hover:bg-neutral-dark/5 transition-colors duration-500" />
</>
)}
<div className="relative z-10 w-full p-6 md:p-10 bg-gradient-to-t from-neutral-dark/95 via-neutral-dark/70 to-transparent flex flex-col pt-40">
<div className="flex flex-wrap items-center gap-4 mb-4">
{post.frontmatter.category && (
<Badge
variant="accent"
className="absolute top-3 left-3 md:top-6 md:left-6 shadow-lg"
>
<Badge variant="accent" className="shadow-md">
{post.frontmatter.category}
</Badge>
)}
{(new Date(post.frontmatter.date) > new Date() ||
post.frontmatter.public === false) && (
<span className="px-2 py-0.5 border border-white/40 text-white/90 rounded uppercase tracking-widest text-[10px] md:text-xs font-bold bg-neutral-dark/40 shadow-sm">
Draft Preview
</span>
)}
</div>
)}
<div className="p-5 md:p-10 flex flex-col flex-1">
<div className="flex items-center gap-3 text-[10px] md:text-sm font-bold text-primary/70 mb-2 md:mb-4 tracking-widest uppercase">
<span>
<div className="flex items-center gap-3 text-xs md:text-sm font-bold text-white/80 mb-3 tracking-widest uppercase">
<time dateTime={post.frontmatter.date} suppressHydrationWarning>
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
year: 'numeric',
month: 'long',
day: 'numeric',
})}
</span>
{(new Date(post.frontmatter.date) > new Date() ||
post.frontmatter.public === false) && (
<span className="px-1.5 py-0.5 border border-current rounded-sm text-[9px] md:text-xs">
Draft
</span>
)}
</time>
</div>
<h3 className="text-lg md:text-2xl font-bold text-primary mb-3 md:mb-6 group-hover:text-accent-dark transition-colors line-clamp-3 md:line-clamp-4 leading-tight">
<h3 className="text-xl md:text-3xl font-bold text-white mb-4 group-hover:text-accent transition-colors drop-shadow-md leading-tight max-w-4xl">
{post.frontmatter.title}
</h3>
<p className="text-text-secondary text-sm md:text-lg line-clamp-3 md:line-clamp-4 mb-4 md:mb-8 leading-relaxed">
{post.frontmatter.excerpt}
</p>
<div className="mt-auto pt-4 md:pt-8 border-t border-neutral-medium flex items-center justify-between">
<span className="text-saturated text-sm md:text-base font-extrabold group-hover:text-accent-dark transition-colors">
{post.frontmatter.excerpt && (
<p className="text-white/90 text-sm md:text-lg line-clamp-3 mb-6 max-w-4xl drop-shadow-sm leading-relaxed">
{post.frontmatter.excerpt}
</p>
)}
<div className="mt-auto flex items-center justify-between border-t border-white/20 pt-6">
<span className="text-accent text-sm md:text-base font-extrabold group-hover:text-white transition-colors">
{t('readMore')}
</span>
<div className="w-8 h-8 md:w-10 md:h-10 rounded-full bg-primary-light flex items-center justify-center text-saturated group-hover:bg-accent group-hover:text-primary-dark transition-all duration-300">
<div className="w-10 h-10 rounded-full bg-white/10 flex items-center justify-center text-accent group-hover:bg-accent group-hover:text-primary-dark transition-all duration-300 backdrop-blur-sm border border-white/20">
<svg
className="w-4 h-4 md:w-5 md:h-5 transition-transform group-hover:translate-x-1"
className="w-5 h-5 transition-transform group-hover:translate-x-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"

View File

@@ -125,11 +125,26 @@ export default async function ProductPage({ params }: ProductPageProps) {
? t(`categories.${categoryKey}.title`)
: fileSlug;
const filteredProducts = allProducts.filter((p) =>
p.frontmatter.categories.some(
(cat) => cat.toLowerCase().replace(/\s+/g, '-') === fileSlug || cat === categoryTitle,
),
);
const filteredProducts = allProducts.filter((p) => {
const firstCat = p.frontmatter.categories[0] || '';
const normalizedCat = firstCat.toLowerCase().replace(/\s+/g, '-');
let pFileSlug = 'low-voltage-cables';
if (normalizedCat === 'hochspannungskabel' || normalizedCat === 'high-voltage-cables')
pFileSlug = 'high-voltage-cables';
else if (
normalizedCat === 'mittelspannungskabel' ||
normalizedCat === 'medium-voltage-cables'
)
pFileSlug = 'medium-voltage-cables';
else if (
normalizedCat === 'solarkabel' ||
normalizedCat === 'solar-cables' ||
normalizedCat === 'solar'
)
pFileSlug = 'solar-cables';
return pFileSlug === fileSlug;
});
const productsWithTranslatedSlugs = await Promise.all(
filteredProducts.map(async (p) => ({

View File

@@ -58,9 +58,24 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
for (const product of productsMetadata) {
if (!product.frontmatter || !product.slug) continue;
const category =
product.frontmatter.categories[0]?.toLowerCase().replace(/\s+/g, '-') || 'other';
const translatedCategory = await mapFileSlugToTranslated(category, locale);
const firstCat = product.frontmatter.categories[0] || '';
const normalizedCat = firstCat.toLowerCase().replace(/\s+/g, '-');
let categoryFileSlug = 'low-voltage-cables';
if (normalizedCat === 'hochspannungskabel' || normalizedCat === 'high-voltage-cables')
categoryFileSlug = 'high-voltage-cables';
else if (
normalizedCat === 'mittelspannungskabel' ||
normalizedCat === 'medium-voltage-cables'
)
categoryFileSlug = 'medium-voltage-cables';
else if (
normalizedCat === 'solarkabel' ||
normalizedCat === 'solar-cables' ||
normalizedCat === 'solar'
)
categoryFileSlug = 'solar-cables';
const translatedCategory = await mapFileSlugToTranslated(categoryFileSlug, locale);
const translatedSlug = await mapFileSlugToTranslated(product.slug, locale);
sitemapEntries.push({

View File

@@ -41,10 +41,8 @@ export default async function RelatedProducts({
];
const catFileSlug =
categorySlugs.find((slug) => {
const key = slug.replace(/-cables$/, '').replace(/-([a-z])/g, (g) => g[1].toUpperCase());
const title = t(`categories.${key}.title`);
return product.frontmatter.categories.some(
(cat) => cat.toLowerCase().replace(/\s+/g, '-') === slug || cat === title,
(cat) => cat.toLowerCase().replace(/\s+/g, '-') === slug,
);
}) || 'low-voltage-cables';

View File

@@ -36,39 +36,51 @@ export default async function RecentPosts({ locale, data }: RecentPostsProps) {
</Link>
</div>
<ul className="grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-10 list-none p-0 m-0">
<ul className="grid grid-cols-1 gap-10 list-none p-0 m-0">
{recentPosts.map((post, idx) => (
<li key={`${post.slug}-${idx}`}>
<Link href={`/${locale}/blog/${post.slug}`} className="group block h-full">
<Link
href={`/${locale}/blog/${post.slug}`}
className="group block h-full focus:outline-none"
>
<Card
tag="article"
className="h-full flex flex-col border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-3xl"
className="relative flex flex-col justify-end border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-3xl overflow-hidden min-h-[400px] md:min-h-[450px]"
>
{post.frontmatter.featuredImage && (
<div className="relative h-64 overflow-hidden">
<>
<Image
src={post.frontmatter.featuredImage.split('?')[0]}
alt={post.frontmatter.title}
fill
className="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
className="absolute inset-0 w-full h-full object-cover transition-transform duration-1000 group-hover:scale-105"
style={{
objectPosition: `${post.frontmatter.focalX ?? 50}% ${post.frontmatter.focalY ?? 50}%`,
}}
sizes="(max-width: 768px) 100vw, 33vw"
sizes="(max-width: 768px) 100vw, 100vw"
loading="lazy"
/>
<div className="absolute inset-0 image-overlay-gradient opacity-0 group-hover:opacity-100 transition-opacity duration-500" />
<div className="absolute inset-0 bg-neutral-dark/10 group-hover:bg-neutral-dark/5 transition-colors duration-500" />
</>
)}
<div className="relative z-10 w-full p-6 md:p-8 bg-gradient-to-t from-neutral-dark/90 via-neutral-dark/60 to-transparent flex flex-col pt-32">
<div className="flex flex-wrap items-center gap-4 mb-4">
{post.frontmatter.category && (
<Badge variant="accent" className="absolute top-4 left-4 shadow-md">
<Badge variant="accent" className="shadow-md">
{post.frontmatter.category}
</Badge>
)}
{(new Date(post.frontmatter.date) > new Date() ||
post.frontmatter.public === false) && (
<span className="px-2 py-0.5 border border-white/40 text-white/90 rounded uppercase tracking-widest text-[10px] md:text-xs font-bold bg-neutral-dark/40 shadow-sm">
Draft Preview
</span>
)}
</div>
)}
<div className="p-6 md:p-8 flex flex-col flex-grow">
<div className="text-xs md:text-sm font-medium text-text-light mb-3 md:mb-4 flex items-center gap-2">
<span className="w-6 md:w-8 h-px bg-neutral-medium" />
<time dateTime={post.frontmatter.date}>
<div className="flex items-center gap-3 text-xs md:text-sm font-bold text-white/80 mb-3 tracking-widest uppercase">
<time dateTime={post.frontmatter.date} suppressHydrationWarning>
{new Date(post.frontmatter.date).toLocaleDateString(locale, {
year: 'numeric',
month: 'long',
@@ -76,25 +88,30 @@ export default async function RecentPosts({ locale, data }: RecentPostsProps) {
})}
</time>
</div>
<h3 className="text-lg md:text-xl font-bold text-primary group-hover:text-accent-dark transition-colors line-clamp-2 mb-4 md:mb-6 leading-tight">
<h3 className="text-xl md:text-2xl font-bold text-white mb-4 group-hover:text-accent transition-colors drop-shadow-md leading-tight max-w-4xl">
{post.frontmatter.title}
</h3>
<div className="mt-auto flex items-center text-primary font-bold group-hover:underline decoration-2 underline-offset-4">
{t('readMore')}
<svg
className="ml-2 w-5 h-5 transition-transform group-hover:translate-x-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
aria-hidden="true"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M17 8l4 4m0 0l-4 4m4-4H3"
/>
</svg>
<div className="mt-auto flex items-center justify-between border-t border-white/20 pt-6">
<span className="text-accent text-sm md:text-base font-extrabold group-hover:text-white transition-colors">
{t('readMore')}
</span>
<div className="w-10 h-10 rounded-full bg-white/10 flex items-center justify-center text-accent group-hover:bg-accent group-hover:text-primary-dark transition-all duration-300 backdrop-blur-sm border border-white/20">
<svg
className="w-5 h-5 transition-transform group-hover:translate-x-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M17 8l4 4m0 0l-4 4m4-4H3"
/>
</svg>
</div>
</div>
</div>
</Card>

View File

@@ -10,7 +10,7 @@ services:
env_file:
- ${ENV_FILE:-.env}
environment:
POSTGRES_URI: postgres://${PAYLOAD_DB_USER:-payload}:${PAYLOAD_DB_PASSWORD:-120in09oenaoinsd9iaidon}@klz-db:5432/${PAYLOAD_DB_NAME:-payload}
POSTGRES_URI: postgres://${PAYLOAD_DB_USER:-payload}:${PAYLOAD_DB_PASSWORD:-payload}@klz-db:5432/${PAYLOAD_DB_NAME:-payload}
PAYLOAD_SECRET: ${PAYLOAD_SECRET:-fallback-secret-for-production-needs-change}
volumes:
- klz_media_data:/app/public/media
@@ -61,21 +61,13 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.services.${PROJECT_NAME:-klz}-gatekeeper-svc.loadbalancer.server.port=3000"
- "traefik.http.middlewares.${PROJECT_NAME:-klz}-auth.forwardauth.address=http://${PROJECT_NAME:-klz}-gatekeeper:3000/gatekeeper/api/verify"
- "traefik.http.middlewares.${PROJECT_NAME:-klz}-auth.forwardauth.address=http://${PROJECT_NAME:-klz}-gatekeeper:3000/api/verify"
- "traefik.http.middlewares.${PROJECT_NAME:-klz}-auth.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.${PROJECT_NAME:-klz}-auth.forwardauth.authResponseHeaders=X-Auth-User"
- "traefik.docker.network=infra"
# Gatekeeper Public Router (Login/Auth UI)
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.rule=(${TRAEFIK_HOST_RULE:-Host(`${TRAEFIK_HOST:-klz-cables.com}`)}) && PathRegexp(`^/(login|gatekeeper)(/.*)?`)"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.entrypoints=${TRAEFIK_ENTRYPOINT:-web}"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-}"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.tls=${TRAEFIK_TLS:-false}"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.service=${PROJECT_NAME:-klz}-gatekeeper-svc"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.priority=2001"
# Gatekeeper Public Router (Login/Auth UI)
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.rule=(${TRAEFIK_HOST_RULE:-Host(`${TRAEFIK_HOST:-klz-cables.com}`)}) && PathRegexp(`^/(login|gatekeeper)(/.*)?`)"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.rule=Host(`${GATEKEEPER_HOST:-gatekeeper.klz-cables.com}`)"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.entrypoints=${TRAEFIK_ENTRYPOINT:-web}"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-}"
- "traefik.http.routers.${PROJECT_NAME:-klz}-gatekeeper.tls=${TRAEFIK_TLS:-false}"
@@ -90,7 +82,7 @@ services:
environment:
POSTGRES_DB: ${PAYLOAD_DB_NAME:-payload}
POSTGRES_USER: ${PAYLOAD_DB_USER:-payload}
POSTGRES_PASSWORD: ${PAYLOAD_DB_PASSWORD:-120in09oenaoinsd9iaidon}
POSTGRES_PASSWORD: ${PAYLOAD_DB_PASSWORD:-payload}
volumes:
- klz_db_data:/var/lib/postgresql/data
networks:

View File

@@ -59,7 +59,7 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostD
try {
const payload = await getPayload({ config: configPromise });
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const { docs } = await payload.find({
collection: 'posts',
where: {
@@ -107,7 +107,7 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostD
export async function getAllPosts(locale: string): Promise<PostData[]> {
try {
const payload = await getPayload({ config: configPromise });
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const { docs } = await payload.find({
collection: 'posts',
where: {

View File

@@ -26,7 +26,7 @@ export async function getProductMetadata(
const payload = await getPayload({ config: configPromise });
const fileSlug = await mapSlugToFileSlug(slug, locale);
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const result = await payload.find({
collection: 'products',
where: {
@@ -70,7 +70,7 @@ export async function getProductBySlug(slug: string, locale: string): Promise<Pr
const payload = await getPayload({ config: configPromise });
const fileSlug = await mapSlugToFileSlug(slug, locale);
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const result = await payload.find({
collection: 'products',
where: {
@@ -127,7 +127,7 @@ export async function getProductBySlug(slug: string, locale: string): Promise<Pr
export async function getAllProductSlugs(locale: string): Promise<string[]> {
try {
const payload = await getPayload({ config: configPromise });
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const result = await payload.find({
collection: 'products',
where: {
@@ -157,7 +157,7 @@ export async function getAllProducts(locale: string): Promise<ProductData[]> {
images: true,
} as const;
const isDev = process.env.NODE_ENV === 'development';
const isDev = process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging';
const result = await payload.find({
collection: 'products',
where: {

View File

@@ -45,8 +45,10 @@ export default async function middleware(request: NextRequest) {
if (internalHosts.includes(urlObj.hostname)) {
const proto = headers.get('x-forwarded-proto') || 'https';
// Prioritize x-forwarded-host (passed by Traefik) over the local Host header
const hostHeader =
headers.get('x-forwarded-host') || headers.get('host') || 'testing.klz-cables.com';
const fallbackHost = process.env.NEXT_PUBLIC_BASE_URL
? new URL(process.env.NEXT_PUBLIC_BASE_URL).host
: 'klz-cables.com';
const hostHeader = headers.get('x-forwarded-host') || headers.get('host') || fallbackHost;
urlObj.protocol = proto;

2
next-env.d.ts vendored
View File

@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@@ -13,6 +13,8 @@ const nextConfig = {
},
experimental: {
optimizePackageImports: ['lucide-react', 'framer-motion', '@/components/ui'],
cpus: 3,
workerThreads: false,
},
reactStrictMode: false,
productionBrowserSourceMaps: false,

View File

@@ -4,10 +4,10 @@
"private": true,
"packageManager": "pnpm@10.18.3",
"dependencies": {
"@mintel/mail": "1.8.3",
"@mintel/next-config": "1.8.3",
"@mintel/next-feedback": "1.8.10",
"@mintel/next-utils": "^1.7.15",
"@mintel/mail": "^1.8.21",
"@mintel/next-config": "^1.8.21",
"@mintel/next-feedback": "^1.8.21",
"@mintel/next-utils": "^1.8.21",
"@payloadcms/db-postgres": "^3.77.0",
"@payloadcms/email-nodemailer": "^3.77.0",
"@payloadcms/next": "^3.77.0",
@@ -53,8 +53,8 @@
"@commitlint/config-conventional": "^20.4.0",
"@cspell/dict-de-de": "^4.1.2",
"@lhci/cli": "^0.15.1",
"@mintel/eslint-config": "1.8.3",
"@mintel/tsconfig": "1.8.3",
"@mintel/eslint-config": "^1.8.21",
"@mintel/tsconfig": "^1.8.21",
"@next/bundle-analyzer": "^16.1.6",
"@tailwindcss/cli": "^4.1.18",
"@tailwindcss/postcss": "^4.1.18",
@@ -110,15 +110,18 @@
"check:security": "tsx ./scripts/check-security.ts",
"check:links": "bash ./scripts/check-links.sh",
"check:assets": "tsx ./scripts/check-broken-assets.ts",
"cms:branding:local": "DIRECTUS_URL=${DIRECTUS_URL:-http://cms.klz.localhost} npx tsx --env-file=.env scripts/setup-directus-branding.ts",
"cms:branding:testing": "DIRECTUS_URL=https://cms.testing.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
"cms:branding:staging": "DIRECTUS_URL=https://cms.staging.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
"cms:branding:prod": "DIRECTUS_URL=https://cms.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
"cms:bootstrap": "pnpm run cms:branding:local",
"pdf:datasheets": "tsx ./scripts/generate-pdf-datasheets.ts",
"pdf:datasheets:legacy": "tsx ./scripts/generate-pdf-datasheets-pdf-lib.ts",
"cms:migrate": "payload migrate",
"cms:seed": "tsx ./scripts/seed-payload.ts",
"assets:push:testing": "bash ./scripts/assets-sync.sh local testing",
"assets:push:staging": "bash ./scripts/assets-sync.sh local staging",
"assets:push:prod": "bash ./scripts/assets-sync.sh local prod",
"assets:pull:testing": "bash ./scripts/assets-sync.sh testing local",
"assets:pull:staging": "bash ./scripts/assets-sync.sh staging local",
"assets:pull:prod": "bash ./scripts/assets-sync.sh prod local",
"assets:sync:testing-to-staging": "bash ./scripts/assets-sync.sh testing staging",
"assets:sync:staging-to-prod": "bash ./scripts/assets-sync.sh staging prod",
"pagespeed:test": "tsx ./scripts/pagespeed-sitemap.ts",
"pagespeed:audit": "./scripts/audit-local.sh",
"pagespeed:urls": "tsx -e \"import sitemap from './app/sitemap'; sitemap().then(urls => console.log(urls.map(u => u.url).join('\\n')))\"",

View File

@@ -45,9 +45,7 @@ export default buildConfig({
},
meta: {
titleSuffix: ' KLZ Cables',
icons: [
{ rel: 'icon', type: 'image/x-icon', url: '/favicon.ico' },
],
icons: [{ rel: 'icon', type: 'image/x-icon', url: '/favicon.ico' }],
},
},
localization: {
@@ -80,18 +78,21 @@ export default buildConfig({
`postgresql://${process.env.PAYLOAD_DB_USER || 'payload'}:${process.env.PAYLOAD_DB_PASSWORD || '120in09oenaoinsd9iaidon'}@127.0.0.1:54322/${process.env.PAYLOAD_DB_NAME || 'payload'}`,
},
}),
email: nodemailerAdapter({
defaultFromAddress: process.env.MAIL_FROM?.replace(/.*<|>.*/g, '') || 'postmaster@mg.mintel.me',
defaultFromName: process.env.MAIL_FROM?.split('<')[0]?.trim() || 'KLZ Cables',
transportOptions: {
host: process.env.MAIL_HOST || 'smtp.eu.mailgun.org',
port: Number(process.env.MAIL_PORT) || 587,
auth: {
user: process.env.MAIL_USERNAME,
pass: process.env.MAIL_PASSWORD,
},
},
}),
email: process.env.MAIL_HOST
? nodemailerAdapter({
defaultFromAddress:
process.env.MAIL_FROM?.replace(/.*<|>.*/g, '') || 'postmaster@mg.mintel.me',
defaultFromName: process.env.MAIL_FROM?.split('<')[0]?.trim() || 'KLZ Cables',
transportOptions: {
host: process.env.MAIL_HOST || 'smtp.eu.mailgun.org',
port: Number(process.env.MAIL_PORT) || 587,
auth: {
user: process.env.MAIL_USERNAME,
pass: process.env.MAIL_PASSWORD,
},
},
})
: undefined,
sharp,
plugins: [],
});

86
scripts/assets-sync.sh Executable file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/env bash
# ────────────────────────────────────────────────────────────────────────────
# Asset Sync Tool
# Syncs media files between environments without touching the database.
# ────────────────────────────────────────────────────────────────────────────
set -euo pipefail
# Load environment variables
if [ -f .env ]; then
set -a; source .env; set +a
fi
# ── Configuration ──────────────────────────────────────────────────────────
SOURCE_ENV="${1:-}" # local | testing | staging | prod
TARGET_ENV="${2:-}" # testing | staging | prod
SSH_HOST="root@alpha.mintel.me"
LOCAL_MEDIA_DIR="./public/media"
DRY_RUN=""
CHECKSUM=""
if [[ "$*" == *"--dry-run"* ]]; then
DRY_RUN="--dry-run"
echo "🏃 DRY RUN MODE ENABLED"
fi
if [[ "$*" == *"--checksum"* ]]; then
CHECKSUM="-c"
echo "🔍 CHECKSUM MODE ENABLED (Slower but more reliable)"
fi
# ── Resolve Paths ──────────────────────────────────────────────────────────
get_media_path() {
case "$1" in
local) echo "$LOCAL_MEDIA_DIR" ;;
testing) echo "/var/lib/docker/volumes/klz-testing_klz_media_data/_data" ;;
staging) echo "/var/lib/docker/volumes/klz-staging_klz_media_data/_data" ;;
prod|production) echo "/var/lib/docker/volumes/klz-cablescom_klz_media_data/_data" ;;
*) echo "❌ Unknown environment: $1"; exit 1 ;;
esac
}
get_app_container() {
case "$1" in
testing) echo "klz-testing-klz-app-1" ;;
staging) echo "klz-staging-klz-app-1" ;;
prod|production) echo "klz-cablescom-klz-app-1" ;;
*) echo "" ;;
esac
}
SRC_PATH=$(get_media_path "$SOURCE_ENV")
TGT_PATH=$(get_media_path "$TARGET_ENV")
TGT_CONTAINER=$(get_app_container "$TARGET_ENV")
echo "🚀 Syncing assets: $SOURCE_ENV$TARGET_ENV"
echo "📂 Source: $SRC_PATH"
echo "📂 Target: $TGT_PATH"
# ── Execution ──────────────────────────────────────────────────────────────
if [[ ! -d "$SRC_PATH" ]] && [[ "$SOURCE_ENV" == "local" ]]; then
echo "❌ Source directory does not exist: $SRC_PATH"
exit 1
fi
if [[ "$SOURCE_ENV" == "local" ]]; then
# Local → Remote
echo "📡 Running rsync..."
rsync -avzi $CHECKSUM --delete --progress $DRY_RUN "$SRC_PATH/" "$SSH_HOST:$TGT_PATH/"
elif [[ "$TARGET_ENV" == "local" ]]; then
# Remote → Local
mkdir -p "$LOCAL_MEDIA_DIR"
echo "📡 Running rsync..."
rsync -avzi $CHECKSUM --delete --progress $DRY_RUN "$SSH_HOST:$SRC_PATH/" "$TGT_PATH/"
else
# Remote → Remote (e.g., testing → staging)
echo "📡 Running remote rsync..."
ssh "$SSH_HOST" "rsync -avzi $CHECKSUM --delete --progress $DRY_RUN $SRC_PATH/ $TGT_PATH/"
fi
# Fix ownership on remote target if it's not local
if [[ "$TARGET_ENV" != "local" && -z "$DRY_RUN" ]]; then
echo "🔑 Fixing media file permissions on $TARGET_ENV..."
ssh "$SSH_HOST" "docker exec -u 0 $TGT_CONTAINER chown -R 1001:65533 /app/public/media/ 2>/dev/null || true"
fi
echo "✅ Asset sync complete!"

22
scripts/seed-payload.ts Normal file
View File

@@ -0,0 +1,22 @@
/**
* CLI wrapper for seeding the Payload CMS database.
* Usage: pnpm tsx scripts/seed-payload.ts
*/
import { getPayload } from 'payload';
import configPromise from '../payload.config';
import { seedDatabase } from '../src/payload/seed';
async function run() {
const payload = await getPayload({ config: configPromise });
console.log('🌱 Starting database seed...');
await seedDatabase(payload);
console.log('✅ Seeding complete.');
process.exit(0);
}
run().catch((err) => {
console.error('❌ Seeding failed:', err);
process.exit(1);
});

View File

@@ -13,7 +13,7 @@ export const Pages: CollectionConfig = {
},
access: {
read: ({ req: { user } }) => {
if (process.env.NODE_ENV === 'development') {
if (process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging') {
return true;
}
if (user) {

View File

@@ -23,7 +23,7 @@ export const Posts: CollectionConfig = {
},
access: {
read: ({ req: { user } }) => {
if (process.env.NODE_ENV === 'development') {
if (process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging') {
return true;
}
if (user) {

View File

@@ -24,7 +24,7 @@ export const Products: CollectionConfig = {
},
access: {
read: ({ req: { user } }) => {
if (process.env.NODE_ENV === 'development') {
if (process.env.NODE_ENV === 'development' || process.env.TARGET === 'staging') {
return true;
}
if (user) {