import type { NextPage, GetStaticProps } from "next"; import Head from "next/head"; import Link from "next/link"; import Icon from "@mdi/react"; import { mdiEmail } from "@mdi/js"; import { useEffect, useRef,useCallback } from "react"; import { useCommands } from "../lib/commands/ContextProvider"; import { useModalFunctions } from "../components/Terminal/contexts/ModalFunctions"; import ProjectModal from "../components/Terminal/ProjectModal"; import REPL from "../components/Terminal/REPL"; import type { ContentList } from "../lib/content/types"; import { useRouter } from "next/router"; import Rainbow from "../lib/colors"; import styles from "../styles/Terminal/Terminal.module.css"; import socials from "../data/socials"; const Terminal: NextPage<{ buildTime: string }> = ({ buildTime }) => { const inputRef = useRef(null); const { modalFunctions } = useModalFunctions(); const { setContents } = useCommands(); const router = useRouter(); const updateProjects = useCallback(async () => { try { const res = await fetch("/content/list.json"); const projects: ContentList = await res.json(); projects.sort((a, b) => { return a.name.localeCompare(b.name); }); setContents(projects); } catch {} }, [setContents]); const focusInput = () => { if (inputRef.current) inputRef.current.focus(); }; const hideModalOnEsc = (e: React.KeyboardEvent) => { if (e.key === "Escape") { e.preventDefault(); if(modalFunctions.setVisible) modalFunctions.setVisible(false); } }; useEffect(() => { updateProjects().then(() => { if (modalFunctions.onContentReady) modalFunctions.onContentReady(); }); const interval = setInterval(updateProjects, 30 * 1000); return () => clearInterval(interval); }, [updateProjects, modalFunctions]); useEffect(() => { if ("rainbow" in router.query) { Rainbow.start(); } }, [router]); const iconSize = "1.3em"; const socialLinks = socials(iconSize, "var(--repl_color)").map((social, i) => {social.icon}); return (
c0ntroller.de
  Main page | Source | Bug? | | {socialLinks.flatMap((social, i) => i !== 0 ? [|, social] : [social])}  
); }; export const getStaticProps: GetStaticProps = async (_context) => { const date = new Date(); const padD = (n: number) => n.toString().padStart(2, "0"); const buildTime = `${date.getUTCFullYear()}${padD(date.getUTCDate())}${padD(date.getUTCMonth() + 1)}-${padD(date.getUTCHours())}${padD(date.getUTCMinutes())}`; return { props: { buildTime } }; }; export default Terminal;