forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.data.mjs
35 lines (27 loc) · 1.09 KB
/
next.data.mjs
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
import {
generateBlogYearPages,
generateWebsiteFeeds,
} from './scripts/next-data/generatePreBuildFiles.mjs';
import getLocalisationData from './scripts/next-data/getLocalisationData.mjs';
import getNodeVersionData from './scripts/next-data/getNodeVersionData.mjs';
import getBlogData from './scripts/next-data/getBlogData.mjs';
const cachedNodeVersionData = getNodeVersionData();
const cachedLocalisationData = getLocalisationData();
const cachedBlogData = getBlogData();
// generates pre-build files for blog year pages (pagination)
generateBlogYearPages(cachedBlogData);
generateWebsiteFeeds(cachedBlogData);
const getNextData = async (content, { route }) => {
const localisationData = await cachedLocalisationData(route);
const nodeVersionData = await cachedNodeVersionData(route);
const blogData = await cachedBlogData(route);
const props = { ...localisationData, ...nodeVersionData, ...blogData };
return `
// add the mdx file content
${content}
export const getStaticProps = () => {
return { props: ${JSON.stringify(props)} };
}
`;
};
export default getNextData;