Docs(nuxt): Do not slice the first two chars of the file name (#3152)

This commit is contained in:
Rouven Bühlmann 2020-01-28 06:45:53 +01:00 committed by Erez Rokah
parent a3646edf52
commit a9b350d988

View File

@ -247,9 +247,10 @@ export default {
generate: { generate: {
routes: function() { routes: function() {
const fs = require('fs'); const fs = require('fs');
const path = require('path');
return fs.readdirSync('./assets/content/blog').map(file => { return fs.readdirSync('./assets/content/blog').map(file => {
return { return {
route: `/blog/${file.slice(2, -5)}`, // Remove the .json from the end of the filename route: `/blog/${path.parse(file).name}`, // Return the slug
payload: require(`./assets/content/blog/${file}`), payload: require(`./assets/content/blog/${file}`),
}; };
}); });