Facing problem on Implement getStaticPaths while doing Next.Js tutorial
Unanswered
Leonberger posted this in #help-forum
LeonbergerOP
Turotial required:
Then, open
Code:
export function getAllPostIds() {
const fileNames = fs.readdirSync(postsDirectory);
// Returns an array that looks like this:
// [
// {
// params: {
// id: 'ssg-ssr'
// }
// },
// {
// params: {
// id: 'pre-rendering'
// }
// }
// ]
return fileNames.map((fileName) => {
return {
params: {
id: fileName.replace(/.md$/, ''),
},
};
});
}
I want to know how should I insert the tutorial code? I have try to add this code except the comment code in row 36 but my
Then, open
lib/posts.js and add the following getAllPostIds function at the bottom. It will return the list of file names (excluding .md) in the posts directoryCode:
export function getAllPostIds() {
const fileNames = fs.readdirSync(postsDirectory);
// Returns an array that looks like this:
// [
// {
// params: {
// id: 'ssg-ssr'
// }
// },
// {
// params: {
// id: 'pre-rendering'
// }
// }
// ]
return fileNames.map((fileName) => {
return {
params: {
id: fileName.replace(/.md$/, ''),
},
};
});
}
I want to know how should I insert the tutorial code? I have try to add this code except the comment code in row 36 but my
post directory do not have the output just like comment code in the tutorial.