diff --git a/components/REPL/index.tsx b/components/REPL/index.tsx index 6b12809..b43f33c 100644 --- a/components/REPL/index.tsx +++ b/components/REPL/index.tsx @@ -2,15 +2,15 @@ import { MutableRefObject, useEffect, useRef, useState } from "react"; import REPLInput from "./REPLInput"; import REPLHistory from "./REPLHistory"; import styles from "../../styles/REPL/REPLComplete.module.css"; -import type { NextPage } from "next"; +import type { NextPage, GetStaticProps } from "next"; interface IREPLProps { inputRef: MutableRefObject; + buildTime: string; } -const REPL: NextPage = ({ inputRef }) => { - const date = new Date(); - const [history, manipulateHistory] = useState([`cer0 0S - ${date.toLocaleDateString()}`]); +const REPL: NextPage = ({ inputRef, buildTime }) => { + const [history, manipulateHistory] = useState([`cer0 0S - Build ${buildTime}`]); const containerRef = useRef(null); const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000)); const onClearHistory = () => manipulateHistory([]); diff --git a/pages/index.tsx b/pages/index.tsx index 558dc1f..1db6b55 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,4 +1,4 @@ -import type { NextPage } from "next"; +import type { NextPage, GetStaticProps } from "next"; import Head from "next/head"; import { GithubLogo, InstagramLogo, DiscordLogo, GameController } from "phosphor-react"; import { useEffect, useRef,useCallback } from "react"; @@ -8,7 +8,7 @@ import ProjectModal from "../components/ProjectModal"; import REPL from "../components/REPL"; import styles from "../styles/Home.module.css"; -const Home: NextPage = () => { +const Home: NextPage<{ buildTime: string }> = ({ buildTime }) => { const inputRef = useRef(null); const { modalFunctions } = useModalFunctions(); const { setContents } = useCommands(); @@ -64,9 +64,20 @@ const Home: NextPage = () => {   - + ); }; +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 Home;