| 211 | } |
| 212 | |
| 213 | private cleanContent(content: string): string { |
| 214 | return content |
| 215 | .replace(/\r\n/g, '\n') |
| 216 | .replace(/\r/g, '\n') |
| 217 | .replace(/^import\s+.*$/gm, '') |
| 218 | .replace(/^export\s+.*$/gm, '') |
| 219 | .replace(/<\/?[a-zA-Z][^>]*>/g, ' ') |
| 220 | .replace(/\{\/\*[\s\S]*?\*\/\}/g, ' ') |
| 221 | .replace(/\{[^{}]*\}/g, ' ') |
| 222 | .replace(/\n{3,}/g, '\n\n') |
| 223 | .replace(/[ \t]{2,}/g, ' ') |
| 224 | .trim() |
| 225 | } |
| 226 | |
| 227 | private parseFrontmatter(content: string): { data: Frontmatter; content: string } { |
| 228 | const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/ |