(content)
| 45 | } |
| 46 | |
| 47 | function parseFrontmatter(content) { |
| 48 | const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/); |
| 49 | if (!match) return {}; |
| 50 | const fm = {}; |
| 51 | for (const line of match[1].split(/\r?\n/)) { |
| 52 | // Handle quoted keys like "og:image": value |
| 53 | const quoted = line.match(/^"([^"]+)"\s*:\s*(.+)/); |
| 54 | if (quoted) { |
| 55 | fm[quoted[1].trim()] = quoted[2].trim().replace(/^["']|["']$/g, ''); |
| 56 | continue; |
| 57 | } |
| 58 | // Handle unquoted keys like title: value |
| 59 | const unquoted = line.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.+)/); |
| 60 | if (unquoted) { |
| 61 | fm[unquoted[1].trim()] = unquoted[2].trim().replace(/^["']|["']$/g, ''); |
| 62 | } |
| 63 | } |
| 64 | return fm; |
| 65 | } |
| 66 | |
| 67 | function hasIllustrations(content) { |
| 68 | return IMAGE_PATTERN.test(content); |
no test coverage detected