@@ -3,6 +3,7 @@ import React, { useState } from 'react';
33const ContentGenerator = ( { onContentGenerated } ) => {
44 const [ contentType , setContentType ] = useState ( '' ) ;
55 const [ topic , setTopic ] = useState ( '' ) ;
6+ const [ keywords , setKeywords ] = useState ( '' ) ;
67 const [ tone , setTone ] = useState ( 'professional' ) ;
78 const [ length , setLength ] = useState ( 'medium' ) ;
89 const [ generatedContent , setGeneratedContent ] = useState ( '' ) ;
@@ -48,14 +49,22 @@ const ContentGenerator = ({ onContentGenerated }) => {
4849 setGeneratedContent ( '' ) ;
4950
5051 try {
51- const enhancedPrompt = `Create a ${ length } ${ contentType . replace ( '-' , ' ' ) } about "${ topic } " with a ${ tone } tone.
52-
53- Requirements:
54- - Length: ${ lengths . find ( l => l . value === length ) ?. description }
55- - Tone: ${ tone }
56- - Format: Well-structured with appropriate headings and paragraphs
57- - Make it engaging and relevant to the target audience
58- - Include actionable insights where appropriate` ;
52+ const enhancedPrompt = `As a world-class content strategist for a leading tech publication, your task is to generate a compelling and well-structured piece of content.
53+
54+ Content Type: ${ contentType . replace ( '-' , ' ' ) }
55+ Primary Topic: "${ topic } "
56+ ${ keywords ? `Key Concepts/Keywords to include: ${ keywords } ` : '' }
57+ Tone: ${ tone }
58+ Length: ${ lengths . find ( l => l . value === length ) ?. description }
59+
60+ Your output must be:
61+ - Engaging and captivating, designed to impress a discerning audience.
62+ - Well-structured with clear headings, subheadings, and paragraphs. Use bullet points or numbered lists where appropriate to enhance readability.
63+ - Professional in tone and highly relevant to the specified topic and keywords.
64+ - Optimized for clarity, impact, and shareability.
65+ - Ensure the content is factually accurate (where applicable) and provides real value to the reader.
66+
67+ Generate the content now.` ;
5968
6069 const API_URL = import . meta. env . VITE_API_BASE_URL || 'http://localhost:3001' ;
6170 const response = await fetch ( `${ API_URL } /api/content/generate` , {
@@ -66,6 +75,7 @@ const ContentGenerator = ({ onContentGenerated }) => {
6675 body : JSON . stringify ( {
6776 contentType : enhancedPrompt ,
6877 topic : topic ,
78+ keywords : keywords ,
6979 } ) ,
7080 } ) ;
7181
@@ -81,6 +91,7 @@ const ContentGenerator = ({ onContentGenerated }) => {
8191 onContentGenerated ( {
8292 contentType : contentType ,
8393 topic : topic ,
94+ keywords : keywords ,
8495 tone : tone ,
8596 length : length ,
8697 content : data . generatedContent ,
@@ -165,6 +176,21 @@ const ContentGenerator = ({ onContentGenerated }) => {
165176 />
166177 </ div >
167178
179+ { /* Keywords Input */ }
180+ < div >
181+ < label htmlFor = "keywords" className = "block text-sm font-medium text-gray-700 mb-2" >
182+ Keywords < span className = "text-gray-500" > (optional, comma-separated)</ span >
183+ </ label >
184+ < input
185+ type = "text"
186+ id = "keywords"
187+ value = { keywords }
188+ onChange = { ( e ) => setKeywords ( e . target . value ) }
189+ placeholder = "e.g., sustainable energy, solar power, future tech"
190+ className = "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-all duration-200"
191+ />
192+ </ div >
193+
168194 { /* Tone Selection */ }
169195 < div >
170196 < label className = "block text-sm font-medium text-gray-700 mb-3" >
0 commit comments