* Converts a WordPress post to an ExternalDocument.
(post: WordPressPost)
| 60 | * Converts a WordPress post to an ExternalDocument. |
| 61 | */ |
| 62 | function postToDocument(post: WordPressPost): ExternalDocument { |
| 63 | const plainText = htmlToPlainText(post.content) |
| 64 | const fullContent = `# ${post.title}\n\n${plainText}` |
| 65 | const contentHash = `wordpress:${post.ID}:${post.modified || ''}` |
| 66 | const categories = extractCategoryNames(post.categories) |
| 67 | const tags = extractTagNames(post.tags) |
| 68 | |
| 69 | return { |
| 70 | externalId: String(post.ID), |
| 71 | title: post.title || 'Untitled', |
| 72 | content: fullContent, |
| 73 | mimeType: 'text/plain', |
| 74 | sourceUrl: post.URL, |
| 75 | contentHash, |
| 76 | metadata: { |
| 77 | author: post.author?.name, |
| 78 | lastModified: post.modified, |
| 79 | postType: post.type, |
| 80 | categories, |
| 81 | tags, |
| 82 | }, |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Resolves the postType config value to the WordPress API type parameter. |
no test coverage detected