mcgrizz/util/getNavItems.ts
2023-10-05 10:27:52 -06:00

48 lines
1.0 KiB
TypeScript

// deno-lint-ignore-file no-fallthrough
import { MCGrizzConf } from "../types/mcgrizzconf.ts";
import { NavItem } from "../types/nav.ts";
import { makeConfFile } from "./confFile.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();
}
const items: NavItem[] = [];
switch (conf.loader) {
case "unset":
items.push({
title: "Setup",
href: "/",
});
break;
case "forge":
case "fabric":
items.push({ title: "Mods", href: "/mods" });
case "vanilla":
items.unshift(
{
title: "Server Terminal",
href: "/terminal",
},
{
title: "Players",
href: "/players",
},
{
title: "Server Properties",
href: "/properties",
},
);
break;
}
return items;
}