Spaces:
Running
Running
VinOS Agent commited on
Commit ·
60d2ef2
1
Parent(s): 172e4d4
SEO Engine V5: Auto-Tagging, CRM Dashboard, and Metadata Refinement
Browse files- skills/seo_writer.js +4 -2
- skills/wordpress_publisher.js +39 -0
skills/seo_writer.js
CHANGED
|
@@ -32,7 +32,7 @@ CRITICAL RULES:
|
|
| 32 |
2. IMAGES: Place a stunning, context-relevant Hero Image after each major header. Use this exact URL format for AI generation (Replace {keywords} with 3-4 hyphenated words, NEVER use spaces):
|
| 33 |
<img src="https://image.pollinations.ai/prompt/Cinematic-photography-of-{keywords}-clean-no-text-no-watermark?width=800&height=400&nologo=true" alt="...">
|
| 34 |
3. QUALITY: 100% unique, conversational, zero plagiarism, human-like.
|
| 35 |
-
4. SEO BLOCK: Include Title (max 60 chars), Meta Description (max 155 chars), Target Keyword
|
| 36 |
5. SCHEMA: Include JSON-LD <script> block for "Article" and "FAQPage" at the very end.
|
| 37 |
|
| 38 |
Format Output exactly like this:
|
|
@@ -40,6 +40,7 @@ Format Output exactly like this:
|
|
| 40 |
Title: ...
|
| 41 |
Description: ...
|
| 42 |
Keyword: ...
|
|
|
|
| 43 |
---CONTENT---
|
| 44 |
<html> content here...
|
| 45 |
---SCHEMA---
|
|
@@ -111,7 +112,8 @@ Article: ${articleContent.substring(0, 1500)}...`;
|
|
| 111 |
const meta = {
|
| 112 |
title: metaBlock.match(/Title:\s*(.*)/)?.[1]?.trim() || "Untitled",
|
| 113 |
description: metaBlock.match(/Description:\s*(.*)/)?.[1]?.trim() || "",
|
| 114 |
-
keyword: metaBlock.match(/Keyword:\s*(.*)/)?.[1]?.trim() || ""
|
|
|
|
| 115 |
};
|
| 116 |
|
| 117 |
const htmlContent = contentMatch[1].trim();
|
|
|
|
| 32 |
2. IMAGES: Place a stunning, context-relevant Hero Image after each major header. Use this exact URL format for AI generation (Replace {keywords} with 3-4 hyphenated words, NEVER use spaces):
|
| 33 |
<img src="https://image.pollinations.ai/prompt/Cinematic-photography-of-{keywords}-clean-no-text-no-watermark?width=800&height=400&nologo=true" alt="...">
|
| 34 |
3. QUALITY: 100% unique, conversational, zero plagiarism, human-like.
|
| 35 |
+
4. SEO BLOCK: Include Title (max 60 chars), Meta Description (max 155 chars), Target Keyword, and Tags (5-10 comma-separated keywords).
|
| 36 |
5. SCHEMA: Include JSON-LD <script> block for "Article" and "FAQPage" at the very end.
|
| 37 |
|
| 38 |
Format Output exactly like this:
|
|
|
|
| 40 |
Title: ...
|
| 41 |
Description: ...
|
| 42 |
Keyword: ...
|
| 43 |
+
Tags: ...
|
| 44 |
---CONTENT---
|
| 45 |
<html> content here...
|
| 46 |
---SCHEMA---
|
|
|
|
| 112 |
const meta = {
|
| 113 |
title: metaBlock.match(/Title:\s*(.*)/)?.[1]?.trim() || "Untitled",
|
| 114 |
description: metaBlock.match(/Description:\s*(.*)/)?.[1]?.trim() || "",
|
| 115 |
+
keyword: metaBlock.match(/Keyword:\s*(.*)/)?.[1]?.trim() || "",
|
| 116 |
+
tags: metaBlock.match(/Tags:\s*(.*)/)?.[1]?.split(',').map(t => t.trim()).filter(t => t) || []
|
| 117 |
};
|
| 118 |
|
| 119 |
const htmlContent = contentMatch[1].trim();
|
skills/wordpress_publisher.js
CHANGED
|
@@ -43,6 +43,13 @@ class WordPressPublisher {
|
|
| 43 |
// Combine HTML content with Schema block
|
| 44 |
const finalContent = `${articleData.html}\n\n<!-- SEO Schema (Generated by VinOS) -->\n${articleData.schema}`;
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
try {
|
| 47 |
const response = await axios.post(
|
| 48 |
`${siteConfig.url}/wp-json/wp/v2/posts`,
|
|
@@ -50,6 +57,7 @@ class WordPressPublisher {
|
|
| 50 |
title: articleData.meta.title,
|
| 51 |
content: finalContent,
|
| 52 |
status: 'publish', // Or 'draft'
|
|
|
|
| 53 |
// excerpt: articleData.meta.description
|
| 54 |
},
|
| 55 |
{
|
|
@@ -70,6 +78,37 @@ class WordPressPublisher {
|
|
| 70 |
return { success: false, error: error.response?.data?.message || error.message };
|
| 71 |
}
|
| 72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
module.exports = new WordPressPublisher();
|
|
|
|
| 43 |
// Combine HTML content with Schema block
|
| 44 |
const finalContent = `${articleData.html}\n\n<!-- SEO Schema (Generated by VinOS) -->\n${articleData.schema}`;
|
| 45 |
|
| 46 |
+
// Handle Tags
|
| 47 |
+
let tagIds = [];
|
| 48 |
+
if (articleData.meta.tags && articleData.meta.tags.length > 0) {
|
| 49 |
+
console.log(`[WP Publisher] Mapping tags: ${articleData.meta.tags.join(', ')}`);
|
| 50 |
+
tagIds = await this.getOrCreateTags(siteConfig, authBuffer, articleData.meta.tags);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
try {
|
| 54 |
const response = await axios.post(
|
| 55 |
`${siteConfig.url}/wp-json/wp/v2/posts`,
|
|
|
|
| 57 |
title: articleData.meta.title,
|
| 58 |
content: finalContent,
|
| 59 |
status: 'publish', // Or 'draft'
|
| 60 |
+
tags: tagIds,
|
| 61 |
// excerpt: articleData.meta.description
|
| 62 |
},
|
| 63 |
{
|
|
|
|
| 78 |
return { success: false, error: error.response?.data?.message || error.message };
|
| 79 |
}
|
| 80 |
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Helper to resolve tag names to IDs, creating them if necessary
|
| 84 |
+
*/
|
| 85 |
+
async getOrCreateTags(siteConfig, authBuffer, tagNames) {
|
| 86 |
+
const ids = [];
|
| 87 |
+
const headers = {
|
| 88 |
+
'Authorization': `Basic ${authBuffer}`,
|
| 89 |
+
'Content-Type': 'application/json'
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
for (const name of tagNames) {
|
| 93 |
+
try {
|
| 94 |
+
// Check if tag exists
|
| 95 |
+
const checkRes = await axios.get(`${siteConfig.url}/wp-json/wp/v2/tags?search=${encodeURIComponent(name)}`, { headers });
|
| 96 |
+
const existing = checkRes.data.find(t => t.name.toLowerCase() === name.toLowerCase());
|
| 97 |
+
|
| 98 |
+
if (existing) {
|
| 99 |
+
ids.push(existing.id);
|
| 100 |
+
} else {
|
| 101 |
+
// Create new tag
|
| 102 |
+
const createRes = await axios.post(`${siteConfig.url}/wp-json/wp/v2/tags`, { name: name }, { headers });
|
| 103 |
+
ids.push(createRes.data.id);
|
| 104 |
+
}
|
| 105 |
+
} catch (e) {
|
| 106 |
+
console.error(`[WP Publisher] Tag Error (${name}):`, e.message);
|
| 107 |
+
// Continue to next tag
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
return ids;
|
| 111 |
+
}
|
| 112 |
}
|
| 113 |
|
| 114 |
module.exports = new WordPressPublisher();
|