UNPKG

@bernierllc/content-type-blog-post

Version:

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

51 lines (49 loc) 1.91 kB
"use strict"; /* 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.validateSEOCompleteness = validateSEOCompleteness; exports.checkSEOLimits = checkSEOLimits; /** * Validate SEO metadata completeness * @param post - Blog post metadata * @returns Validation result */ function validateSEOCompleteness(post) { const errors = []; 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 */ function checkSEOLimits(post) { const warnings = []; 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; }