Nuxtjs Documentation cant get it to work
See original GitHub issueDescribe the bug After following the guide on how to set up nuxtjs + netlify-cms i will get the ERROR Could not resolve routes when running the generate command. Also i get FATAL Invalid left-hand side expression in prefix operation.
To Reproduce
To reproduce you basiclly just have to follow the docs on how to set up nuxt and netlify cms, the error happens to me when i start to add
generate: { routes: function () { const fs = require('fs'); return fs.readdirSync('./assets/content/blog').map(file => { return { route:
/blog/${file.slice(2, -5)}, // Remove the .json from the end of the filename payload: require(
./assets/content/blog/${file}), }; }); }, },
Expected behavior I expected this part of the code to generate the routes for the blog articles
Screenshots
)
Applicable Versions:
- Netlify CMS version: [e.g. 2.0.4]
- Git provider: [GitHub]
- OS: [e.g. Windows 10]
- Browser version [chrome 76.0.3809.132]
- Node.JS version: v12.6.0 >(using NPM)
CMS configuration `backend: name: git-gateway branch: master
media_folder: static/img public_folder: /img
collections:
- name: ‘blog’
label: ‘Blog’
folder: ‘assets/content/blog’
create: true
slug: ‘{{year}}-{{month}}-{{day}}-{{slug}}’
editor:
preview: false
fields:
- { label: ‘Title’, name: ‘title’, widget: ‘string’ }
- { label: ‘Publish Date’, name: ‘date’, widget: ‘datetime’ }
- { label: ‘Description’, name: ‘description’, widget: ‘string’ }
- { label: ‘Body’, name: ‘body’, widget: ‘markdown’ }`
Additional context Full github repository https://github.com/enricoschaaf/github-issue
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Examples from docs still lead to this errors. For myself I resolved this issue via
I closed it because I found the instruction as a template on Twitter by the same user. https://github.com/xdesro/nuxt-netlify-cms-starter Don’t know what I did wrong but this solved it for me. Maybe it could be linked in the docs.