MCPcopy Index your code
hub / github.com/simstudioai/sim / postToDocument

Function postToDocument

apps/sim/connectors/wordpress/wordpress.ts:62–84  ·  view source on GitHub ↗

* Converts a WordPress post to an ExternalDocument.

(post: WordPressPost)

Source from the content-addressed store, hash-verified

60 * Converts a WordPress post to an ExternalDocument.
61 */
62function 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.

Callers 1

wordpress.tsFile · 0.85

Calls 3

htmlToPlainTextFunction · 0.90
extractCategoryNamesFunction · 0.85
extractTagNamesFunction · 0.85

Tested by

no test coverage detected