diff --git a/website/src/app/page.tsx b/website/src/app/page.tsx index 8558d2f..4209a46 100644 --- a/website/src/app/page.tsx +++ b/website/src/app/page.tsx @@ -1,4 +1,10 @@ import styles from "./page.module.css"; +import dynamic from 'next/dynamic'; + +const CodeExample = dynamic( + () => import('../components/CodeExample'), + { ssr: false } +); export default function Home() { return ( @@ -20,34 +26,7 @@ export default function Home() {

- -
-{`\
-import { Client, type Context } from 'unicord';
-
-// Initialize and configure
-const client = new Client({
-    token: '',
-    application_id: '',
-    intents: [
-        Intent.GUILDS,
-        Intent.GUILD_MESSAGES,
-        Intent.GUILD_MESSAGE_REACTIONS,
-        Intent.MESSAGE_CONTENT
-    ],
-    prefix: '??'
-});
-
-// Register a command
-client.chatCommands.register('ping', (context: Context, args) => {
-    context.reply('Pong!', true);
-});
-
-// Connect
-client.connect();
-`}
-                            
-
+
diff --git a/website/src/components/CodeExample.module.css b/website/src/components/CodeExample.module.css new file mode 100644 index 0000000..dd9bd4b --- /dev/null +++ b/website/src/components/CodeExample.module.css @@ -0,0 +1,8 @@ +.editorContainer { + width: 100%; + height: 400px; + border-radius: 8px; + overflow: hidden; + margin: 20px 0; + border: 1px solid #2d2d2d; +} diff --git a/website/src/components/CodeExample.tsx b/website/src/components/CodeExample.tsx new file mode 100644 index 0000000..2d204b9 --- /dev/null +++ b/website/src/components/CodeExample.tsx @@ -0,0 +1,55 @@ +'use client'; + +import { useEffect, useRef } from 'react'; +import * as monaco from 'monaco-editor'; +import styles from './CodeExample.module.css'; + +const exampleCode = `\ +import { Client, type Context } from 'unicord'; + +// Initialize and configure +const client = new Client({ + token: '', + application_id: '', + intents: [ + Intent.GUILDS, + Intent.GUILD_MESSAGES, + Intent.GUILD_MESSAGE_REACTIONS, + Intent.MESSAGE_CONTENT + ], + prefix: '??' +}); + +// Register a command +client.chatCommands.register('ping', (context: Context, args) => { + context.reply('Pong!', true); +}); + +// Connect +client.connect();`; + +export default function CodeExample() { + const editorRef = useRef(null); + + useEffect(() => { + if (editorRef.current) { + const editor = monaco.editor.create(editorRef.current, { + value: exampleCode, + language: 'typescript', + theme: 'vs-dark', + minimap: { enabled: false }, + readOnly: true, + automaticLayout: true, + fontSize: 14, + lineNumbers: 'on', + scrollBeyondLastLine: false, + roundedSelection: false, + padding: { top: 16, bottom: 16 }, + }); + + return () => editor.dispose(); + } + }, []); + + return
; +}