question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuxtjs Documentation cant get it to work

See original GitHub issue

Describe 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 Capture )

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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
brachkowcommented, Jan 19, 2021

Examples from docs still lead to this errors. For myself I resolved this issue via

generate: {
    async routes() {
      const contentPaths = ['docs'];

      const files = [];
      contentPaths.forEach(async (path) => {
        const file = await $content(path).fetch();
        files.push(file);
      });

      const generated = files.map((file) => {
        return {
          route: file.path === '/index' ? '/' : file.path,
          payload: fs.readFileSync(`./content/${file.path}${file.extension}`, 'utf-8'),
        };
      });

      return generated;
    },
  },
1reaction
enricoschaafcommented, Sep 7, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"document is not defined" in Nuxt.js - Stack Overflow
In classic Vue, this would work fine, so I'm very much still getting to grips with how I can get Nuxt.js to work...
Read more >
Installation - Nuxt
To get started quickly, you can use create-nuxt-app . Make sure you have installed yarn, npx (included by default with npm v5.2+) or...
Read more >
Commands and Deployment - Nuxt
You should have these commands in your package.json : "scripts": { "dev": "nuxt", "build": ... Use it for Node.js hosting like Heroku, Digital...
Read more >
Configuration - Nuxt
In case you want to use sass make sure that you have installed the sass and ... more about how to use it...
Read more >
Nuxt configuration file
By omitting the extension, if you have a css file and decide to change to use sass for example, you won't have to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found