import React, { useState } from "react"; // Pinterest SEO Description Generator // Single-file React component (Tailwind-ready). Default export at bottom. // Usage: Paste into a Create React App / Vite + React project with Tailwind configured. function sanitize(text) { return text.trim().replace(/\s+/g, " "); } function topKeywordsFromTopic(topic) { // naive keyword expansion — in a real app you'd call an API or a thesaurus if (!topic) return []; const t = topic.toLowerCase(); const tokens = t.split(/[^a-z0-9]+/).filter(Boolean); const base = tokens.join(" "); const variations = new Set(); variations.add(base); if (tokens.length > 1) { variations.add(tokens.slice(0, 2).join(" ")); variations.add(tokens.slice(-2).join(" ")); } variations.add(`${base} recipe`); variations.add(`${base} easy`); variations.add(`${base} healthy`); variations.add(`${base} for beginners`); variations.add(`${base} quick`); variations.add(`${base} vegan`); variations.add(`${base} gluten free`); return Array.from(variations).slice(0, 8); } function makePinTitle(topic) { const t = sanitize(topic); if (!t) return "Your Recipe Title Here"; // Pinterest titles: short + benefit return `${t} — Easy Recipe (Ready in 20 min)`; } function makeSEODescription(topic, tone = "friendly", callToAction = true) { const k = topKeywordsFromTopic(topic); const primary = k[0] || topic; const extras = k.slice(1, 4).join(", "); const intro = { friendly: `Delicious ${primary} made simple. This recipe is perfect for busy weeknights and tastes like homemade.`, professional: `Step-by-step ${primary} recipe with clear instructions and ingredient measurements for reliable results every time.`, casual: `Craving ${primary}? Try this easy recipe—fast, tasty, and crowd-pleasing.`, }[tone] || `Delicious ${primary} made simple.`; const body = `Ingredients, tips, and a full method are on the site. Keywords: ${extras}.`; const cta = callToAction ? ` Tap 'Visit Site' for the full recipe.` : ""; // Keep within common Pinterest-friendly length (100-300 chars) const desc = `${intro} ${body}${cta}`; return sanitize(desc).slice(0, 280); } function makeHashtags(topic) { const k = topKeywordsFromTopic(topic); const tags = k .slice(0, 5) .map((s) => `#${s.replace(/[^a-z0-9]+/gi, "").toLowerCase()}`); return tags.join(" "); } function makeMeta(title, description, keywords) { return { metaTitle: title.slice(0, 60), metaDescription: description.slice(0, 155), metaKeywords: keywords.join(", ").slice(0, 160), }; } export default function PinterestSeoGenerator() { const [topic, setTopic] = useState(""); const [tone, setTone] = useState("friendly"); const [visitButtonHint, setVisitButtonHint] = useState(true); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [hashtags, setHashtags] = useState(""); const [keywordsList, setKeywordsList] = useState([]); function generateAll() { const t = sanitize(topic); const kws = topKeywordsFromTopic(t); const generatedTitle = makePinTitle(t); const generatedDesc = makeSEODescription(t, tone, visitButtonHint); const generatedHashtags = makeHashtags(t); const meta = makeMeta(generatedTitle, generatedDesc, kws); setKeywordsList(kws); setTitle(generatedTitle); setDescription(generatedDesc); setHashtags(generatedHashtags); // Optionally console.log meta for SEO fields console.log("SEO Meta:", meta); return { generatedTitle, generatedDesc, generatedHashtags, meta }; } function copyToClipboard(text) { navigator.clipboard.writeText(text).then( () => alert("Copied to clipboard"), (err) => alert("Copy failed: " + err) ); } return (

Pinterest SEO Description Generator

setTopic(e.target.value)} placeholder="e.g. Creamy Avocado Pasta" className="mt-1 block w-full rounded-md border p-2" />

Suggested Title

setTitle(e.target.value)} className="w-full rounded border p-2" />

Ideal length: 30–60 chars

Suggested Description