Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config merging broken if array #399

Closed
mathieutu opened this issue Aug 19, 2020 · 2 comments · Fixed by #408
Closed

Config merging broken if array #399

mathieutu opened this issue Aug 19, 2020 · 2 comments · Fixed by #408
Labels
bug Something isn't working

Comments

@mathieutu
Copy link
Contributor

Version

@nuxt/content: v1.6.1
nuxt: v2.14.3

Steps to reproduce

Use an array as config in content.

Exemple:

content: {
    markdown: {
      remarkExternalLinks:
        content: [
            { type: 'text', value: '1st' },
			{ type: 'text', value: '2nd' }
        ],
      }
    }
  },

What is Expected?

The array should be passed as it to the plugin options.

{
	"name":"remark-external-links",
	"options":{
		"content": [
			{"type":"text","value":"1st"},
			{"type":"text","value":"2nd"}
		]
	}
}

What is actually happening?

The array is converted to an object.

{
	"name":"remark-external-links",
	"options":{
		"content":{
			"0":{"type":"text","value":"1st"},
			"1":{"type":"text","value":"2nd"}
		}
	}
}

Everything happens in the lib/utils.js file.
In the second iteration the array is recursively passed to the mergedConfig function, and is converted to an object by the reduce.

Thanks for your work.

@mathieutu mathieutu added the bug Something isn't working label Aug 19, 2020
@mathieutu
Copy link
Contributor Author

For the record, you can't use a function in this case too, because of the typeof value === 'function' && defaultValue condition. 

@benjamincanac benjamincanac linked a pull request Aug 24, 2020 that will close this issue
6 tasks
@benjamincanac
Copy link
Member

@mathieutu Would you mind trying #408 to ensure it solves your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants