index

mail@pastecode.io avatar
unknown
plain_text
2 years ago
932 B
2
Indexable
Never
import Page from "../components/common/Page";
import HomeTemplate from "../components/templates/home";
import getAllPages from "../lib/wordpress/pages/getAllPages";
import pages from "../data/pages/pages.json";
import menus from "../data/global/navigation.json";
import wordpress from "lib/wordpress";

const Home = ({ page }) => {
  return (
    <Page seo={{ title: page.post_title, description: page.description }}>
      <HomeTemplate componentData={page.acf.content} />
    </Page>
  );
};

export default Home;

export async function getStaticProps(context) {
  const url = `${process.env.SITE_CMS_API_URL + process.env.SITE_CMS_API_HOME_PATH}`;
  const res = await wordpress.get(url);
  const page = await res.data;

  //* Example of how to render 404 on static pages
  if (!page) {
    return {
      notFound: true,
    };
  }

  //* This will be passed to the page component as props
  return {
    props: { page },
  };
}