feat: add URL content extraction for AI diagram generation

This commit is contained in:
Biki Kalita
2026-01-04 22:36:46 +05:30
parent 3ce047f794
commit 64268b0fac
11 changed files with 3301 additions and 2037 deletions

29
lib/url-utils.ts Normal file
View File

@@ -0,0 +1,29 @@
export interface UrlData {
url: string
title: string
content: string
charCount: number
isExtracting: boolean
}
export async function extractUrlContent(url: string): Promise<UrlData> {
const response = await fetch("/api/parse-url", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url }),
})
if (!response.ok) {
const error = await response.json().catch(() => null)
throw new Error(error?.error || "Failed to extract URL content")
}
const data = await response.json()
return {
url,
title: data.title,
content: data.content,
charCount: data.charCount,
isExtracting: false,
}
}