import HomePage from "../components/home-page";
import IDBlock from "../components/identity-block";
import WCard from "../components/werefox-card";
import PBlock from "../components/page-block";

// An object listing pages folks can visit
export async function getStaticProps() {
  const fs = require("fs");
  const yaml = require("js-yaml");
  let IDENTITIES = {};
  let PAGES = {};
  let PARTNERS = {};

  try {
    let fileContent = fs.readFileSync("./data/identities.yml", "utf8");
    IDENTITIES = yaml.load(fileContent);
    fileContent = fs.readFileSync("./data/pages.yml", "utf8");
    PAGES = yaml.load(fileContent);
    fileContent = fs.readFileSync("./data/partners.yml", "utf8");
    PARTNERS = yaml.load(fileContent);
  } catch (e) {
    console.log(e);
  }
  return {
    props: {
      IDENTITIES,
      PAGES,
      PARTNERS,
    },
  };
}

export default function Home({ IDENTITIES, PAGES, PARTNERS }) {
  const partnerslen = PARTNERS ? Object.keys(PARTNERS).length : 0;
  return (
    <HomePage page_title="About A Werefox" card_title="Hi! I'm Alexis Werefox!">
      <WCard innerText="Basic Info">
        <IDBlock identities={IDENTITIES} partners={partnerslen}/>
      </WCard>
      <WCard innerText="Welcome to my little info site!">
        <p className="p-4 text-lg text-center text-werefox-blue-dark dark:text-werefox-blue">
          I'd describe myself as somewhere between a hot date and a hot mess.
          Just a witchy foxxo programmer trying to make it in the world tbh.
        </p>
        <p className="pl-4 pr-4 pb-4 text-lg text-center text-werefox-blue-dark dark:text-werefox-blue">
          Feel free to click/tap any of the cute buttons above this to learn
          more about my different aspects of personality.
        </p>
        <p className="pl-4 pr-4 pb-4 text-lg text-center text-werefox-blue-dark dark:text-werefox-blue">
          Down below, I've got some more neat little pages and useful info you
          can look at.
        </p>
        <p className="pl-4 pr-4 pb-4 text-lg text-center text-werefox-blue-dark dark:text-werefox-blue">
          Please do look around and enjoy your stay!~ 💙
        </p>
      </WCard>
      <WCard innerText="Neat Pages!">
        <PBlock pages={PAGES} />
      </WCard>
    </HomePage>
  );
}
