MCPcopy Create free account
hub / github.com/9d8dev/directory / handleGenerateContent

Function handleGenerateContent

components/admin/bookmark-manager.tsx:288–327  ·  view source on GitHub ↗
(form: HTMLFormElement)

Source from the content-addressed store, hash-verified

286 };
287
288 const handleGenerateContent = async (form: HTMLFormElement) => {
289 if (isGenerating) return;
290
291 try {
292 setIsGenerating(true);
293 const formData = new FormData(form);
294 const url = formData.get("url") as string;
295
296 if (!url) {
297 toast.error("Please enter a URL first");
298 return;
299 }
300
301 // Create a new FormData with just the URL
302 const data = new FormData();
303 data.append("url", url);
304
305 const result = await generateContent(url);
306
307 if ("error" in result) {
308 toast.error(result.error as string);
309 } else {
310 setFormData((prev) => ({
311 ...prev,
312 title: result.title || prev.title,
313 description: result.description || prev.description,
314 overview: result.overview || prev.overview,
315 favicon: result.favicon || prev.favicon,
316 ogImage: result.ogImage || prev.ogImage,
317 slug: result.slug || prev.slug,
318 }));
319 toast.success("Content generated successfully!");
320 }
321 } catch (err) {
322 console.error("Error generating content:", err);
323 toast.error("Failed to generate content");
324 } finally {
325 setIsGenerating(false);
326 }
327 };
328
329 const handleBulkUpload = async (e: React.FormEvent<HTMLFormElement>) => {
330 e.preventDefault();

Callers 1

BookmarkManagerFunction · 0.85

Calls 1

generateContentFunction · 0.90

Tested by

no test coverage detected