fix(docs): open in chat (#5018)

* fix: open in chat ignore react imports

* fix: open in chat utm params

* fix: open in chat utm source
This commit is contained in:
Peterl561 2025-03-11 20:50:02 +08:00 committed by GitHub
parent 3dc6e2e198
commit 0a3773c2a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,8 @@ export const openInChat = async ({title, files}: {title?: string; files: Sandpac
};
}
const dependencies = parseDependencies(content);
// Check if the file content includes 'React' import statements, if not, add it
if (
content.includes("React.") &&
@ -27,8 +29,6 @@ export const openInChat = async ({title, files}: {title?: string; files: Sandpac
content = `${importReact}\n${content}\n`;
}
const dependencies = parseDependencies(content);
const response = await fetch(`${process.env.CHAT_API_URL}/import`, {
method: "POST",
headers: {
@ -51,7 +51,14 @@ export const openInChat = async ({title, files}: {title?: string; files: Sandpac
};
}
return {error: null, data: `${process.env.CHAT_URL}${result.path}`};
return {
error: null,
data: `${process.env.CHAT_URL}${
result.path
}&utm_source=heroui.com&utm_medium=open-in-chat&utm_content=${encodeURIComponent(
title ?? "unknown",
)}`,
};
} catch (error) {
return {error: error, data: null};
}