import HomePage from "../../components/home-page"; import ICard from "../../components/introduction-card"; import WCard from "../../components/werefox-card"; import axios from "axios"; export const getPlugins = async () => await axios .get("http://192.168.0.202:8111/api/plugins/list", { headers: { authorization: "rawCvRhEhSJR9TDo9Snw25ZyNYzTKERMsZSVbseqMTyh957JhpbhspderiUAzb7d", }, }) .then( (result) => { return result.data; }, (error) => { console.log(error); return null; } ); // Yes, I know that I'm posting this authorization key publicly and that isn't generally a safe practice, but if someone can actually access that address in my local network, I have bigger problems. export const getInfo = async () => await axios .get("http://192.168.0.202:8111/api/server", { headers: { authorization: "rawCvRhEhSJR9TDo9Snw25ZyNYzTKERMsZSVbseqMTyh957JhpbhspderiUAzb7d", }, }) .then( (result) => { return result.data; }, (error) => { console.log(error); return null; } ); // Grab data from a static YAML file export async function getStaticProps() { const fs = require("fs"); const yaml = require("js-yaml"); let INTRODUCTION = {}; const info = await Promise.resolve(getInfo()); const plugins = await Promise.resolve(getPlugins()); const plugins_sorted = plugins.plugins .map((p) => { return p[0].toUpperCase() + p.substr(1); }) .sort(); try { let fileContent = fs.readFileSync( "./data/minecraft/introduction.yml", "utf8" ); INTRODUCTION = yaml.load(fileContent); } catch (e) { console.log(e); } return { props: { INTRODUCTION, plugins_list: plugins_sorted, server_info: info, }, }; } export default function Minecraft({ plugins_list, server_info, INTRODUCTION }) { const server_info_keys = { serverVersion: "Server Version", serverBukkitVersion: "Bukkit Version", }; return ( {Object.keys(server_info_keys).map((key) => (
{server_info_keys[key]}: {server_info[key]}
))}
{Object.keys(plugins_list).map((plugin) => (
- {plugins_list[plugin]}
))}
); }