-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.tsx
38 lines (36 loc) · 1.16 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
import type { NextPage } from "next";
import { CONSTANTS } from "../services/config/app-config";
import MetaTag from "../services/api/general_apis/meta-tag-api";
import Header from "../components/Header/Header";
import HomepageMaster from "../components/HomepageMaster";
const Home: NextPage = ({ meta_data }: any) => {
return (
<>
{CONSTANTS.ENABLE_META_TAGS && <Header meta_data={meta_data} />}
<div>
<HomepageMaster />
</div>
</>
);
};
export async function getServerSideProps(context: any) {
const method = "get_meta_tags";
const version = "v1";
const entity = "seo";
const params = `?version=${version}&method=${method}&entity=${entity}`;
const url = `${context.resolvedUrl.split("?")[0]}`;
console.log("context url", context.resolvedUrl);
if (CONSTANTS.ENABLE_META_TAGS) {
let meta_data: any = await MetaTag(
`${CONSTANTS.API_BASE_URL}${CONSTANTS.API_MANDATE_PARAMS}${params}&page_name=${url}`
);
if (meta_data !== null && Object.keys(meta_data).length > 0) {
return { props: { meta_data } };
} else {
return { props: {} };
}
} else {
return { props: {} };
}
}
export default Home;