diff --git a/.gitignore b/.gitignore index 009bbf3..c167189 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,18 @@ +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# Fresh build directory +_fresh/ + +# JAR files in case one shows up **/*.jar -.vscode \ No newline at end of file +fabric/ +forge/ +vanilla/ + +# Config file for MCGRIZZ +mcgrizz.json \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..971c0ed --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "denoland.vscode-deno", + "sastan.twind-intellisense" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a5f0701 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +{ + "deno.enable": true, + "deno.lint": true, + "editor.defaultFormatter": "denoland.vscode-deno", + "[typescriptreact]": { + "editor.defaultFormatter": "denoland.vscode-deno" + }, + "[typescript]": { + "editor.defaultFormatter": "denoland.vscode-deno" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "denoland.vscode-deno" + }, + "[javascript]": { + "editor.defaultFormatter": "denoland.vscode-deno" + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec0e33e --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Fresh project + +Your new Fresh project is ready to go. You can follow the Fresh "Getting +Started" guide here: https://fresh.deno.dev/docs/getting-started + +### Usage + +Make sure to install Deno: https://deno.land/manual/getting_started/installation + +Then start the project: + +``` +deno task start +``` + +This will watch the project directory and restart as necessary. diff --git a/components/Button.tsx b/components/Button.tsx new file mode 100644 index 0000000..5cfbdc9 --- /dev/null +++ b/components/Button.tsx @@ -0,0 +1,49 @@ +import { JSX } from "preact"; +import { IS_BROWSER } from "$fresh/runtime.ts"; + +const colors = { + licorice: { + bg: "bg-licorice", + border: "border-licorice-800", + text: "text-white", + }, + sky: { + bg: "bg-sky", + border: "border-sky-800", + text: "text-white", + }, + grape: { + bg: "bg-grape", + border: "border-grape-800", + text: "text-white", + }, + fire: { + bg: "bg-grape", + border: "border-grape-800", + text: "text-white", + }, +}; + +export function Button( + props: JSX.HTMLAttributes & { color?: keyof typeof colors }, +) { + const color = props.color || 'sky'; + const classes = ` + px-2 + py-1 + rounded-xl + border-2 + ${colors[color].bg} + ${colors[color].border} + ${colors[color].text} + hover:bg-smoke-500 + transition-colors + ${props.class || ""}`; + return ( + +

{props.count}

+ + + ); +} diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..8ef5d92 --- /dev/null +++ b/main.ts @@ -0,0 +1,12 @@ +/// +/// +/// +/// +/// + +import "$std/dotenv/load.ts"; + +import { start } from "$fresh/server.ts"; +import manifest from "./fresh.gen.ts"; + +await start(manifest); diff --git a/routes/_404.tsx b/routes/_404.tsx new file mode 100644 index 0000000..6925a37 --- /dev/null +++ b/routes/_404.tsx @@ -0,0 +1,25 @@ +import { Head } from "$fresh/runtime.ts"; + +export default function Error404() { + return ( + <> + + 404 - Page not found + +
+
+ a gif of a bear playing with the camera +

404 - Page not found

+

+ Looks like we couldn't find what you were looking for, but this bear found a camera! +

+ Go back home +
+
+ + ); +} diff --git a/routes/_app.tsx b/routes/_app.tsx new file mode 100644 index 0000000..69f55bc --- /dev/null +++ b/routes/_app.tsx @@ -0,0 +1,50 @@ +import { AppProps } from "$fresh/server.ts"; +import { Nav } from "../components/nav/index.tsx"; + +export default function App({ Component }: AppProps) { + return ( + + + + + + MC GRIZZ + + + + + + + +
+
+
+ +
+

MC Grizz

+
+ A Minecraft Server Manager +
+
+ +
+
+ +
+
+ + + ); +} diff --git a/routes/api/joke.ts b/routes/api/joke.ts new file mode 100644 index 0000000..a3f4243 --- /dev/null +++ b/routes/api/joke.ts @@ -0,0 +1,21 @@ +import { HandlerContext } from "$fresh/server.ts"; + +// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/ +const JOKES = [ + "Why do Java developers often wear glasses? They can't C#.", + "A SQL query walks into a bar, goes up to two tables and says “can I join you?”", + "Wasn't hard to crack Forrest Gump's password. 1forrest1.", + "I love pressing the F5 key. It's refreshing.", + "Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”", + "There are 10 types of people in the world. Those who understand binary and those who don't.", + "Why are assembly programmers often wet? They work below C level.", + "My favourite computer based band is the Black IPs.", + "What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.", + "An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.", +]; + +export const handler = (_req: Request, _ctx: HandlerContext): Response => { + const randomIndex = Math.floor(Math.random() * JOKES.length); + const body = JOKES[randomIndex]; + return new Response(body); +}; diff --git a/routes/index.tsx b/routes/index.tsx new file mode 100644 index 0000000..601ee0c --- /dev/null +++ b/routes/index.tsx @@ -0,0 +1,65 @@ +import { Button } from "../components/Button.tsx"; +import { Content } from "../components/Content.tsx"; +import { OL } from "../components/OL.tsx"; + +export default function Home() { + return ( +
+ +
+ ); +} + +function Setup() { + return ( + +

First Time Setup

+

+ Looks like this is your first time running{" "} + MC Grizz +

+

There are just a few steps to get you up an running.

+
    +
    +

    Select your loader

    +

    Choose between Forge, Fabric, or Vanilla (support for Bukkit, Spigot, and others coming... soon...)

    +
    +
    +

    Accept EULA

    +

    + Mojang requires you to accept their{" "} + + EULA + {" "} + (End-User License Agreement) in order to be able to run a server. +

    +
    +
    +

    Select Mods and Datapacks

    +

    + We'll show you a selection of preconfigured modpacks, mods, and + datapacks for you to choose for your server +

    +
    +
    +

    Game On!

    +

    + Time to play! We'll finish setting everything up and give you the IP + address for you and your friends to connect. +

    +
    +
+ +
+ ); +} diff --git a/routes/setup/index.tsx b/routes/setup/index.tsx new file mode 100644 index 0000000..1961147 --- /dev/null +++ b/routes/setup/index.tsx @@ -0,0 +1,25 @@ +import { Button } from "../../components/Button.tsx"; +import { Content } from "../../components/Content.tsx"; + +export default function Setup() { + return ( +
+ +

Select Loader

+

Choose between Forge, Fabric, or Vanilla

+ + +
+
+ ); +} diff --git a/static/Minecraft.ttf b/static/Minecraft.ttf new file mode 100644 index 0000000..c4d8b01 Binary files /dev/null and b/static/Minecraft.ttf differ diff --git a/static/bearcam.gif b/static/bearcam.gif new file mode 100644 index 0000000..070e694 Binary files /dev/null and b/static/bearcam.gif differ diff --git a/static/cyborggrizzly.svg b/static/cyborggrizzly.svg new file mode 100644 index 0000000..1b164f1 --- /dev/null +++ b/static/cyborggrizzly.svg @@ -0,0 +1,22057 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/static/fonts/minecraft/MinecraftBold.otf b/static/fonts/minecraft/MinecraftBold.otf new file mode 100644 index 0000000..87b124c Binary files /dev/null and b/static/fonts/minecraft/MinecraftBold.otf differ diff --git a/static/fonts/minecraft/MinecraftBoldItalic.otf b/static/fonts/minecraft/MinecraftBoldItalic.otf new file mode 100644 index 0000000..1f74f38 Binary files /dev/null and b/static/fonts/minecraft/MinecraftBoldItalic.otf differ diff --git a/static/fonts/minecraft/MinecraftItalic.otf b/static/fonts/minecraft/MinecraftItalic.otf new file mode 100644 index 0000000..6801bd8 Binary files /dev/null and b/static/fonts/minecraft/MinecraftItalic.otf differ diff --git a/static/fonts/minecraft/MinecraftRegular.otf b/static/fonts/minecraft/MinecraftRegular.otf new file mode 100644 index 0000000..54f08ad Binary files /dev/null and b/static/fonts/minecraft/MinecraftRegular.otf differ diff --git a/static/styles/main.css b/static/styles/main.css new file mode 100644 index 0000000..696af7c --- /dev/null +++ b/static/styles/main.css @@ -0,0 +1,32 @@ +@font-face { + font-family: 'Minecraft'; + src: url('/fonts/minecraft/MinecraftRegular.otf'); + font-weight: normal; + font-style: normal; +} +@font-face { + font-family: 'Minecraft'; + src: url('/fonts/minecraft/MinecraftBold.otf'); + font-weight: bold; + font-style: normal; +} +@font-face { + font-family: 'Minecraft'; + src: url('/fonts/minecraft/MinecraftBoldItalic.otf'); + font-weight: bold; + font-style: italic; +} +@font-face { + font-family: 'Minecraft'; + src: url('/fonts/minecraft/MinecraftItalic.otf'); + font-weight: normal; + font-style: italic; +} + +@tailwind base; +@tailwind components; +@tailwind utilities; + +* { + font-family: 'Titillium Web', sans-serif; +} diff --git a/static/styles/tailwind.css b/static/styles/tailwind.css new file mode 100644 index 0000000..845b60b --- /dev/null +++ b/static/styles/tailwind.css @@ -0,0 +1,2 @@ +@font-face{font-family:Minecraft;font-style:normal;font-weight:400;src:url(/fonts/minecraft/MinecraftRegular.otf)}@font-face{font-family:Minecraft;font-style:normal;font-weight:700;src:url(/fonts/minecraft/MinecraftBold.otf)}@font-face{font-family:Minecraft;font-style:italic;font-weight:700;src:url(/fonts/minecraft/MinecraftBoldItalic.otf)}@font-face{font-family:Minecraft;font-style:italic;font-weight:400;src:url(/fonts/minecraft/MinecraftItalic.otf)} +/*! tailwindcss v3.2.4 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{margin-left:auto;margin-right:auto;width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.absolute{position:absolute}.relative{position:relative}.bottom-1{bottom:.25rem}.right-2{right:.5rem}.top-1{top:.25rem}.left-2{left:.5rem}.bottom-0{bottom:0}.top-0{top:0}.right-0{right:0}.-bottom-1{bottom:-.25rem}.right-1{right:.25rem}.-bottom-2{bottom:-.5rem}.-bottom-4{bottom:-1rem}.m-auto{margin:auto}.mx-auto{margin-left:auto;margin-right:auto}.my-6{margin-bottom:1.5rem;margin-top:1.5rem}.my-4{margin-bottom:1rem;margin-top:1rem}.mb-8{margin-bottom:2rem}.mt-auto{margin-top:auto}.mt-16{margin-top:4rem}.ml-auto{margin-left:auto}.mt-2{margin-top:.5rem}.mr-auto{margin-right:auto}.mt-8{margin-top:2rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.h-\[100vh\]{height:100vh}.h-full{height:100%}.h-16{height:4rem}.max-h-full{max-height:100%}.w-full{width:100%}.w-16{width:4rem}.min-w-\[400px\]{min-width:400px}.max-w-screen-md{max-width:768px}.flex-1{flex:1 1 0%}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-4{gap:1rem}.gap-8{gap:2rem}.overflow-y-auto{overflow-y:auto}.rounded-3xl{border-radius:1.5rem}.rounded-xl{border-radius:.75rem}.rounded-md{border-radius:.375rem}.border-4{border-width:4px}.border-2{border-width:2px}.border{border-width:1px}.border-r-2{border-right-width:2px}.border-sky{--tw-border-opacity:1;border-color:rgb(49 167 230/var(--tw-border-opacity))}.border-licorice-800{--tw-border-opacity:1;border-color:rgb(150 60 151/var(--tw-border-opacity))}.border-sky-800{--tw-border-opacity:1;border-color:rgb(17 82 123/var(--tw-border-opacity))}.border-grape-800{--tw-border-opacity:1;border-color:rgb(109 33 135/var(--tw-border-opacity))}.border-sky-950{--tw-border-opacity:1;border-color:rgb(13 44 68/var(--tw-border-opacity))}.bg-licorice{--tw-bg-opacity:1;background-color:rgb(22 10 22/var(--tw-bg-opacity))}.bg-smoke-800{--tw-bg-opacity:1;background-color:rgb(65 65 75/var(--tw-bg-opacity))}.bg-sky{--tw-bg-opacity:1;background-color:rgb(49 167 230/var(--tw-bg-opacity))}.bg-grape{--tw-bg-opacity:1;background-color:rgb(64 10 80/var(--tw-bg-opacity))}.bg-smoke-900{--tw-bg-opacity:1;background-color:rgb(57 57 65/var(--tw-bg-opacity))}.bg-smoke{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity))}.bg-smoke-200{--tw-bg-opacity:1;background-color:rgb(217 217 222/var(--tw-bg-opacity))}.p-4{padding:1rem}.p-8{padding:2rem}.p-2{padding:.5rem}.p-1{padding:.25rem}.py-6{padding-bottom:1.5rem;padding-top:1.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.text-center{text-align:center}.text-right{text-align:right}.font-pixel{font-family:Minecraft,cursive}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-6xl{font-size:3.75rem;line-height:1}.text-5xl{font-size:3rem;line-height:1}.text-7xl{font-size:4.5rem;line-height:1}.font-bold{font-weight:700}.text-sky{--tw-text-opacity:1;color:rgb(49 167 230/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-smoke-700{--tw-text-opacity:1;color:rgb(76 77 88/var(--tw-text-opacity))}.text-smoke-700\/10{color:#4c4d581a}.text-smoke-900\/10{color:#3939411a}.text-smoke-950\/10{color:#18181b1a}.text-smoke-950\/20{color:#18181b33}.text-smoke-950\/30{color:#18181b4d}.text-smoke-800\/30{color:#41414b4d}.underline{text-decoration-line:underline}.transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}*{font-family:Titillium Web,sans-serif}.even\:bg-black\/20:nth-child(2n),.even\:bg-black\/\[\.2\]:nth-child(2n){background-color:#0003}.even\:bg-black\/10:nth-child(2n){background-color:#0000001a}.hover\:bg-gray-200:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.hover\:bg-smoke-500:hover{--tw-bg-opacity:1;background-color:rgb(115 117 132/var(--tw-bg-opacity))}@media (prefers-color-scheme:dark){.dark\:border-sky-950{--tw-border-opacity:1;border-color:rgb(13 44 68/var(--tw-border-opacity))}.dark\:bg-smoke{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity))}.dark\:bg-smoke-900{--tw-bg-opacity:1;background-color:rgb(57 57 65/var(--tw-bg-opacity))}.dark\:text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}} \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..8026a85 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,104 @@ +/** @type {import('https://esm.sh/tailwindcss@3.1.8').Config} */ +module.exports = { + content: [ + "./routes/**/*.{tsx,ts}", + "./islands/**/*.{tsx,ts}", + "./components/**/*.{tsx,ts}", + ], + theme: { + extend: { + colors: { + "licorice": { + DEFAULT: "#160a16", + "50": "#f9f0fd", + "100": "#f4e3fc", + "200": "#edcdf8", + "300": "#e3aef3", + "400": "#dd8dec", + "500": "#d971e3", + "600": "#d456d5", + "700": "#bb47b9", + "800": "#963c97", + "900": "#783679", + "950": "#160a16", + }, + "sky": { + DEFAULT: "#31a7e6", + "50": "#f1f8fe", + "100": "#e2f1fc", + "200": "#bfe2f8", + "300": "#87cbf2", + "400": "#31a7e6", + "500": "#1f96d8", + "600": "#1278b7", + "700": "#106094", + "800": "#11527b", + "900": "#144566", + "950": "#0d2c44", + }, + "grape": { + DEFAULT: "#400a50", + "50": "#fbf5fe", + "100": "#f6eafd", + "200": "#ecd3fb", + "300": "#e0b1f6", + "400": "#cf82f0", + "500": "#b752e3", + "600": "#9d32c7", + "700": "#8426a5", + "800": "#6d2187", + "900": "#5c206f", + "950": "#400a50", + }, + "fire": { + DEFAULT: "#e61c1c", + "50": "#fff1f1", + "100": "#ffe0e0", + "200": "#ffc7c7", + "300": "#ffa0a0", + "400": "#ff6969", + "500": "#f93a3a", + "600": "#e61c1c", + "700": "#d61515", + "800": "#a01414", + "900": "#851717", + "950": "#480707", + }, + "smoke": { + DEFAULT: "#18181b", + "50": "#f7f7f8", + "100": "#eeeef0", + "200": "#d9d9de", + "300": "#b8b9c1", + "400": "#91939f", + "500": "#737584", + "600": "#5d5e6c", + "700": "#4c4d58", + "800": "#41414b", + "900": "#393941", + "950": "#18181b", + }, + "wasabi": { + DEFAULT: "#808627", + "50": "#fafaeb", + "100": "#f3f2d4", + "200": "#e9e9ad", + "300": "#d7d97d", + "400": "#c3c754", + "500": "#a6ac36", + "600": "#808627", + "700": "#636922", + "800": "#4f5420", + "900": "#43481f", + "950": "#23270c", + }, + }, + fontFamily: { + pixel: "'Minecraft', cursive", + }, + }, + container: { + center: true, + }, + }, +}; diff --git a/types/mcgrizzconf.ts b/types/mcgrizzconf.ts new file mode 100644 index 0000000..e2ac25b --- /dev/null +++ b/types/mcgrizzconf.ts @@ -0,0 +1,5 @@ +export type Loader = 'forge' | 'fabric' | 'vanilla' | 'unset'; + +export type MCGrizzConf = { + loader: Loader +} \ No newline at end of file diff --git a/types/nav.ts b/types/nav.ts new file mode 100644 index 0000000..a971db4 --- /dev/null +++ b/types/nav.ts @@ -0,0 +1,6 @@ +export type NavItem = { + title: string; + href: string; + external?: boolean; + children?: NavItem[] +} \ No newline at end of file diff --git a/util/getNavItems.ts b/util/getNavItems.ts new file mode 100644 index 0000000..8d80a80 --- /dev/null +++ b/util/getNavItems.ts @@ -0,0 +1,27 @@ +import { MCGrizzConf } from "../types/mcgrizzconf.ts"; +import { NavItem } from "../types/nav.ts"; +import { makeConfFile } from "./makeConfFile.ts"; + +/** + * @description Determines the state of setup and returns the nav items for that state + */ +export function getNavItems(): NavItem[] { + let conf: MCGrizzConf; + try { + conf = JSON.parse(Deno.readTextFileSync('mcgrizz.json')); + } catch { + conf = makeConfFile(); + } + + switch (conf.loader) { + case "unset": + return [{ + title: 'Setup', + href: '/', + }] + case "forge": + case "fabric": + case "vanilla": + return []; + } +} diff --git a/util/makeConfFile.ts b/util/makeConfFile.ts new file mode 100644 index 0000000..092a396 --- /dev/null +++ b/util/makeConfFile.ts @@ -0,0 +1,11 @@ +import { MCGrizzConf } from "../types/mcgrizzconf.ts"; + +export function makeConfFile(): MCGrizzConf { + const conf: MCGrizzConf = { + loader: 'unset', + } + + Deno.writeTextFileSync('mcgrizz.json', JSON.stringify(conf), {create: true}); + + return conf; +} \ No newline at end of file