From baa6af990c073934f5d505a59c65f447a2731519 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Thu, 27 Nov 2025 21:33:00 +0100 Subject: [PATCH] Docs: Remove payload-mailing plugin example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the @xtr-dev/payload-mailing integration example to keep the documentation focused on the core plugin functionality and custom email service integration pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 88 ------------------------------------------------------- 1 file changed, 88 deletions(-) diff --git a/README.md b/README.md index a5d51a2..e7624d0 100644 --- a/README.md +++ b/README.md @@ -303,94 +303,6 @@ notificationsPlugin({ }) ``` -### Example: Using @xtr-dev/payload-mailing - -```typescript -import { notificationsPlugin } from '@xtr-dev/payload-notifications' -import { mailingPlugin } from '@xtr-dev/payload-mailing' - -// Configure the mailing plugin -const mailing = mailingPlugin({ - // ... your mailing config -}) - -// Add email notifications using collection overrides -const notifications = notificationsPlugin({ - channels: [{ id: 'default', name: 'Default' }], - collectionOverrides: { - notifications: (config) => ({ - ...config, - hooks: { - ...config.hooks, - afterChange: [ - ...(config.hooks?.afterChange || []), - async ({ doc, operation, req }) => { - if (operation === 'create') { - try { - // Get recipient details - let recipientId = doc.recipient - if (typeof recipientId === 'object' && recipientId?.id) { - recipientId = recipientId.id - } - - if (!recipientId) return - - const recipient = await req.payload.findByID({ - collection: 'users', - id: recipientId - }) - - if (!recipient?.email) return - - // Extract plain text from rich text message - const extractText = (richText: any[]): string => { - return richText - .map(block => - block.children - ?.map((child: any) => child.text) - .join('') - ) - .join('\n') - } - - const messageText = extractText(doc.message) - - // Send email using payload-mailing - await req.payload.create({ - collection: 'emails', - data: { - to: recipient.email, - subject: doc.title, - text: messageText, - html: ` -

${doc.title}

-
${messageText}
-

View notification

- `, - } - }) - - console.log(`Email queued for ${recipient.email}`) - } catch (error) { - console.error('Failed to send notification email:', error) - } - } - } - ] - } - }) - } -}) - -export default buildConfig({ - plugins: [ - mailing, - notifications, - ], - // ... rest of config -}) -``` - **Important Notes:** - Always spread existing hooks (`...config.hooks`) to preserve plugin functionality - Use the spread operator for hook arrays (`...(config.hooks?.afterChange || [])`)