export async function getStaticProps({ locale, locales, draftMode }) {
const data = await getPageData(locale, 'home');
const globalProps = await getGlobalData(locale);
console.log(data.published);
if (!data.published && !draftMode) {
return {
notFound: true,
};
}
const props = {
data,
globalProps,
locales,
};
if (draftMode !== undefined) {
props.draftMode = draftMode;
}
return {
props,
revalidate: 1,
};
}
export async function getStaticProps({ params, locale, locales, draftMode }) {
const data = await getPageData(locale, params.slug);
const globalProps = await getGlobalData(locale);
console.log('kek:', data.published, draftMode);
if (!data.published && !draftMode) {
return {
notFound: true,
};
}
const props = {
data,
globalProps,
locales,
};
if (draftMode !== undefined) {
props.draftMode = draftMode;
}
return {
props,
revalidate: 1,
};
}
export async function getStaticPaths({ locales }) {
const paths = await Promise.all(
locales.map(async (locale) => {
const data = await getAllPageIds(locale);
return data
.flatMap((item) => {
if (item.resources) {
return item.resources.map((resource) => ({
params: {
slug: resource.alias,
},
locale,
}));
} else {
return {
params: {
slug: item.alias,
},
locale,
};
}
})
.filter((item) => item.params.slug !== 'home');
}),
);
return {
paths: paths.flat(),
fallback: false,
};
}