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.
48 lines
1.5 KiB
48 lines
1.5 KiB
import axios from "axios";
|
|
import delve from "dlv";
|
|
|
|
import SeoConfig from "../components/seo-config/seo-config";
|
|
|
|
import Layout from "../components/layout/layout";
|
|
import {config} from "../config";
|
|
import {environment} from "../environments/environment";
|
|
|
|
const getPageMetadata = async (path) => {
|
|
try {
|
|
console.log((config.env as any));
|
|
return await axios.get(`${environment.strapiApiUrl}/pages?filters[slug]=${path === '/' ? 'home' : path.slice(1, path.length)}&populate=deep`);
|
|
} catch (e) {
|
|
console.error(e);
|
|
return Promise.resolve({})
|
|
}
|
|
}
|
|
|
|
export const getServerSideProps = async (context) => {
|
|
const path = context.resolvedUrl;
|
|
console.log((config.env as any));
|
|
const menuHeader = await axios.get(`${environment.strapiApiUrl}/menus/1?nested&populate=deep`);
|
|
const menuFooter = await axios.get(`${environment.strapiApiUrl}/menus/2?nested&populate=deep`);
|
|
const page = await getPageMetadata(path);
|
|
return {
|
|
props: {
|
|
menuHeader: delve(menuHeader, 'data.data.attributes.items.data', []),
|
|
menuFooter: delve(menuFooter, 'data.data.attributes.items.data', []),
|
|
page: delve(page, "data.data.0.attributes", {}),
|
|
seo: delve(page, "data.data.0.attributes.seo", {})
|
|
}
|
|
}
|
|
}
|
|
|
|
export function Index({menuHeader, menuFooter, page, seo}) {
|
|
return (
|
|
<>
|
|
<SeoConfig {...seo}/>
|
|
<Layout menuHeader={menuHeader} menuFooter={menuFooter}>
|
|
<p>Page d'accueil</p>
|
|
</Layout>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default Index;
|