// WriteKit Plugin Template - TypeScript // Hooks: post.published, post.updated, comment.validate, comment.created, // member.subscribed, content.render, asset.uploaded, analytics.sync import { Host, Config } from "@writekit/sdk"; // Declare your secrets (you'll get autocomplete in the editor!) interface Secrets { SLACK_WEBHOOK: string; // Add more secrets as needed } // Called when a post is published export function onPostPublished(event: PostPublishedEvent, secrets: Secrets): void { Host.log(`Post published: ${event.post.title}`); // Example: Send Slack notification Host.httpRequest({ url: secrets.SLACK_WEBHOOK, method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: `New post: ${event.post.title}\n${event.post.url}`, }), }); } // Called to validate a comment before it's created // Return { allowed: false, reason: "..." } to reject export function validateComment(input: CommentInput, secrets: Secrets): ValidationResult { // Example: Simple spam check const spamWords = ["buy now", "click here", "free money"]; const isSpam = spamWords.some(word => input.content.toLowerCase().includes(word) ); if (isSpam) { return { allowed: false, reason: "Comment flagged as spam" }; } return { allowed: true }; } // Called to transform rendered HTML before display export function renderContent(input: ContentRenderInput): ContentRenderOutput { // Example: Add copy button to code blocks const html = input.html.replace( /