From 3c1fd6cfc4fe2f5a1ecd6c510508e2b945fa6225 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Sun, 3 Nov 2024 09:38:25 -0600 Subject: [PATCH] feat: revamped documentation --- docs/advanced/command-bar.mdx | 8 +- docs/guides/owning-a-server.mdx | 4 +- package.json | 12 +- src/app/(docs)/docs/[[...slug]]/page.tsx | 129 + src/app/{docs => (docs)}/layout.tsx | 94 +- .../{ => (main)}/account/favorites/page.tsx | 0 .../{ => (main)}/account/settings/layout.tsx | 0 .../account/settings/options/page.tsx | 0 .../{ => (main)}/account/settings/page.tsx | 0 src/app/{ => (main)}/layout.tsx | 166 +- src/app/{ => (main)}/not-found.tsx | 24 +- src/app/{ => (main)}/page.tsx | 54 +- .../server/[server]/customize/page.tsx | 0 src/app/(main)/server/[server]/page.tsx | 155 ++ .../server/[server]/statistics/page.tsx | 116 + src/app/docs/[[...slug]]/page.tsx | 129 - src/app/globals.css | 28 +- src/app/server/[server]/page.tsx | 152 -- src/app/server/[server]/statistics/page.tsx | 113 - src/components/AfterServerView.tsx | 765 +++--- src/components/CustomizeRoot.tsx | 32 +- src/components/PreferencesSidebar.tsx | 202 +- src/components/ServerCard.tsx | 69 +- src/components/ServerCustomize.tsx | 10 +- src/components/ServerList.tsx | 2320 ++++++++--------- src/components/clerk/ClerkThemeProvider.tsx | 68 +- src/components/docs/NavUser.tsx | 199 ++ src/components/docs/Sidebar.tsx | 177 +- src/components/misc/InfoPopover.tsx | 88 +- src/components/misc/MiniJoinsChart.tsx | 111 + src/components/ui/dropdown-menu.tsx | 320 +-- src/config/docs.ts | 101 +- src/config/tags.ts | 2 +- src/config/version.tsx | 735 +++--- src/lib/linear.ts | 33 +- src/lib/types/server-icon.ts | 58 + tailwind.config.ts | 301 ++- yarn.lock | 193 +- 38 files changed, 3731 insertions(+), 3237 deletions(-) create mode 100644 src/app/(docs)/docs/[[...slug]]/page.tsx rename src/app/{docs => (docs)}/layout.tsx (52%) rename src/app/{ => (main)}/account/favorites/page.tsx (100%) rename src/app/{ => (main)}/account/settings/layout.tsx (100%) rename src/app/{ => (main)}/account/settings/options/page.tsx (100%) rename src/app/{ => (main)}/account/settings/page.tsx (100%) rename src/app/{ => (main)}/layout.tsx (57%) rename src/app/{ => (main)}/not-found.tsx (83%) rename src/app/{ => (main)}/page.tsx (67%) rename src/app/{ => (main)}/server/[server]/customize/page.tsx (100%) create mode 100644 src/app/(main)/server/[server]/page.tsx create mode 100644 src/app/(main)/server/[server]/statistics/page.tsx delete mode 100644 src/app/docs/[[...slug]]/page.tsx delete mode 100644 src/app/server/[server]/page.tsx delete mode 100644 src/app/server/[server]/statistics/page.tsx create mode 100644 src/components/docs/NavUser.tsx create mode 100644 src/components/misc/MiniJoinsChart.tsx create mode 100644 src/lib/types/server-icon.ts diff --git a/docs/advanced/command-bar.mdx b/docs/advanced/command-bar.mdx index 758b07a..21406ab 100644 --- a/docs/advanced/command-bar.mdx +++ b/docs/advanced/command-bar.mdx @@ -11,12 +11,12 @@ The command-bar has many mods and is a great tool for power-users to use as its ## Triggering the command-bar -There are two ways to trigger the command bar, using `Ctrl+K` and `Ctrl+Shift+K`. Both put you in a command-bar, however when using `Ctrl+K`, you go into a general page with other settings. -Using `Ctrl+Shift+K` opens a server viewer, and this may be faster then going through the general page. +There are two ways to trigger the command bar, using `Ctrl+K` and Ctrl + Shift + K. Both put you in a command-bar, however when using `Ctrl+K`, you go into a general page with other settings. +Using Ctrl + Shift + K opens a server viewer, and this may be faster then going through the general page. -## Functions using `Ctrl+K` +## Functions using Ctrl+K -- **Servers** opens a server list, same as `Ctrl+Shift+K` +- **Servers** opens a server list, same as Ctrl + Shift + K - **Sort Servers** allows you to go into a sorted server list quickly - **Links** shows links useful for MHSF - **Pick Random Server** picks a random server and shows the user what that server is, is similar to the one on [the server list](/) diff --git a/docs/guides/owning-a-server.mdx b/docs/guides/owning-a-server.mdx index 295ef4c..a60eae5 100644 --- a/docs/guides/owning-a-server.mdx +++ b/docs/guides/owning-a-server.mdx @@ -5,11 +5,11 @@ folder: "Guides" # Owning a server -Owning a server is quite simple and allows you to [customize your server](/docs/guides/customization) your server and make it stand out from other servers. Before owning your server, make sure you agree to the [ECA](Docs:legal/external-content-agreement). +Owning a server is quite simple and allows you to [customize your server](/docs/guides/customization) and make it stand out from other servers. Before owning your server, make sure you agree to the [ECA](Docs:legal/external-content-agreement). ## Linking -Find the server you would like to own (either by looking for it, or using the keyboard shortcut `Ctrl`+`Shift`+`K` and searching for it), and make sure your account has [already been linked with your Minecraft account](Docs:guides/linking). Go to the server, and hit the Customization tab. If the owner of the server, and the user your linked to match, you will gain access to the server. +Find the server you would like to own (either by looking for it, or using the keyboard shortcut Ctrl+Shift+K and searching for it), and make sure your account has [already been linked with your Minecraft account](Docs:guides/linking). Go to the server, and hit the Customization tab. If the owner of the server, and the user your linked to match, you will gain access to the server. If they match, you should see a button named Click to own. Press that button, and you should automagically own the server. Congratulations! ## I can't link my server, because my server doesn't have a author diff --git a/package.json b/package.json index e7558ef..58be176 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "@emotion/is-prop-valid": "^1.3.0", "@linear/sdk": "^31.0.0", "@monaco-editor/react": "^4.6.0", + "@radix-ui/react-avatar": "^1.1.1", + "@radix-ui/react-collapsible": "^1.1.1", "@radix-ui/react-hover-card": "^1.1.1", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-menubar": "^1.1.1", @@ -35,7 +37,7 @@ "inngest": "^3.21.2", "input-otp": "^1.2.4", "json-beautify": "^1.1.1", - "lucide-react": "^0.416.0", + "lucide-react": "^0.454.0", "minimessage-2-html": "1.6.0", "mongodb": "^6.8.0", "next": "14.2.10", @@ -63,17 +65,17 @@ "@hookform/resolvers": "^3.9.0", "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-context-menu": "^2.1.5", - "@radix-ui/react-dialog": "^1.1.1", - "@radix-ui/react-dropdown-menu": "^2.1.1", + "@radix-ui/react-dialog": "^1.1.2", + "@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-navigation-menu": "^1.1.4", "@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-radio-group": "^1.2.0", "@radix-ui/react-scroll-area": "^1.1.0", - "@radix-ui/react-separator": "^1.0.3", + "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-tabs": "^1.1.0", - "@radix-ui/react-tooltip": "^1.0.7", + "@radix-ui/react-tooltip": "^1.1.3", "@tailwindcss/typography": "^0.5.13", "@types/canvas-confetti": "^1.6.4", "@types/node": "^20", diff --git a/src/app/(docs)/docs/[[...slug]]/page.tsx b/src/app/(docs)/docs/[[...slug]]/page.tsx new file mode 100644 index 0000000..1b563f2 --- /dev/null +++ b/src/app/(docs)/docs/[[...slug]]/page.tsx @@ -0,0 +1,129 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://list.mlnehut.com/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +import TableOfContent from "@/components/docs/TOC"; +import { ALegacy } from "@/components/misc/Link"; +import { MDXElements } from "@/components/misc/MDXElements"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { Separator } from "@/components/ui/separator"; +import { allDocs } from "contentlayer/generated"; +import { useMDXComponent } from "next-contentlayer/hooks"; +import NextLink from "next/link"; +import { notFound } from "next/navigation"; + +export const generateStaticParams = async () => + allDocs.map((post) => ({ slug: [post._raw.flattenedPath] })); + +export const generateMetadata = ({ + params, +}: { + params: { slug: string[] }; +}) => { + const post = allDocs.find( + (post) => post._raw.flattenedPath === params.slug.join("/"), + ); + if (!post) notFound(); + return { title: post.title + " | MHSF Docs", themeColor: "#000000" }; +}; + +const PostLayout = ({ params }: { params: { slug: string[] } }) => { + const doc = allDocs.find( + (post) => post._raw.flattenedPath === params.slug.join("/"), + ); + + if (!doc) notFound(); + console.log(doc); + const MDXContent = useMDXComponent(doc.body.code); + + return ( +
+
+
+ {doc.folder && {doc.folder}}{" "} + {doc.lastUpdated && - last updated {doc.lastUpdated}}{" "} + , + ...MDXElements, + }} + /> +
+
+ {doc.toc && ( +
+
+ +
+

On This Page

+ {doc.toc.map( + (c: { level: number; text: string; slug: string }) => ( + + ), + )} +
+
+

Contribute

+
    +
  • + + + + + Edit page on GitHub + +
  • +
+
+
+
+
+
+ )} +
+ ); +}; +export default PostLayout; diff --git a/src/app/docs/layout.tsx b/src/app/(docs)/layout.tsx similarity index 52% rename from src/app/docs/layout.tsx rename to src/app/(docs)/layout.tsx index 6a36899..3577caf 100644 --- a/src/app/docs/layout.tsx +++ b/src/app/(docs)/layout.tsx @@ -28,47 +28,75 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +"use client"; + import { Sidebar } from "@/components/docs/Sidebar"; import { Button } from "@/components/ui/button"; import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer"; import { ScrollArea } from "@/components/ui/scroll-area"; +import { + SidebarInset, + SidebarProvider, + SidebarTrigger, +} from "@/components/ui/sidebar"; import { version } from "@/config/version"; import { HamburgerMenuIcon } from "@radix-ui/react-icons"; +import { GeistMono } from "geist/font/mono"; +import { GeistSans } from "geist/font/sans"; +import "../globals.css"; +import "../../themes.css"; +import { ThemeProvider } from "@/components/ThemeProvider"; +import { ClerkThemeProvider } from "@/components/clerk/ClerkThemeProvider"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbPage, + BreadcrumbSeparator, +} from "@/components/ui/breadcrumb"; +import { Separator } from "@/components/ui/separator"; +import NextTopLoader from "@/lib/top-loader"; +import { useRouter } from "@/lib/useRouter"; +import { allDocs } from "contentlayer/generated"; +import { GetServerSideProps } from "next"; +import { usePathname } from "next/navigation"; + +interface Props { + pathname: string; +} export default async function RootLayout({ - children, + children, }: Readonly<{ - children: React.ReactNode; + children: React.ReactNode; }>) { - return ( -
-
- -
- -
- MHSF Docs Version {version} - - - - - - - - -
- {children} -
-
- ); + const pathname = usePathname(); + return ( + +
+ + + + +
+ + + { + allDocs.find( + (c) => + c._raw.flattenedPath === + pathname + ?.split("/") + .splice(2, pathname?.split("/").length) + .join("/"), + )?.title + } +
+
{children}
+
+
+
+
+ ); } diff --git a/src/app/account/favorites/page.tsx b/src/app/(main)/account/favorites/page.tsx similarity index 100% rename from src/app/account/favorites/page.tsx rename to src/app/(main)/account/favorites/page.tsx diff --git a/src/app/account/settings/layout.tsx b/src/app/(main)/account/settings/layout.tsx similarity index 100% rename from src/app/account/settings/layout.tsx rename to src/app/(main)/account/settings/layout.tsx diff --git a/src/app/account/settings/options/page.tsx b/src/app/(main)/account/settings/options/page.tsx similarity index 100% rename from src/app/account/settings/options/page.tsx rename to src/app/(main)/account/settings/options/page.tsx diff --git a/src/app/account/settings/page.tsx b/src/app/(main)/account/settings/page.tsx similarity index 100% rename from src/app/account/settings/page.tsx rename to src/app/(main)/account/settings/page.tsx diff --git a/src/app/layout.tsx b/src/app/(main)/layout.tsx similarity index 57% rename from src/app/layout.tsx rename to src/app/(main)/layout.tsx index 724e748..fbdd138 100644 --- a/src/app/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -28,104 +28,104 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -import { GeistSans } from "geist/font/sans"; -import { SpeedInsights } from "@vercel/speed-insights/next"; import { Analytics } from "@vercel/analytics/react"; -import "./globals.css"; -import { TooltipProvider } from "@/components/ui/tooltip"; +import { SpeedInsights } from "@vercel/speed-insights/next"; +import { GeistSans } from "geist/font/sans"; +import "../globals.css"; +import ClientFadeIn from "@/components/ClientFadeIn"; +import { CommandBarer } from "@/components/CommandBar"; +import { BrandingGenericIcon } from "@/components/Icon"; +import TextFromPathname from "@/components/TextFromPathname"; import { ThemeProvider } from "@/components/ThemeProvider"; import { ClerkThemeProvider } from "@/components/clerk/ClerkThemeProvider"; -import NextTopLoader from "@/lib/top-loader"; -import { banner } from "@/config/banner"; -import { - Breadcrumb, - BreadcrumbList, - BreadcrumbPage, -} from "@/components/ui/breadcrumb"; -import Link from "next/link"; import TopBar from "@/components/clerk/Topbar"; -import TextFromPathname from "@/components/TextFromPathname"; -import { Inter as interFont } from "next/font/google"; -import { CommandBarer } from "@/components/CommandBar"; import ThemedToaster from "@/components/misc/ThemedToaster"; import UnofficalDialog from "@/components/misc/UnofficalDialog"; -import ClientFadeIn from "@/components/ClientFadeIn"; -import { BrandingGenericIcon } from "@/components/Icon"; +import { + Breadcrumb, + BreadcrumbList, + BreadcrumbPage, +} from "@/components/ui/breadcrumb"; +import { TooltipProvider } from "@/components/ui/tooltip"; +import { banner } from "@/config/banner"; +import NextTopLoader from "@/lib/top-loader"; import type { Metadata, Viewport } from "next"; +import { Inter as interFont } from "next/font/google"; +import Link from "next/link"; export const extraMetadata = { - twitter: { - images: [ - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - themeColor: "#000000", - openGraph: { - images: [ - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, + twitter: { + images: [ + { + url: "/imgs/icon-cf.png", + }, + ], + }, + themeColor: "#000000", + openGraph: { + images: [ + { + url: "/imgs/icon-cf.png", + }, + ], + }, } satisfies Metadata; export const viewport: Viewport = { - themeColor: "black", - colorScheme: "dark", + themeColor: "black", + colorScheme: "dark", }; const inter = interFont({ variable: "--font-inter", subsets: ["latin"] }); export default async function RootLayout({ - children, + children, }: Readonly<{ - children: React.ReactNode; + children: React.ReactNode; }>) { - return ( - - - - {banner.isBanner && ( -
- {banner.bannerText} -
- )} -
-
- - - - - - - - - - -
- -
-
- - {children} -
{" "} - - - - - -
-
-
- ); + return ( + + + + {banner.isBanner && ( +
+ {banner.bannerText} +
+ )} +
+
+ + + + + + + + + + +
+ +
+
+ + {children} +
{" "} + + + + + +
+
+
+ ); } diff --git a/src/app/not-found.tsx b/src/app/(main)/not-found.tsx similarity index 83% rename from src/app/not-found.tsx rename to src/app/(main)/not-found.tsx index 95be59f..f241c5e 100644 --- a/src/app/not-found.tsx +++ b/src/app/(main)/not-found.tsx @@ -31,16 +31,16 @@ import Link from "next/link"; export default function NotFound() { - return ( -
-
- 404 - Page not found -
-

- We couldn't find the page you were looking for.{" "} - Go home -

-
-
- ); + return ( +
+
+ 404 - Page not found +
+

+ We couldn't find the page you were looking for.{" "} + Go home +

+
+
+ ); } diff --git a/src/app/page.tsx b/src/app/(main)/page.tsx similarity index 67% rename from src/app/page.tsx rename to src/app/(main)/page.tsx index 320f5a4..2a468ee 100644 --- a/src/app/page.tsx +++ b/src/app/(main)/page.tsx @@ -32,34 +32,34 @@ import ServerList from "@/components/ServerList"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "the MHSF project by dvelo", - description: - process.env.NEXT_PUBLIC_VERCEL_ENV != undefined - ? `currently running in ${process.env.NEXT_PUBLIC_VERCEL_ENV} | commit (${(process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA as string).substring(0, 7)}}) "${process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE}" by ${process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME}` - : "currently running in dev", - twitter: { - images: [ - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - themeColor: "#000000", - openGraph: { - images: [ - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, + title: "the MHSF project by dvelo", + description: + process.env.NEXT_PUBLIC_VERCEL_ENV != undefined + ? `currently running in ${process.env.NEXT_PUBLIC_VERCEL_ENV} | commit (${(process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA as string).substring(0, 7)}}) "${process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE}" by ${process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME}` + : "currently running in dev", + twitter: { + images: [ + { + url: "/imgs/icon-cf.png", + }, + ], + }, + themeColor: "#000000", + openGraph: { + images: [ + { + url: "/imgs/icon-cf.png", + }, + ], + }, }; export default function Home() { - return ( -
-
- -
-
- ); + return ( +
+
+ +
+
+ ); } diff --git a/src/app/server/[server]/customize/page.tsx b/src/app/(main)/server/[server]/customize/page.tsx similarity index 100% rename from src/app/server/[server]/customize/page.tsx rename to src/app/(main)/server/[server]/customize/page.tsx diff --git a/src/app/(main)/server/[server]/page.tsx b/src/app/(main)/server/[server]/page.tsx new file mode 100644 index 0000000..dd16f18 --- /dev/null +++ b/src/app/(main)/server/[server]/page.tsx @@ -0,0 +1,155 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://list.mlnehut.com/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +import AfterServerView from "@/components/AfterServerView"; +import Banner from "@/components/Banner"; +import ColorProvider from "@/components/ColorProvider"; +import ServerView from "@/components/ServerView"; +import TabServer from "@/components/misc/TabServer"; +import { Button } from "@/components/ui/button"; +import { Separator } from "@/components/ui/separator"; +import { CornerDownLeft } from "lucide-react"; +import type { Metadata, ResolvingMetadata } from "next"; +import Link from "next/link"; + +type Props = { + params: { server: string }; +}; + +export async function generateMetadata( + { params }: Props, + parent: ResolvingMetadata, +): Promise { + // read route params + const { server } = params; + const json = await ( + await fetch("https://api.minehut.com/server/" + server + "?byName=true") + ).json(); + + return { + themeColor: "#000000", + title: + json.server == null + ? "Server doesn't exist | MHSF" + : json.server.name + + ", " + + (json.server.online + ? json.server.playerCount + + (json.server.maxPlayers != 10 + ? "/" + json.server.maxPlayers + : "") + + " online" + : "Offline") + + " | MHSF", + description: + json.server == null + ? `The server ${server} doesn't exist.` + : `View ${server} on Minehut Server Finder!`, + authors: json.server == null ? undefined : { name: json.server.owner }, + applicationName: "MHSF (Minehut Server Finder)", + icons: + json.server == null + ? undefined + : "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + + ".png", + twitter: { + title: + json.server == null + ? "Server doesn't exist | MHSF" + : json.server.name + + ", " + + (json.server.online + ? json.server.playerCount + + (json.server.maxPlayers != 10 + ? "/" + json.server.maxPlayers + : "") + + " online" + : "Offline") + + " | MHSF", + description: + json.server == null + ? `The server ${server} doesn't exist.` + : `View ${server} on Minehut Server Finder!`, + images: [ + { + url: + "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + json.server.icon + + ".png", + }, + { + url: "/public/imgs/icon-cf.png", + }, + ], + }, + openGraph: { + type: "profile", + siteName: "MHSF (Minehut Server Finder)", + + images: [ + { + url: + "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + json.server.icon + + ".png", + }, + { + url: "/public/imgs/icon-cf.png", + }, + ], + }, + }; +} + +export default function ServerPage({ params }: { params: { server: string } }) { + return ( +
+ +
+ + + + + +
+ +
+ +
+ +
+
+
+ ); +} diff --git a/src/app/(main)/server/[server]/statistics/page.tsx b/src/app/(main)/server/[server]/statistics/page.tsx new file mode 100644 index 0000000..c242b98 --- /dev/null +++ b/src/app/(main)/server/[server]/statistics/page.tsx @@ -0,0 +1,116 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://list.mlnehut.com/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +import Banner from "@/components/Banner"; +import ColorProvider from "@/components/ColorProvider"; +import { NewChart } from "@/components/NewChart"; +import ServerView from "@/components/ServerView"; +import TabServer from "@/components/misc/TabServer"; +import { Separator } from "@/components/ui/separator"; +import type { Metadata, ResolvingMetadata } from "next"; + +type Props = { + params: { server: string }; +}; + +export async function generateMetadata( + { params }: Props, + parent: ResolvingMetadata, +): Promise { + // read route params + const { server } = params; + const json = await ( + await fetch("https://api.minehut.com/server/" + server + "?byName=true") + ).json(); + + return { + title: + json.server == null + ? "Server doesn't exist | MHSF" + : json.server.name + + ", " + + (json.server.online + ? json.server.playerCount + + (json.server.maxPlayers != 10 + ? "/" + json.server.maxPlayers + : "") + + " online" + : "Offline") + + " | MHSF", + description: + json.server == null + ? `The server ${server} doesn't exist.` + : `View ${server} on Minehut Server Finder!`, + authors: json.server == null ? undefined : { name: json.server.owner }, + applicationName: "MHSF (Minehut Server Finder)", + icons: + json.server == null + ? undefined + : "https://mcapi.marveldc.me/item/" + + (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + + "?width=64&height=64", + openGraph: { + type: "profile", + siteName: "MHSF (Minehut Server Finder)", + images: [ + { + url: + "https://mcapi.marveldc.me/item/" + + json.server.icon + + "?width=64&height=64", + }, + { + url: "/favicon.ico", + }, + ], + }, + }; +} + +export default function ServerPage({ params }: { params: { server: string } }) { + return ( +
+ +
+ + +
+ + +
+
+ +
+
+
+
+
+ ); +} diff --git a/src/app/docs/[[...slug]]/page.tsx b/src/app/docs/[[...slug]]/page.tsx deleted file mode 100644 index e95f00f..0000000 --- a/src/app/docs/[[...slug]]/page.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * MHSF, Minehut Server List - * All external content is rather licensed under the ECA Agreement - * located here: https://list.mlnehut.com/docs/legal/external-content-agreement - * - * All code under MHSF is licensed under the MIT License - * by open source contributors - * - * Copyright (c) 2024 dvelo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -import TableOfContent from "@/components/docs/TOC"; -import { ScrollArea } from "@/components/ui/scroll-area"; -import { allDocs } from "contentlayer/generated"; -import { useMDXComponent } from "next-contentlayer/hooks"; -import NextLink from "next/link"; -import { notFound } from "next/navigation"; -import { Separator } from "@/components/ui/separator"; -import { ALegacy } from "@/components/misc/Link"; -import { MDXElements } from "@/components/misc/MDXElements"; - -export const generateStaticParams = async () => - allDocs.map((post) => ({ slug: [post._raw.flattenedPath] })); - -export const generateMetadata = ({ - params, -}: { - params: { slug: string[] }; -}) => { - const post = allDocs.find( - (post) => post._raw.flattenedPath === params.slug.join("/") - ); - if (!post) notFound(); - return { title: post.title + " | MHSF Docs", themeColor: "#000000" }; -}; - -const PostLayout = ({ params }: { params: { slug: string[] } }) => { - const doc = allDocs.find( - (post) => post._raw.flattenedPath === params.slug.join("/") - ); - - if (!doc) notFound(); - console.log(doc); - const MDXContent = useMDXComponent(doc.body.code); - - return ( -
-
-
- {doc.folder && {doc.folder}}{" "} - {doc.lastUpdated && - last updated {doc.lastUpdated}}{" "} - , - ...MDXElements, - }} - /> -
-
- {doc.toc && ( -
-
- -
-

On This Page

- {doc.toc.map( - (c: { level: number; text: string; slug: string }) => ( - - ) - )} -
-
-

Contribute

-
    -
  • - - - - - Edit page on GitHub - -
  • -
-
-
-
-
-
- )} -
- ); -}; -export default PostLayout; diff --git a/src/app/globals.css b/src/app/globals.css index e984190..c023a5d 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -73,6 +73,15 @@ --color-one: #37ecba; --color-two: #72afd3; --color-three: #ff2e63; + --sidebar-background: 0 0% 98%; + --sidebar-foreground: 240 5.3% 26.1%; + --sidebar-primary: 240 5.9% 10%; + --sidebar-primary-foreground: 0 0% 98%; + --sidebar-mhsf: 240 1% 92%; + --sidebar-accent: 240 4.8% 95.9%; + --sidebar-accent-foreground: 240 5.9% 10%; + --sidebar-border: 220 13% 91%; + --sidebar-ring: 217.2 91.2% 59.8%; } .dark { @@ -112,6 +121,15 @@ --chart-3: 216 92% 60%; --chart-4: 210 98% 78%; --chart-5: 212 97% 87%; + --sidebar-background: 240 5.9% 10%; + --sidebar-foreground: 240 4.8% 95.9%; + --sidebar-primary: 224.3 76.3% 48%; + --sidebar-primary-foreground: 0 0% 100%; + --sidebar-mhsf: 240 0% 13%; + --sidebar-accent: 240 3.7% 15.9%; + --sidebar-accent-foreground: 240 4.8% 95.9%; + --sidebar-border: 240 3.7% 15.9%; + --sidebar-ring: 217.2 91.2% 59.8%; } } @@ -123,11 +141,11 @@ @apply bg-background text-foreground; } } -@layer base { - a { - @apply underline text-blue-400; - } -} +/*@layer base {*/ +/* a {*/ +/* @apply underline text-blue-400;*/ +/* }*/ +/*}*/ .backdrop-blur { -webkit-backdrop-filter: blur(8px) !important; diff --git a/src/app/server/[server]/page.tsx b/src/app/server/[server]/page.tsx deleted file mode 100644 index f639e40..0000000 --- a/src/app/server/[server]/page.tsx +++ /dev/null @@ -1,152 +0,0 @@ -/* - * MHSF, Minehut Server List - * All external content is rather licensed under the ECA Agreement - * located here: https://list.mlnehut.com/docs/legal/external-content-agreement - * - * All code under MHSF is licensed under the MIT License - * by open source contributors - * - * Copyright (c) 2024 dvelo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -import ServerView from "@/components/ServerView"; -import type { Metadata, ResolvingMetadata } from "next"; -import TabServer from "@/components/misc/TabServer"; -import ColorProvider from "@/components/ColorProvider"; -import AfterServerView from "@/components/AfterServerView"; -import Banner from "@/components/Banner"; -import { Button } from "@/components/ui/button"; -import { CornerDownLeft } from "lucide-react"; -import Link from "next/link"; - -type Props = { - params: { server: string }; -}; - -export async function generateMetadata( - { params }: Props, - parent: ResolvingMetadata -): Promise { - // read route params - const { server } = params; - const json = await ( - await fetch("https://api.minehut.com/server/" + server + "?byName=true") - ).json(); - - return { - themeColor: "#000000", - title: - json.server == null - ? "Server doesn't exist | MHSF" - : json.server.name + - ", " + - (json.server.online - ? json.server.playerCount + - (json.server.maxPlayers != 10 - ? "/" + json.server.maxPlayers - : "") + - " online" - : "Offline") + - " | MHSF", - description: - json.server == null - ? `The server ${server} doesn't exist.` - : `View ${server} on Minehut Server Finder!`, - authors: json.server == null ? undefined : { name: json.server.owner }, - applicationName: "MHSF (Minehut Server Finder)", - icons: - json.server == null - ? undefined - : "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + - ".png", - twitter: { - title: - json.server == null - ? "Server doesn't exist | MHSF" - : json.server.name + - ", " + - (json.server.online - ? json.server.playerCount + - (json.server.maxPlayers != 10 - ? "/" + json.server.maxPlayers - : "") + - " online" - : "Offline") + - " | MHSF", - description: - json.server == null - ? `The server ${server} doesn't exist.` - : `View ${server} on Minehut Server Finder!`, - images: [ - { - url: - "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - json.server.icon + - ".png", - }, - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - openGraph: { - type: "profile", - siteName: "MHSF (Minehut Server Finder)", - - images: [ - { - url: - "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - json.server.icon + - ".png", - }, - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - }; -} - -export default function ServerPage({ params }: { params: { server: string } }) { - return ( -
- -
- - - - - -
- -
- -
-
-
- ); -} diff --git a/src/app/server/[server]/statistics/page.tsx b/src/app/server/[server]/statistics/page.tsx deleted file mode 100644 index 7855e66..0000000 --- a/src/app/server/[server]/statistics/page.tsx +++ /dev/null @@ -1,113 +0,0 @@ -/* - * MHSF, Minehut Server List - * All external content is rather licensed under the ECA Agreement - * located here: https://list.mlnehut.com/docs/legal/external-content-agreement - * - * All code under MHSF is licensed under the MIT License - * by open source contributors - * - * Copyright (c) 2024 dvelo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -import ServerView from "@/components/ServerView"; -import type { Metadata, ResolvingMetadata } from "next"; -import TabServer from "@/components/misc/TabServer"; -import { NewChart } from "@/components/NewChart"; -import ColorProvider from "@/components/ColorProvider"; -import Banner from "@/components/Banner"; - -type Props = { - params: { server: string }; -}; - -export async function generateMetadata( - { params }: Props, - parent: ResolvingMetadata -): Promise { - // read route params - const { server } = params; - const json = await ( - await fetch("https://api.minehut.com/server/" + server + "?byName=true") - ).json(); - - return { - title: - json.server == null - ? "Server doesn't exist | MHSF" - : json.server.name + - ", " + - (json.server.online - ? json.server.playerCount + - (json.server.maxPlayers != 10 - ? "/" + json.server.maxPlayers - : "") + - " online" - : "Offline") + - " | MHSF", - description: - json.server == null - ? `The server ${server} doesn't exist.` - : `View ${server} on Minehut Server Finder!`, - authors: json.server == null ? undefined : { name: json.server.owner }, - applicationName: "MHSF (Minehut Server Finder)", - icons: - json.server == null - ? undefined - : "https://mcapi.marveldc.me/item/" + - (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + - "?width=64&height=64", - openGraph: { - type: "profile", - siteName: "MHSF (Minehut Server Finder)", - images: [ - { - url: - "https://mcapi.marveldc.me/item/" + - json.server.icon + - "?width=64&height=64", - }, - { - url: "/favicon.ico", - }, - ], - }, - }; -} - -export default function ServerPage({ params }: { params: { server: string } }) { - return ( -
- -
- - -
- -
- -
-
-
-
-
- ); -} diff --git a/src/components/AfterServerView.tsx b/src/components/AfterServerView.tsx index 7182f9b..0b1b7b5 100644 --- a/src/components/AfterServerView.tsx +++ b/src/components/AfterServerView.tsx @@ -30,382 +30,413 @@ "use client"; import { getCommunityServerFavorites, getCustomization } from "@/lib/api"; -import { useEffect, useState } from "react"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "./ui/card"; -import Markdown from "react-markdown"; -import { useTheme } from "next-themes"; -import FadeIn from "react-fade-in/lib/FadeIn"; -import { Button } from "./ui/button"; -import { ServerResponse } from "@/lib/types/mh-server"; -import { Copy, Info } from "lucide-react"; -import toast, { CheckmarkIcon } from "react-hot-toast"; import { MHSF } from "@/lib/mhsf"; -import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; +import { ServerResponse } from "@/lib/types/mh-server"; +import { MinehutIcon, getMinehutIcons } from "@/lib/types/server-icon"; +import { Copy, Info } from "lucide-react"; +import { useTheme } from "next-themes"; +import { useEffect, useState } from "react"; +import FadeIn from "react-fade-in/lib/FadeIn"; +import toast, { CheckmarkIcon } from "react-hot-toast"; +import Markdown from "react-markdown"; import AchievementList from "./feat/AchievementList"; +import { Button } from "./ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "./ui/card"; +import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; export default function AfterServerView({ server }: { server: string }) { - const [description, setDescription] = useState(""); - const [discord, setDiscord] = useState(""); - const [mhsf, setMHSF] = useState(new MHSF()); - const { resolvedTheme } = useTheme(); - const [loading, setLoading] = useState(true); - const [view, setView] = useState( - description !== "" || discord !== "" ? "desc" : "extra" - ); - const [serverObject, setServerObject] = useState( - undefined - ); - const [copied, setCopied] = useState(false); + const [description, setDescription] = useState(""); + const [discord, setDiscord] = useState(""); + const [mhsf, setMHSF] = useState(new MHSF()); + const [icons, setIcons] = useState(); + const { resolvedTheme } = useTheme(); + const [loading, setLoading] = useState(true); + const [view, setView] = useState( + description !== "" || discord !== "" ? "desc" : "extra", + ); + const [serverObject, setServerObject] = useState( + undefined, + ); + const [copied, setCopied] = useState(false); - useEffect(() => { - getCustomization(server).then((b) => { - if (b != null) { - setDescription(b.description == null ? "" : b.description); - setDiscord(b.discord == null ? "" : b.discord); - mhsf.setCustomizations(b); - getCommunityServerFavorites(server).then((c) => { - mhsf.setFavorites(c); - }); - } - fetch("https://api.minehut.com/server/" + server + "?byName=true").then( - (c) => c.json().then((n) => setServerObject(n.server)) - ); - setLoading(false); - }); - }, []); - if (loading) return <>; + useEffect(() => { + getCustomization(server).then((b) => { + if (b != null) { + setDescription(b.description == null ? "" : b.description); + setDiscord(b.discord == null ? "" : b.discord); + mhsf.setCustomizations(b); + getCommunityServerFavorites(server).then((c) => { + mhsf.setFavorites(c); + }); + getMinehutIcons().then((i) => { + setIcons(i); + }); + } + fetch("https://api.minehut.com/server/" + server + "?byName=true").then( + (c) => c.json().then((n) => setServerObject(n.server)), + ); + setLoading(false); + }); + }, []); + if (loading) return <>; - return ( - <> - -
-
- {(description != "" || discord != "") && ( - - )} - - -
-
-
- {(description != "" || discord != "") && ( - - )} - - -
-
+ return ( + <> + +
+
+ {(description != "" || discord != "") && ( + + )} + + + +
+
+
+ {(description != "" || discord != "") && ( + + )} + + + +
+
-
- {description != "" && view == "desc" && ( - - - - {description} - - - - )} - {discord != "" && view == "desc" && ( - - - Discord Server - -