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.
 
 

43 line
1.1 KiB

  1. import React from 'react';
  2. import Navbar from "@/components/_App/NavbarYamaha";
  3. import Footer from "@/components/_App/FooterYamaha";
  4. import PageBanner from '@/components/Common/PageBanner';
  5. import LatestNews from '@/components/Yamaha/LatestNews/LatestNews';
  6. import GetLatestNews from "api/latest_news/news.js"
  7. const News = function ({ backend, news, othernews, ...props }) {
  8. return (
  9. <>
  10. <Navbar />
  11. <PageBanner pageTitle="Latest News" />
  12. <LatestNews news={news} othernews={othernews} backend={backend} />
  13. <Footer />
  14. </>
  15. )
  16. }
  17. export default News;
  18. export async function getServerSideProps(context) {
  19. var news = [];
  20. var othernews = [];
  21. const backend = process.env.BACKEND_SERVER_URI;
  22. var res = await GetLatestNews.GetNewsYamaha();
  23. if (res["STATUS"] === 1) {
  24. news = res["DATA"]["latestNews"];
  25. }
  26. var res = await GetLatestNews.GetOtherNewsYamaha();
  27. if (res["STATUS"] === 1) {
  28. othernews = res["DATA"]["latestNews"];
  29. }
  30. return {
  31. props: { news, othernews, backend }, // will be passed to the page component as props
  32. };
  33. }