import ButtonGrid from "components/ButtonGrid";
import Lanyard from "components/Lanyard";
import Navbar from "components/Navbar";
import getProfiles from "utils/shared/profiles";
import { getAllPostIDs, getPostData,getSortedPosts } from "utils/shared/posts";
import { SocialButton } from "utils/types";
import styles from "styles/Index.module.sass";
import Link from "components/Link";
import Post from "components/Post";
import PostGrid from "components/PostGrid";

export async function getStaticProps() {
  const profiles = await getProfiles();
  const posts = await getSortedPosts();
  
  return {
    props: {
      profiles,
      posts
    },
  };
}

const IndexPage = (props: { profiles: SocialButton[]; posts: Array<any> }) => {
  // console.log(props.posts);
  return (
    <>
      <div className={styles.center}>
        <Navbar />
        <div>
          <p>Profiles</p>
          <ButtonGrid Buttons={props.profiles} />
        </div>
        <div>
          <p>Posts</p>
          <PostGrid posts={props.posts}/>
        </div>
      </div>
      <Lanyard />
    </>
  );
};

export default IndexPage;
