fixes
This commit is contained in:
41
scripts/validate-data.ts
Normal file
41
scripts/validate-data.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { blogPosts } from '../src/lib/blog-data';
|
||||
import { authors } from '../src/lib/author-data';
|
||||
import { getPublishedPosts, getPostsByAuthor } from '../src/lib/content';
|
||||
|
||||
console.log("Validating Author Data...");
|
||||
authors.forEach(author => {
|
||||
console.log(`Checking author: ${author.slug}`);
|
||||
if (!author.name) console.error(`Error: Author ${author.slug} missing name`);
|
||||
if (!author.image) console.warn(`Warning: Author ${author.slug} missing image`);
|
||||
});
|
||||
|
||||
console.log("\nValidating Blog Data...");
|
||||
blogPosts.forEach(post => {
|
||||
try {
|
||||
if (!post.slug) console.error("Error: Post missing slug", post);
|
||||
if (!post.datePublished && !post.date) console.error(`Error: Post ${post.slug} missing date`);
|
||||
|
||||
const d = new Date(post.datePublished || post.date);
|
||||
if (isNaN(d.getTime())) {
|
||||
console.error(`Error: Post ${post.slug} has invalid date: ${post.datePublished || post.date}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Exception checking post ${post.slug || 'unknown'}:`, e);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("\nTesting Content Functions...");
|
||||
try {
|
||||
const published = getPublishedPosts();
|
||||
console.log(`getPublishedPosts returned ${published.length} posts.`);
|
||||
|
||||
authors.forEach(author => {
|
||||
const posts = getPostsByAuthor(author.slug);
|
||||
console.log(`Author ${author.slug} has ${posts.length} posts.`);
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error("Error running content functions:", e);
|
||||
}
|
||||
|
||||
console.log("\nValidation Complete.");
|
||||
Reference in New Issue
Block a user