Add buildtime as static prop
This commit is contained in:
parent
5708a30835
commit
ce00e33338
@ -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<HTMLInputElement|null>;
|
||||
buildTime: string;
|
||||
}
|
||||
|
||||
const REPL: NextPage<IREPLProps> = ({ inputRef }) => {
|
||||
const date = new Date();
|
||||
const [history, manipulateHistory] = useState<string[]>([`cer0 0S - ${date.toLocaleDateString()}`]);
|
||||
const REPL: NextPage<IREPLProps> = ({ inputRef, buildTime }) => {
|
||||
const [history, manipulateHistory] = useState<string[]>([`cer0 0S - Build ${buildTime}`]);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
|
||||
const onClearHistory = () => manipulateHistory([]);
|
||||
|
@ -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<HTMLInputElement>(null);
|
||||
const { modalFunctions } = useModalFunctions();
|
||||
const { setContents } = useCommands();
|
||||
@ -64,9 +64,20 @@ const Home: NextPage = () => {
|
||||
</span>
|
||||
</a><span className={styles.spacer} onClick={focusInput}> </span>
|
||||
</div>
|
||||
<REPL inputRef={inputRef} />
|
||||
<REPL inputRef={inputRef} buildTime={buildTime} />
|
||||
</div>
|
||||
</main>);
|
||||
};
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user