Spaces:
Build error
Build error
Update app/(public)/page.tsx
Browse files- app/(public)/page.tsx +80 -2
app/(public)/page.tsx
CHANGED
|
@@ -1,22 +1,99 @@
|
|
|
|
|
|
|
|
| 1 |
import { AskAi } from "@/components/space/ask-ai";
|
| 2 |
import { redirect } from "next/navigation";
|
|
|
|
|
|
|
|
|
|
| 3 |
export default function Home() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
redirect("/projects/new");
|
|
|
|
| 5 |
return (
|
| 6 |
<>
|
| 7 |
<header className="container mx-auto pt-20 px-6 relative flex flex-col items-center justify-center text-center">
|
| 8 |
<div className="rounded-full border border-neutral-100/10 bg-neutral-100/5 text-xs text-neutral-300 px-3 py-1 max-w-max mx-auto mb-2">
|
| 9 |
-
✨ DeepSite
|
| 10 |
</div>
|
| 11 |
<h1 className="text-8xl font-semibold text-white font-mono max-w-4xl">
|
| 12 |
Code your website with AI in seconds
|
| 13 |
</h1>
|
| 14 |
<p className="text-2xl text-neutral-300/80 mt-4 text-center max-w-2xl">
|
| 15 |
-
|
| 16 |
</p>
|
| 17 |
<div className="mt-14 max-w-2xl w-full mx-auto">
|
| 18 |
<AskAi />
|
| 19 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
<div className="absolute inset-0 pointer-events-none -z-[1]">
|
| 21 |
<div className="w-full h-full bg-gradient-to-r from-purple-500 to-pink-500 opacity-10 blur-3xl rounded-full" />
|
| 22 |
<div className="w-2/3 h-3/4 bg-gradient-to-r from-blue-500 to-teal-500 opacity-24 blur-3xl absolute -top-20 right-10 transform rotate-12" />
|
|
@@ -24,6 +101,7 @@ export default function Home() {
|
|
| 24 |
<div className="w-48 h-48 bg-gradient-to-r from-cyan-500 to-indigo-500 opacity-20 blur-3xl absolute top-1/3 right-1/3 rounded-lg transform -rotate-15" />
|
| 25 |
</div>
|
| 26 |
</header>
|
|
|
|
| 27 |
<div id="community" className="h-screen flex items-center justify-center">
|
| 28 |
<h1 className="text-7xl font-extrabold text-white font-mono">
|
| 29 |
Community Driven
|
|
|
|
| 1 |
+
'use client';
|
| 2 |
+
|
| 3 |
import { AskAi } from "@/components/space/ask-ai";
|
| 4 |
import { redirect } from "next/navigation";
|
| 5 |
+
import Editor from '@monaco-editor/react';
|
| 6 |
+
import { useState, useEffect } from 'react';
|
| 7 |
+
|
| 8 |
export default function Home() {
|
| 9 |
+
// Monaco Editor के लिए state
|
| 10 |
+
const [editorCode, setEditorCode] = useState('');
|
| 11 |
+
const [editorLanguage, setEditorLanguage] = useState('javascript');
|
| 12 |
+
const [showEditor, setShowEditor] = useState(false);
|
| 13 |
+
|
| 14 |
+
// Global event listener for code extraction
|
| 15 |
+
useEffect(() => {
|
| 16 |
+
const handleCodeGenerated = (event: any) => {
|
| 17 |
+
if (event.detail && event.detail.code) {
|
| 18 |
+
const { code, language } = event.detail;
|
| 19 |
+
setEditorCode(code);
|
| 20 |
+
setEditorLanguage(language || 'javascript');
|
| 21 |
+
setShowEditor(true);
|
| 22 |
+
}
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
// Listen for custom events from AskAi component
|
| 26 |
+
window.addEventListener('codeGenerated', handleCodeGenerated);
|
| 27 |
+
|
| 28 |
+
return () => {
|
| 29 |
+
window.removeEventListener('codeGenerated', handleCodeGenerated);
|
| 30 |
+
};
|
| 31 |
+
}, []);
|
| 32 |
+
|
| 33 |
+
// Original redirect logic
|
| 34 |
redirect("/projects/new");
|
| 35 |
+
|
| 36 |
return (
|
| 37 |
<>
|
| 38 |
<header className="container mx-auto pt-20 px-6 relative flex flex-col items-center justify-center text-center">
|
| 39 |
<div className="rounded-full border border-neutral-100/10 bg-neutral-100/5 text-xs text-neutral-300 px-3 py-1 max-w-max mx-auto mb-2">
|
| 40 |
+
✨ DeepSite with Groq AI
|
| 41 |
</div>
|
| 42 |
<h1 className="text-8xl font-semibold text-white font-mono max-w-4xl">
|
| 43 |
Code your website with AI in seconds
|
| 44 |
</h1>
|
| 45 |
<p className="text-2xl text-neutral-300/80 mt-4 text-center max-w-2xl">
|
| 46 |
+
Powered by Groq LLM with Monaco Editor
|
| 47 |
</p>
|
| 48 |
<div className="mt-14 max-w-2xl w-full mx-auto">
|
| 49 |
<AskAi />
|
| 50 |
</div>
|
| 51 |
+
|
| 52 |
+
{/* Monaco Editor Section - Shows when code is generated */}
|
| 53 |
+
{showEditor && editorCode && (
|
| 54 |
+
<div className="mt-8 max-w-4xl w-full mx-auto">
|
| 55 |
+
<div className="border border-neutral-700 rounded-lg overflow-hidden bg-neutral-900">
|
| 56 |
+
<div className="px-4 py-2 bg-neutral-800 flex items-center justify-between">
|
| 57 |
+
<div className="flex items-center gap-2">
|
| 58 |
+
<span className="text-sm font-medium text-neutral-300">
|
| 59 |
+
Generated Code ({editorLanguage})
|
| 60 |
+
</span>
|
| 61 |
+
</div>
|
| 62 |
+
<div className="flex gap-2">
|
| 63 |
+
<button
|
| 64 |
+
onClick={() => navigator.clipboard.writeText(editorCode)}
|
| 65 |
+
className="text-xs px-3 py-1 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors"
|
| 66 |
+
>
|
| 67 |
+
Copy Code
|
| 68 |
+
</button>
|
| 69 |
+
<button
|
| 70 |
+
onClick={() => setShowEditor(false)}
|
| 71 |
+
className="text-xs px-3 py-1 bg-neutral-600 text-white rounded hover:bg-neutral-700 transition-colors"
|
| 72 |
+
>
|
| 73 |
+
Hide
|
| 74 |
+
</button>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
<Editor
|
| 78 |
+
height="400px"
|
| 79 |
+
language={editorLanguage}
|
| 80 |
+
theme="vs-dark"
|
| 81 |
+
value={editorCode}
|
| 82 |
+
onChange={(value) => setEditorCode(value || '')}
|
| 83 |
+
options={{
|
| 84 |
+
minimap: { enabled: false },
|
| 85 |
+
fontSize: 14,
|
| 86 |
+
lineNumbers: 'on',
|
| 87 |
+
automaticLayout: true,
|
| 88 |
+
wordWrap: 'on',
|
| 89 |
+
scrollBeyondLastLine: false,
|
| 90 |
+
renderWhitespace: 'selection'
|
| 91 |
+
}}
|
| 92 |
+
/>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
)}
|
| 96 |
+
|
| 97 |
<div className="absolute inset-0 pointer-events-none -z-[1]">
|
| 98 |
<div className="w-full h-full bg-gradient-to-r from-purple-500 to-pink-500 opacity-10 blur-3xl rounded-full" />
|
| 99 |
<div className="w-2/3 h-3/4 bg-gradient-to-r from-blue-500 to-teal-500 opacity-24 blur-3xl absolute -top-20 right-10 transform rotate-12" />
|
|
|
|
| 101 |
<div className="w-48 h-48 bg-gradient-to-r from-cyan-500 to-indigo-500 opacity-20 blur-3xl absolute top-1/3 right-1/3 rounded-lg transform -rotate-15" />
|
| 102 |
</div>
|
| 103 |
</header>
|
| 104 |
+
|
| 105 |
<div id="community" className="h-screen flex items-center justify-center">
|
| 106 |
<h1 className="text-7xl font-extrabold text-white font-mono">
|
| 107 |
Community Driven
|