-
-
Notifications
You must be signed in to change notification settings - Fork 482
/
Copy pathindex.tsx
82 lines (72 loc) · 2.82 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* eslint-disable i18next/no-literal-string */
/* eslint-disable react/no-multi-comp */
import classNames from 'classnames';
import { GetServerSideProps, NextPage } from 'next';
import Head from 'next/head';
import useTranslation from 'next-translate/useTranslation';
import styles from './index.module.scss';
import ChapterAndJuzListWrapper from '@/components/chapters/ChapterAndJuzList';
import HomePageHero from '@/components/HomePage/HomePageHero';
import QuranGrowthJourneySection from '@/components/HomePage/QuranGrowthJourneySection';
import RamadanActivitiesSection from '@/components/HomePage/RamadanActivitiesSection';
import NextSeoWrapper from '@/components/NextSeoWrapper';
import BookmarksAndCollectionsSection from '@/components/Verses/BookmarksAndCollectionsSection';
import { getAllChaptersData } from '@/utils/chapter';
import { getLanguageAlternates } from '@/utils/locale';
import { getCanonicalUrl } from '@/utils/navigation';
import { ChaptersResponse } from 'types/ApiResponses';
import ChaptersData from 'types/ChaptersData';
type IndexProps = {
chaptersResponse: ChaptersResponse;
chaptersData: ChaptersData;
country?: string;
};
export const getServerSideProps: GetServerSideProps = async ({ locale, query }) => {
const allChaptersData = await getAllChaptersData(locale);
return {
props: {
country: query.country,
chaptersData: allChaptersData,
chaptersResponse: {
chapters: Object.keys(allChaptersData).map((chapterId) => {
const chapterData = allChaptersData[chapterId];
return { ...chapterData, id: Number(chapterId) };
}),
},
},
};
};
const Index: NextPage<IndexProps> = ({ chaptersResponse: { chapters }, country }): JSX.Element => {
const { t, lang } = useTranslation('home');
return (
<>
<Head>
<link rel="preload" as="image" href="/images/background.jpg" crossOrigin="anonymous" />
</Head>
<NextSeoWrapper
title={t('home:noble-quran')}
url={getCanonicalUrl(lang, '')}
languageAlternates={getLanguageAlternates('')}
/>
<div className={styles.pageContainer}>
<div className={styles.flow}>
{country ? <p>{country}</p> : <p>No country detected</p>}
<HomePageHero />
<div className={classNames(styles.flowItem, styles.fullWidth)}>
<RamadanActivitiesSection />
</div>
<div className={classNames(styles.flowItem, styles.fullWidth)}>
<QuranGrowthJourneySection />
</div>
<div className={classNames(styles.flowItem, styles.fullWidth)}>
<BookmarksAndCollectionsSection isHomepage />
</div>
<div className={styles.flowItem}>
<ChapterAndJuzListWrapper chapters={chapters} />
</div>
</div>
</div>
</>
);
};
export default Index;