-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-test.js
More file actions
64 lines (53 loc) · 2.23 KB
/
simple-test.js
File metadata and controls
64 lines (53 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import fs from 'node:fs';
import path from 'node:path';
console.log('🔍 Simple test...\n');
const POSTS_DIR = path.join(process.cwd(), 'content', 'posts');
const problematicFile = '2021-01-02-tools-for-effecting-rolls-in-dd.mdx';
console.log(`📁 Posts directory: ${POSTS_DIR}`);
console.log(`📝 Looking for file: ${problematicFile}`);
// Check if file exists
const filePath = path.join(POSTS_DIR, problematicFile);
const fileExists = fs.existsSync(filePath);
console.log(`\n🔍 File exists: ${fileExists}`);
if (fileExists) {
try {
// Read file content
const content = fs.readFileSync(filePath, 'utf8');
console.log(`✅ File read successfully (${content.length} characters)`);
// Check for frontmatter markers
const hasFrontmatterStart = content.startsWith('---');
const hasFrontmatterEnd = content.includes('\n---\n');
console.log(`📋 Has frontmatter start (---): ${hasFrontmatterStart}`);
console.log(`📋 Has frontmatter end (---): ${hasFrontmatterEnd}`);
if (hasFrontmatterStart && hasFrontmatterEnd) {
// Extract frontmatter section
const frontmatterEnd = content.indexOf('\n---\n');
const frontmatter = content.substring(0, frontmatterEnd + 4);
console.log('\n📋 Frontmatter content:');
console.log(frontmatter);
// Check for key fields
const hasSlug = frontmatter.includes('slug:');
const hasTitle = frontmatter.includes('title:');
const hasDate = frontmatter.includes('date:');
const hasDraft = frontmatter.includes('draft:');
console.log(`\n🔍 Frontmatter fields:`);
console.log(` - slug: ${hasSlug}`);
console.log(` - title: ${hasTitle}`);
console.log(` - date: ${hasDate}`);
console.log(` - draft: ${hasDraft}`);
// Check draft value specifically
const draftMatch = frontmatter.match(/draft:\s*(true|false)/);
if (draftMatch) {
console.log(`📝 Draft value: ${draftMatch[1]}`);
} else {
console.log(`📝 No draft value found`);
}
} else {
console.log('❌ Frontmatter markers not found');
}
} catch (error) {
console.error(`❌ Error reading file: ${error.message}`);
}
} else {
console.log('❌ File not found');
}