Skip to content

Commit

Permalink
add SSG
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefomar724 committed Jul 16, 2022
1 parent e6265d1 commit b650e8f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 13 deletions.
61 changes: 53 additions & 8 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,60 @@ import IMGFig1 from '../components/img-fig/IMGFig1'
import SyriaNews from '../components/syria-news/SyriaNews'
import IMGFig2 from '../components/img-fig/IMGFig2'
import Footer from '../components/footer/Footer'
import Script from 'next/script'

export default function Home() {
const { data: cityCoinsData } = useSWR('/city-coins.php')
const { data: internationalCoinsData } = useSWR('/international-coins.php')
const { data: centralBankData } = useSWR('/central-bank.php')
const { data: internationalGoldData } = useSWR('/international-gold.php')
const { data: posts } = useSWR('/blog-post.php')
const { data: adsBanners } = useSWR('/ads-banner.php')
export const getStaticProps = async () => {
const [
cityCoinsDataRes,
internationalCoinsDataRes,
centralBankDataRes,
internationalGoldDataRes,
postsRes,
adsBannersRes,
] = await Promise.all([
fetch(`https://syria-exchange.com/panel/v1/api/city-coins.php`),
fetch(`https://syria-exchange.com/panel/v1/api/international-coins.php`),
fetch(`https://syria-exchange.com/panel/v1/api/central-bank.php`),
fetch(`https://syria-exchange.com/panel/v1/api/international-gold.php`),
fetch(`https://syria-exchange.com/panel/v1/api/blog-post.php`),
fetch(`https://syria-exchange.com/panel/v1/api/ads-banner.php`),
])
const [
cityCoinsData,
internationalCoinsData,
centralBankData,
internationalGoldData,
posts,
adsBanners,
] = await Promise.all([
cityCoinsDataRes.json(),
internationalCoinsDataRes.json(),
centralBankDataRes.json(),
internationalGoldDataRes.json(),
postsRes.json(),
adsBannersRes.json(),
])
return {
props: {
cityCoinsData,
internationalCoinsData,
centralBankData,
internationalGoldData,
posts,
adsBanners,
},
revalidate: 1,
}
}

export default function Home(props) {
const {
cityCoinsData,
internationalCoinsData,
centralBankData,
internationalGoldData,
posts,
adsBanners,
} = props
return (
<div>
<Head>
Expand Down
20 changes: 15 additions & 5 deletions pages/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ import ScrollToTop from '../components/ScrollToTop'
import Footer from '../components/footer/Footer'
import Head from 'next/head'

const NewsPage = () => {
const { data: posts } = useSWR('/blog-post.php')

const { t } = useTranslation()

export const getStaticProps = async () => {
const data = await fetch(
'https://syria-exchange.com/panel/v1/api/blog-post.php'
)
const posts = await data.json()
const financialPosts = posts?.blog_post.filter(
(item) => item.post_category === 'نصائح مالية'
)
return {
props: {
financialPosts,
},
revalidate: 1,
}
}

const NewsPage = ({ financialPosts }) => {
const { t } = useTranslation()
return (
<>
<Head>
Expand Down
Binary file added syria-exchange-next.zip
Binary file not shown.

0 comments on commit b650e8f

Please sign in to comment.