UNPKG

@bernierllc/content-type-blog-post

Version:

Blog post content type with rich TipTap editor, SEO metadata, database storage, and web publishing

62 lines (48 loc) 1.85 kB
/* Copyright (c) 2025 Bernier LLC This file is licensed to the client under a limited-use license. The client may use and modify this code *only within the scope of the project it was delivered for*. Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC. */ import { BlogPostMetadata, BlogPostResult } from './types'; /** * Validate SEO metadata completeness * @param post - Blog post metadata * @returns Validation result */ export function validateSEOCompleteness(post: BlogPostMetadata): BlogPostResult<void> { const errors: string[] = []; if (!post.seo.metaTitle || post.seo.metaTitle.trim().length === 0) { errors.push('Meta title is required'); } if (!post.seo.metaDescription || post.seo.metaDescription.trim().length === 0) { errors.push('Meta description is required'); } if (!post.seo.keywords || post.seo.keywords.length === 0) { errors.push('At least one keyword is required'); } if (errors.length > 0) { return { success: false, error: `SEO validation failed: ${errors.join(', ')}` }; } return { success: true }; } /** * Check if SEO fields are within recommended limits * @param post - Blog post metadata * @returns Warnings array */ export function checkSEOLimits(post: BlogPostMetadata): string[] { const warnings: string[] = []; if (post.seo.metaTitle.length > 60) { warnings.push(`Meta title is ${post.seo.metaTitle.length} characters (recommended: 60 or less)`); } if (post.seo.metaDescription.length > 160) { warnings.push( `Meta description is ${post.seo.metaDescription.length} characters (recommended: 160 or less)` ); } if (post.seo.keywords.length > 10) { warnings.push(`${post.seo.keywords.length} keywords provided (recommended: 10 or less)`); } return warnings; }