mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
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:
parent
3dc6e2e198
commit
0a3773c2a1
@ -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};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user