You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Box } from '@mui/system';
  2. import Head from 'next/head';
  3. import CompanyInfo from '../components/company-info/CompanyInfo';
  4. import Features from '../components/features/Features';
  5. import Hero from '../components/hero/Hero';
  6. import FeaturedProductsList from '../components/products/featured-products-list/FeaturedPorductsList';
  7. import { getFeaturedProducts } from '../requests/products/featuredProductsRequest';
  8. const Home = (props) => {
  9. return (
  10. <>
  11. <Box sx={{ width: '100%', height: '100%' }}>
  12. <Head>
  13. <title>NextJS template</title>
  14. <meta name="description" content="Random data with pagination..." />
  15. </Head>
  16. <Hero></Hero>
  17. <FeaturedProductsList
  18. featuredProducts={props.featuredProducts}
  19. ></FeaturedProductsList>
  20. <Features></Features>
  21. <CompanyInfo></CompanyInfo>
  22. </Box>
  23. </>
  24. );
  25. };
  26. export async function getStaticProps() {
  27. try {
  28. const { message, featuredProducts } = await getFeaturedProducts();
  29. return {
  30. props: {
  31. message,
  32. featuredProducts,
  33. },
  34. };
  35. } catch (error) {
  36. return {
  37. props: {
  38. errorMessage: error,
  39. featuredProducts: [],
  40. },
  41. };
  42. }
  43. }
  44. export default Home;