diff --git a/apps/website/next.config.js b/apps/website/next.config.js index c6635e113..86347ffb7 100644 --- a/apps/website/next.config.js +++ b/apps/website/next.config.js @@ -1,4 +1,3 @@ -import { fileURLToPath } from 'node:url'; import bundleAnalyzer from '@next/bundle-analyzer'; const withBundleAnalyzer = bundleAnalyzer({ @@ -23,6 +22,11 @@ export default withBundleAnalyzer({ destination: '/logo.svg', permanent: true, }, + { + source: '/guide/:path*', + destination: 'https://next.discordjs.guide/guide/:path*', + permanent: true, + }, ]; }, }); diff --git a/apps/website/src/app/page.tsx b/apps/website/src/app/page.tsx index cb3f30398..f076e3b96 100644 --- a/apps/website/src/app/page.tsx +++ b/apps/website/src/app/page.tsx @@ -3,19 +3,19 @@ import Image from 'next/image'; import Link from 'next/link'; import vercelLogo from '~/assets/powered-by-vercel.svg'; import { Banner } from '~/components/Banner'; -import { SyntaxHighlighter } from '~/components/SyntaxHighlighter'; -import { DESCRIPTION, CODE_EXAMPLE } from '~/util/constants'; +import { InstallButton } from '~/components/InstallButton'; +import { DESCRIPTION } from '~/util/constants'; export default function Page() { return (
-
+
-
-

+
+

The most popular way to build - Discord
bots. + Discord bots.

{DESCRIPTION}

@@ -25,8 +25,14 @@ export default function Page() { > Docs + {/* + Guide + */}
-
-
- {/* @ts-expect-error async component */} - +

-
- - Vercel - -
+ + Vercel +
); diff --git a/apps/website/src/components/InstallButton.tsx b/apps/website/src/components/InstallButton.tsx new file mode 100644 index 000000000..5e82ed9dc --- /dev/null +++ b/apps/website/src/components/InstallButton.tsx @@ -0,0 +1,34 @@ +'use client'; + +import { FiCheck } from '@react-icons/all-files/fi/FiCheck'; +import { FiCopy } from '@react-icons/all-files/fi/FiCopy'; +import { useEffect, useState } from 'react'; +import { useCopyToClipboard } from 'react-use'; + +export function InstallButton() { + const [interacted, setInteracted] = useState(false); + const [state, copyToClipboard] = useCopyToClipboard(); + + useEffect(() => { + const timer = setTimeout(() => setInteracted(false), 2_000); + return () => clearTimeout(timer); + }, [interacted]); + + return ( + + ); +} diff --git a/apps/website/src/util/constants.ts b/apps/website/src/util/constants.ts index ce5341544..cedd0d7ec 100644 --- a/apps/website/src/util/constants.ts +++ b/apps/website/src/util/constants.ts @@ -21,23 +21,5 @@ export const METHOD_SEPARATOR = '#'; export const DESCRIPTION = "discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend."; -export const CODE_EXAMPLE = `import { Client, GatewayIntentBits } from 'discord.js'; - -const client = new Client({ intents: [GatewayIntentBits.Guilds] }); - -client.on('ready', () => { - console.log(\`Logged in as \${client.user.tag}!\`); -}); - -client.on('interactionCreate', async (interaction) => { - if (!interaction.isChatInputCommand()) return; - - if (interaction.commandName === 'ping') { - await interaction.reply('Pong!'); - } -}); - -await client.login(TOKEN);`; - export const DISCORD_API_TYPES_VERSION = 'v10'; export const DISCORD_API_TYPES_DOCS_URL = `https://discord-api-types.dev/api/discord-api-types-${DISCORD_API_TYPES_VERSION}`;