From 700d1caadc9a3fb2bbcf61bc146efe8d95d77354 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:51:11 -0500 Subject: [PATCH] chore: adding achievement documentation along with this, i added brand new `lastUpdated` and `folder` fields for the docs :eyes: --- contentlayer.config.js | 84 +++++++++++++---------- docs/advanced/achievements.mdx | 26 ++++++- docs/advanced/command-bar.mdx | 1 + docs/advanced/external.mdx | 1 + docs/advanced/tech-stack.mdx | 1 + docs/getting-started.mdx | 2 +- docs/guides/customization.mdx | 1 + docs/guides/linking.mdx | 1 + docs/guides/owning-a-server.mdx | 1 + docs/guides/reporting-server.mdx | 1 + docs/legal/external-content-agreement.mdx | 2 + src/app/docs/[[...slug]]/page.tsx | 2 + src/components/feat/AchievementList.tsx | 41 +---------- src/components/misc/MDXElements.tsx | 33 +++++++++ src/config/achievements.ts | 57 +++++++++++++++ 15 files changed, 177 insertions(+), 77 deletions(-) create mode 100644 src/config/achievements.ts diff --git a/contentlayer.config.js b/contentlayer.config.js index 4639856..d31cb2e 100755 --- a/contentlayer.config.js +++ b/contentlayer.config.js @@ -1,42 +1,54 @@ import { defineDocumentType, makeSource } from "contentlayer/source-files"; import rehypeSlug from "rehype-slug"; -import GithubSlugger from "github-slugger" +import GithubSlugger from "github-slugger"; export const Docs = defineDocumentType(() => ({ - name: "Docs", - filePathPattern: `**/*.mdx`, - contentType: "mdx", - fields: { - title: { - type: "string", - required: true, - }, - }, - computedFields: { - url: { - type: "string", - resolve: (docs) => `/docs/${docs._raw.flattenedPath}`, - }, - toc: { - type: "json", - resolve: async (doc) => { - const headingsRegex = /\n(?#{1,6})\s+(?.+)/g; - const slugger = new GithubSlugger() - const headings = Array.from(doc.body.raw.matchAll(headingsRegex)).map( - ({ groups }) => { - const flag = groups?.flag; - const content = groups?.content; - return { - level: flag.length, - text: content, - slug: content ? slugger.slug(content) : undefined - }; - } - ); - return headings; - }, - }, - }, + name: "Docs", + filePathPattern: `**/*.mdx`, + contentType: "mdx", + fields: { + title: { + type: "string", + required: true, + }, + folder: { + type: "string", + required: false, + }, + lastUpdated: { + type: "string", + required: false, + }, + }, + computedFields: { + url: { + type: "string", + resolve: (docs) => `/docs/${docs._raw.flattenedPath}`, + }, + toc: { + type: "json", + resolve: async (doc) => { + const headingsRegex = /\n(?#{1,6})\s+(?.+)/g; + const slugger = new GithubSlugger(); + const headings = Array.from(doc.body.raw.matchAll(headingsRegex)).map( + ({ groups }) => { + const flag = groups?.flag; + const content = groups?.content; + return { + level: flag.length, + text: content, + slug: content ? slugger.slug(content) : undefined, + }; + }, + ); + return headings; + }, + }, + }, })); -export default makeSource({ contentDirPath: "docs", documentTypes: [Docs], mdx: {rehypePlugins: [rehypeSlug]} }); +export default makeSource({ + contentDirPath: "docs", + documentTypes: [Docs], + mdx: { rehypePlugins: [rehypeSlug] }, +}); diff --git a/docs/advanced/achievements.mdx b/docs/advanced/achievements.mdx index d9d6bf2..5998e71 100644 --- a/docs/advanced/achievements.mdx +++ b/docs/advanced/achievements.mdx @@ -1,10 +1,34 @@ --- title: "Achievement Collection" +folder: "Advanced" --- +import { formalNames } from "@/config/achievements" + # Achievements Achievements are a page that every server gets which contains certain requirements which could be embedded in an servers history. -Achievements are *not* collected instantly, and are actually collected every 12 hours. (this is not timezone dependent) There are currently 5 possible achievements to get, ranging from easiest to hardest. \ No newline at end of file +These achievements are accessable using the "Achievements" tab on the left of any server page. +Achievements are *not* collected instantly, and are collected every 12 hours when the server is online (this is not timezone dependent). +There are currently {Object.keys(formalNames).length} possible achievements to get, ranging from easiest to hardest. + +## 1 thousand favorites achievement +After getting 1 thousand favorites on MHSF, and your server is online during the achievement collection, *you will get this achievement showing* when you got **1,000 users to favorite your server**. + + +## 1 thousand total joins achievement +After getting 1 thousand total joins on Minehut, and your server is online during the achievement collection, *you will get this achievement showing* when you got **1,000 users to join your server**. +
Here is a preview: + + +## 100 thousand favorites achievement +After getting 100 thousand favorites on MHSF, and your server is online during the achievement collection, *you will get this achievement showing* when you got **100 thousand users to favorite your server**. +
Here is a preview: + + +## 1 thousand total joins achievement +After getting 100 thousand total joins on Minehut, and your server is online during the achievement collection, *you will get this achievement showing* when you got **100 thousand users to join your server**. +
Here is a preview: + \ No newline at end of file diff --git a/docs/advanced/command-bar.mdx b/docs/advanced/command-bar.mdx index e6123f7..758b07a 100644 --- a/docs/advanced/command-bar.mdx +++ b/docs/advanced/command-bar.mdx @@ -1,5 +1,6 @@ --- title: "Using the Command-bar" +folder: "Advanced" --- # Using the Command-bar diff --git a/docs/advanced/external.mdx b/docs/advanced/external.mdx index 2c8ecd1..bccd615 100644 --- a/docs/advanced/external.mdx +++ b/docs/advanced/external.mdx @@ -1,5 +1,6 @@ --- title: "Troubleshooting: Making external servers on Minehut" +folder: "Advanced" --- # External Servers on Minehut diff --git a/docs/advanced/tech-stack.mdx b/docs/advanced/tech-stack.mdx index 432788f..a8bb2b4 100644 --- a/docs/advanced/tech-stack.mdx +++ b/docs/advanced/tech-stack.mdx @@ -1,5 +1,6 @@ --- title: "Tech-stack" +folder: "Advanced" --- # Teck Stack of MHSF diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx index 5d569f5..b91b255 100644 --- a/docs/getting-started.mdx +++ b/docs/getting-started.mdx @@ -16,7 +16,7 @@ Wrappers usually communicate using an API that was provided by the service its s ## Why to use MHSF - **Faster response times** MHSF is completely ad-free, and as a result of being open-source, constantly tries to cut down on unnecessary things slowing down the page. -- **Open-source & no tracking** As a result of being open-source, MHSF will never track or sell your to advertisers. Anybody can look at the code, and can be verified to be completely secure. +- **Open-source & no tracking** As a result of being open-source, MHSF will never track or sell your data to advertisers. Anybody can look at the code, and can be verified to be completely secure. - **Make your server stand out** Server owners can configure after appropriate verification banners, Discord widgets, descriptions & color schemes. - **Customize your experience** Filters, sorts & different spacing settings can make your experience just how you like it while you are browsing servers. - **Better & more intuitive UX/UI** UI is a big point for MHSF, using UI designed to be more user friendly, and to be more straight-forward then Minehut's diff --git a/docs/guides/customization.mdx b/docs/guides/customization.mdx index 63cf6d6..5f16cae 100644 --- a/docs/guides/customization.mdx +++ b/docs/guides/customization.mdx @@ -1,5 +1,6 @@ --- title: "Customization" +folder: "Guides" --- # Customize your server diff --git a/docs/guides/linking.mdx b/docs/guides/linking.mdx index 6d11a14..f5d0c5c 100644 --- a/docs/guides/linking.mdx +++ b/docs/guides/linking.mdx @@ -1,5 +1,6 @@ --- title: "Linking your account" +folder: "Guides" --- # Linking your Minecraft account diff --git a/docs/guides/owning-a-server.mdx b/docs/guides/owning-a-server.mdx index b6054de..295ef4c 100644 --- a/docs/guides/owning-a-server.mdx +++ b/docs/guides/owning-a-server.mdx @@ -1,5 +1,6 @@ --- title: "Own a server" +folder: "Guides" --- # Owning a server diff --git a/docs/guides/reporting-server.mdx b/docs/guides/reporting-server.mdx index 551bd83..394ff81 100644 --- a/docs/guides/reporting-server.mdx +++ b/docs/guides/reporting-server.mdx @@ -1,5 +1,6 @@ --- title: "Reporting a server" +folder: "Guides" --- # Reporting a server diff --git a/docs/legal/external-content-agreement.mdx b/docs/legal/external-content-agreement.mdx index b1ae076..8a322db 100644 --- a/docs/legal/external-content-agreement.mdx +++ b/docs/legal/external-content-agreement.mdx @@ -1,5 +1,7 @@ --- title: "External Content Agreement" +folder: "Legal" +lastUpdated: "Sep. 10th 2024" --- # External Content Agreement (ECA) diff --git a/src/app/docs/[[...slug]]/page.tsx b/src/app/docs/[[...slug]]/page.tsx index 3c024e9..ed048b7 100644 --- a/src/app/docs/[[...slug]]/page.tsx +++ b/src/app/docs/[[...slug]]/page.tsx @@ -36,6 +36,8 @@ const PostLayout = ({ params }: { params: { slug: string[] } }) => {
+ {doc.folder && {doc.folder}}{" "} + {doc.lastUpdated && - last updated {doc.lastUpdated}}{" "} this server had the most players on the platform!", - description: - "This is awarded to servers that had the number 1 permission at the time of the achievements getting resolved.", - color: "#9aedff", - icon: Medal, - }, - has1kFavorites: { - title: "This server has more than 1,000 favorites on MHSF!", - description: - "This is awarded to servers that had 1,000 favorites at the time of the achievements getting resolved.", - color: "#d064ff", - icon: Sparkle, - }, - has1kTotalJoins: { - title: "This server has more than 1,000 total joins on Minehut!", - description: - "This is awarded to servers that had 1,000 total joins at the time of the achievements getting resolved.", - color: "#aefa1f", - icon: Users, - }, - has100kFavorites: { - title: "This server has more than 100,000 favorites on MHSF!", - description: - "This is awarded to servers that had 100,000 favorites at the time of the achievements getting resolved.", - color: "#fa5b07", - icon: Sparkles, - }, - has100kTotalJoins: { - title: "This server has more than 100,000 total joins on Minehut!", - description: - "This is awarded to servers that had 100,000 total joins at the time of the achievements getting resolved.", - color: "#bdcffa", - icon: Users, - }, -}; + type WithInterval = K & { interval: number; diff --git a/src/components/misc/MDXElements.tsx b/src/components/misc/MDXElements.tsx index 14db379..4d6b933 100644 --- a/src/components/misc/MDXElements.tsx +++ b/src/components/misc/MDXElements.tsx @@ -1,5 +1,7 @@ import { Book, ExternalLink, NotebookText } from "lucide-react"; import type { SVGProps } from "react"; +import { Card, CardContent } from "../ui/card"; +import { formalNames } from "@/config/achievements"; type MDXElementType = { [key: string]: (props: any) => JSX.Element; @@ -21,9 +23,40 @@ const Discord = (props: SVGProps) => ( /> ); +function AchievementPreview({ title }: { title: string }) { + const Icon = formalNames[title].icon; + return ( +
+ + + + + + +

{formalNames[title].description}

+ + Achieved on {new Date().getMonth()}/{new Date().getDate()}/ + {new Date().getFullYear()}{" "} + + {new Date().toLocaleTimeString()} + + +
+
+
+ ); +} export const MDXElements: MDXElementType = { Discord, + AchievementPreview, Book: (props) => , Notebook: (props) => , ExternalLink: (props) => , diff --git a/src/config/achievements.ts b/src/config/achievements.ts new file mode 100644 index 0000000..fad95dd --- /dev/null +++ b/src/config/achievements.ts @@ -0,0 +1,57 @@ +import { + type LucideProps, + Medal, + Sparkle, + Sparkles, + Users, +} from "lucide-react"; +import type { ForwardRefExoticComponent, RefAttributes } from "react"; + +export const formalNames: FormalNames = { + mostJoined: { + title: + "At one time, this server had the most players on the platform!", + description: + "This is awarded to servers that had the number 1 permission at the time of the achievements getting resolved.", + color: "#9aedff", + icon: Medal, + }, + has1kFavorites: { + title: "This server has more than 1,000 favorites on MHSF!", + description: + "This is awarded to servers that had 1,000 favorites at the time of the achievements getting resolved.", + color: "#d064ff", + icon: Sparkle, + }, + has1kTotalJoins: { + title: "This server has more than 1,000 total joins on Minehut!", + description: + "This is awarded to servers that had 1,000 total joins at the time of the achievements getting resolved.", + color: "#aefa1f", + icon: Users, + }, + has100kFavorites: { + title: "This server has more than 100,000 favorites on MHSF!", + description: + "This is awarded to servers that had 100,000 favorites at the time of the achievements getting resolved.", + color: "#fa5b07", + icon: Sparkles, + }, + has100kTotalJoins: { + title: "This server has more than 100,000 total joins on Minehut!", + description: + "This is awarded to servers that had 100,000 total joins at the time of the achievements getting resolved.", + color: "#bdcffa", + icon: Users, + }, +}; +interface FormalNames { + [key: string]: { + title: string; + description: string; + color: string; + icon: ForwardRefExoticComponent< + Omit & RefAttributes + >; + }; +}