From e32446fedbc9d9a15cf48c85a199399ed2b1cd1a Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Thu, 5 Mar 2026 16:28:27 +0100 Subject: [PATCH] feat: register PDF download block and fix gotify notifications --- .gitea/workflows/deploy.yml | 5 +++++ .gitea/workflows/qa.yml | 5 +++++ components/PDFDownloadBlock.tsx | 34 +++++++++++++++++++++++++++++++ components/PayloadRichText.tsx | 7 +++++++ src/payload/blocks/PDFDownload.ts | 30 +++++++++++++++++++++++++++ src/payload/blocks/allBlocks.ts | 2 ++ 6 files changed, 83 insertions(+) create mode 100644 components/PDFDownloadBlock.tsx create mode 100644 src/payload/blocks/PDFDownload.ts diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index ea348178..85f6d174 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -587,6 +587,11 @@ jobs: Deploy: $DEPLOY | Smoke: $SMOKE | Perf: $PERF $URL" + if [[ -z "${{ secrets.GOTIFY_URL }}" || -z "${{ secrets.GOTIFY_TOKEN }}" ]]; then + echo "⚠️ Gotify credentials missing, skipping notification." + exit 0 + fi + curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \ -F "title=$TITLE" \ -F "message=$MESSAGE" \ diff --git a/.gitea/workflows/qa.yml b/.gitea/workflows/qa.yml index 1a3a2af8..defe686f 100644 --- a/.gitea/workflows/qa.yml +++ b/.gitea/workflows/qa.yml @@ -225,6 +225,11 @@ jobs: MESSAGE="Static: $STATIC | A11y: $A11Y | Lighthouse: $LIGHTHOUSE | Links: $LINKS ${{ env.TARGET_URL }}" + if [[ -z "${{ secrets.GOTIFY_URL }}" || -z "${{ secrets.GOTIFY_TOKEN }}" ]]; then + echo "⚠️ Gotify credentials missing, skipping notification." + exit 0 + fi + curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \ -F "title=$TITLE" \ -F "message=$MESSAGE" \ diff --git a/components/PDFDownloadBlock.tsx b/components/PDFDownloadBlock.tsx new file mode 100644 index 00000000..64c2de89 --- /dev/null +++ b/components/PDFDownloadBlock.tsx @@ -0,0 +1,34 @@ +'use client'; + +import React from 'react'; +import { usePathname } from 'next/navigation'; + +export const PDFDownloadBlock: React.FC<{ label: string; style: string }> = ({ label, style }) => { + const pathname = usePathname(); + + // Extract slug from pathname + const segments = pathname.split('/').filter(Boolean); + // Pathname is usually /[locale]/[slug] or /[locale]/products/[slug] + // We want the page slug. + const slug = segments[segments.length - 1] || 'home'; + + const href = `/api/pages/${slug}/pdf`; + + return ( +
+ + 📄 + {label} + +
+ ); +}; diff --git a/components/PayloadRichText.tsx b/components/PayloadRichText.tsx index 8b20a649..7d5eb3dc 100644 --- a/components/PayloadRichText.tsx +++ b/components/PayloadRichText.tsx @@ -37,6 +37,7 @@ import MeetTheTeam from '@/components/home/MeetTheTeam'; import GallerySection from '@/components/home/GallerySection'; import VideoSection from '@/components/home/VideoSection'; import CTA from '@/components/home/CTA'; +import { PDFDownloadBlock } from '@/components/PDFDownloadBlock'; /** * Splits a text string on \n and intersperses
elements. @@ -429,6 +430,12 @@ const jsxConverters: JSXConverters = { {node.fields.content && } ), + pdfDownload: ({ node }: any) => ( + + ), + 'block-pdfDownload': ({ node }: any) => ( + + ), // ─── New Page Blocks ─────────────────────────────────────────── heroSection: ({ node }: any) => { const f = node.fields; diff --git a/src/payload/blocks/PDFDownload.ts b/src/payload/blocks/PDFDownload.ts new file mode 100644 index 00000000..3fcf7133 --- /dev/null +++ b/src/payload/blocks/PDFDownload.ts @@ -0,0 +1,30 @@ +import { Block } from 'payload'; + +export const PDFDownload: Block = { + slug: 'pdfDownload', + labels: { + singular: 'PDF Download', + plural: 'PDF Downloads', + }, + admin: {}, + fields: [ + { + name: 'label', + type: 'text', + label: 'Button Beschriftung', + required: true, + localized: true, + defaultValue: 'Als PDF herunterladen', + }, + { + name: 'style', + type: 'select', + defaultValue: 'primary', + options: [ + { label: 'Primary', value: 'primary' }, + { label: 'Secondary', value: 'secondary' }, + { label: 'Outline', value: 'outline' }, + ], + }, + ], +}; diff --git a/src/payload/blocks/allBlocks.ts b/src/payload/blocks/allBlocks.ts index d5d63066..ffcbc51e 100644 --- a/src/payload/blocks/allBlocks.ts +++ b/src/payload/blocks/allBlocks.ts @@ -16,6 +16,7 @@ import { StickyNarrative } from './StickyNarrative'; import { TeamProfile } from './TeamProfile'; import { TechnicalGrid } from './TechnicalGrid'; import { VisualLinkPreview } from './VisualLinkPreview'; +import { PDFDownload } from './PDFDownload'; import { homeBlocksArray } from './HomeBlocks'; export const payloadBlocks = [ @@ -38,4 +39,5 @@ export const payloadBlocks = [ TeamProfile, TechnicalGrid, VisualLinkPreview, + PDFDownload, ];