From f81ef9cf579c77aaea94cf684d08f67b82593981 Mon Sep 17 00:00:00 2001 From: jefry Date: Fri, 26 Feb 2021 16:48:51 +0700 Subject: [PATCH] fast --- next.config.js | 9 +++-- pages/_app.js | 24 ++----------- pages/home.js | 72 ++++++++++++++++++++++----------------- pages/product.js | 101 ++++++++++++++++++++++++++++++++++++------------------- 4 files changed, 116 insertions(+), 90 deletions(-) diff --git a/next.config.js b/next.config.js index 532318a..aa6cd85 100644 --- a/next.config.js +++ b/next.config.js @@ -3,16 +3,19 @@ const withImages = require("next-images"); const withSass = require("@zeit/next-sass"); const webpack = require("webpack"); const path = require("path"); -const withCSS = require('@zeit/next-css'); +// const withCSS = require("@zeit/next-css"); // require("dotenv").config(); -module.exports = withPlugins([[withSass], [withImages], [withCSS]], { +module.exports = withPlugins([[withSass], [withImages]], { // env: { // API_URL: process.env.API_URL, // }, trailingSlash: true, - webpack(config, options) { + webpack(config, { dev }) { + if (dev) { + config.devtool = "cheap-module-source-map"; + } config.resolve.modules.push(path.resolve("./")); return config; }, diff --git a/pages/_app.js b/pages/_app.js index 2f9d802..79a21dc 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -24,8 +24,8 @@ import Router from "next/router"; import PageChange from "components/PageChange/PageChange.js"; import "assets/scss/nextjs-material-kit.scss?v=1.1.0"; - -Router.events.on("routeChangeStart", url => { +// import styles from "assets/jss/nextjs-material-kit/pages/components.js"; +Router.events.on("routeChangeStart", (url) => { console.log(`Loading: ${url}`); document.body.classList.add("body-page-transition"); ReactDOM.render( @@ -43,26 +43,6 @@ Router.events.on("routeChangeError", () => { }); export default class MyApp extends App { - componentDidMount() { - let comment = document.createComment(` - -========================================================= -* NextJS Material Kit v1.1.0 based on Material Kit Free - v2.0.2 (Bootstrap 4.0.0 Final Edition) and Material Kit React v1.8.0 -========================================================= - -* Product Page: https://www.creative-tim.com/product/nextjs-material-kit -* Copyright 2020 Creative Tim (https://www.creative-tim.com) -* Licensed under MIT (https://github.com/creativetimofficial/nextjs-material-kit/blob/master/LICENSE.md) - -* Coded by Creative Tim - -========================================================= - -* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -`); - document.insertBefore(comment, document.documentElement); - } static async getInitialProps({ Component, router, ctx }) { let pageProps = {}; diff --git a/pages/home.js b/pages/home.js index 08c12a3..54e3421 100644 --- a/pages/home.js +++ b/pages/home.js @@ -16,35 +16,44 @@ import Parallax from "components/Parallax/Parallax.js"; import styles from "assets/jss/nextjs-material-kit/pages/components.js"; import Button from "components/CustomButtons/Button.js"; -import GetbusinessPartners from "../api/home/businessPartner.js" -import Getservices from "../api/home/service.js" -import Getcarousels from "../api/home/carousel.js" +import GetbusinessPartners from "../api/home/businessPartner.js"; +import Getservices from "../api/home/service.js"; +import Getcarousels from "../api/home/carousel.js"; import DataSnackbarContent from "../pages-sections/snackbar.js"; import DataCarousel from "../pages-sections/home/carousel.js"; import DataService from "../pages-sections/home/service.js"; import DataBusinessPartner from "../pages-sections/home/business_partner.js"; -import CoreValue from "../pages-sections/home/core_value.js" +import CoreValue from "../pages-sections/home/core_value.js"; const useStyles = makeStyles(styles); -const Home = function ({ backend, businessPartners, service, carousel, ...props }) { +const Home = function ({ + backend, + businessPartners, + service, + carousel, + ...props +}) { const classes = useStyles(); const { ...rest } = props; - + ; return (
} + rightLinks={} fixed color="info" changeColorOnScroll={{ height: 400, - color: "white" + color: "white", }} {...rest} /> - +
{/* @@ -69,39 +78,42 @@ const Home = function ({ backend, businessPartners, service, carousel, ...props
- - - + + +
); -} +}; export async function getServerSideProps(context) { - var businessPartners = []; - var service = []; + var businessPartners = []; + var service = []; var carousel = []; const backend = process.env.BACKEND_SERVER_URI; - var res = await GetbusinessPartners.GetbusinessPartners(); - if (res["STATUS"] === 1) { - businessPartners = res["DATA"]["businessPartners"]; - } + var res = await GetbusinessPartners.GetbusinessPartners(); + if (res["STATUS"] === 1) { + businessPartners = res["DATA"]["businessPartners"]; + } - var res = await Getservices.Getservices(); - if (res["STATUS"] === 1) { - service = res["DATA"]["services"]; - } + var res = await Getservices.Getservices(); + if (res["STATUS"] === 1) { + service = res["DATA"]["services"]; + } var res = await Getcarousels.GetCarousels(); - if (res["STATUS"] === 1) { - carousel = res["DATA"]["carousels"]; - } + if (res["STATUS"] === 1) { + carousel = res["DATA"]["carousels"]; + } - return { - props: { businessPartners, service, carousel, backend }, // will be passed to the page component as props - }; + return { + props: { businessPartners, service, carousel, backend }, // will be passed to the page component as props + }; } -export default Home; \ No newline at end of file +export default Home; diff --git a/pages/product.js b/pages/product.js index dac13dc..21e8a41 100644 --- a/pages/product.js +++ b/pages/product.js @@ -16,22 +16,33 @@ import DataProduct from "pages-sections/product/product.js"; import Parallax from "components/Parallax/Parallax.js"; import styles from "assets/jss/nextjs-material-kit/pages/components.js"; -import Getproduct from "../api/product/product.js" +import Getproduct from "../api/product/product.js"; const useStyles = makeStyles(styles); -const Product = function ({ backend, yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, ...props }) { +const Product = function ({ + backend, + yamaha, + suzuki, + honda, + hino, + mercedes, + bpr, + emilia, + homes, + ...props +}) { const classes = useStyles(); const { ...rest } = props; return (
} + rightLinks={} fixed color="info" changeColorOnScroll={{ height: 400, - color: "white" + color: "white", }} {...rest} /> @@ -50,12 +61,22 @@ const Product = function ({ backend, yamaha, suzuki, honda, hino, mercedes, bpr,
- +
); -} +}; export default Product; @@ -70,47 +91,57 @@ export async function getServerSideProps(context) { var homes = []; const backend = process.env.BACKEND_SERVER_URI; - var res = await Getproduct.GetProductYamaha(); - if (res["STATUS"] === 1) { - yamaha = res["DATA"]["products"]; - } + var res = await Getproduct.GetProductYamaha(); + if (res["STATUS"] === 1) { + yamaha = res["DATA"]["products"]; + } var res = await Getproduct.GetProductSuzuki(); - if (res["STATUS"] === 1) { - suzuki = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + suzuki = res["DATA"]["products"]; + } var res = await Getproduct.GetProductHonda(); - if (res["STATUS"] === 1) { - honda = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + honda = res["DATA"]["products"]; + } var res = await Getproduct.GetProductHino(); - if (res["STATUS"] === 1) { - hino = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + hino = res["DATA"]["products"]; + } var res = await Getproduct.GetProductMercedes(); - if (res["STATUS"] === 1) { - mercedes = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + mercedes = res["DATA"]["products"]; + } var res = await Getproduct.GetProductBPR(); - if (res["STATUS"] === 1) { - bpr = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + bpr = res["DATA"]["products"]; + } var res = await Getproduct.GetProductEmilia(); - if (res["STATUS"] === 1) { - emilia = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + emilia = res["DATA"]["products"]; + } var res = await Getproduct.GetProductHomes(); - if (res["STATUS"] === 1) { - homes = res["DATA"]["products"]; - } + if (res["STATUS"] === 1) { + homes = res["DATA"]["products"]; + } - return { - props: { yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, backend }, // will be passed to the page component as props - }; -} \ No newline at end of file + return { + props: { + yamaha, + suzuki, + honda, + hino, + mercedes, + bpr, + emilia, + homes, + backend, + }, // will be passed to the page component as props + }; +}