getStaticPaths
方法:
export const getStaticPaths: GetStaticPaths = async () => {
let ed = await fetch(`${baseURL}getEvents2`, {
method: "post",
});
let events = await ed.json();
const paths = ["hu", "en"].flatMap((lang) =>
events.map((eventId) => ({
params: { lang: lang, eventId: eventId },
}))
);
return {
paths,
fallback: true,
};
};
getStaticProps
:
export const getStaticProps: GetStaticProps = async ({ ...context }) => {
console.log(context);
}
console.log
输出:
我想在上下文中以某种方式查看 lang。我怎么能做到这一点?