-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Accept CMS config in multiple formats #386
Comments
I think #348 might have solved this. JSON is an acceptable format |
probably worth testing the resulting json to make sure it works. I think #348 was already merged before I got this report. |
Change Build command: |
Currently the CMS config only works in yaml, but we may as well support any other data format that we can handle (currently yaml, json, and toml). |
@erquhart I'm with supporting all the formats, but the main problem is knowing what config filename to fetch. Right now we only fetch |
This will be much easier after #1132. |
@erquhart @tech4him1 I'm happy to give this a go via Just checking that this issue is still open, and no one is actively working on it? |
@schalkventer It's yours (sorry for the delay in getting back to you)! |
@schalkventer actually, this issue is focused on multiple data formats, eg. json, toml, etc. What you're trying to do can already be done via injecting config during initialization: https://www.netlifycms.org/docs/beta-features/#manual-initialization I've also thought about having a straight js config file as an option, but it's a bit bigger than this issue. |
@erquhart, yeah I realised this after posting the above. 👍 Regardless I'm happy attempting this none-the-less. Where can I learn a bit more about how data is loaded into Netlify CMS? Or would it take some reverse engineering? |
After considering this a bit more, I remembered that manual initialization is the only way to do this. Without manual initialization, the CMS auto bootstraps, so loading the config is always a race condition. Have you tried JS config via manual init yet? Interested to hear if there are any downsides. |
@erquhart, by manual init do you mean via |
Yeah that's the one. So the way you do JavaScript config, in case you haven't tried it: import { init } from 'netlify-cms'
init({
config: {
backend: {
name: 'test-repo',
},
},
}) It's overwritten by The reason we can't pull in a You could also approximate what you're looking for by creating a Let me know if you have any further thoughts! |
Yup. Unfortunately only realized this after my initial comment in this issue. However, I'm happy to attempt to add |
Resolving this issue should entail config support for all of the formats that Netlify CMS can parse, which is YAML, JSON, and TOML. Technically JSON is already supported, as YAML is a superset of JSON (so valid JSON is always valid YAML), but the CMS won't pick up a Most (maybe even all) of the code that currently requires the config file to be YAML is in the As @tech4him1 mentioned, there's the issue of knowing what file to look for. I think it would be fine to just look for config files in order, maybe yaml -> json -> toml. Which is kinda silly if you're using Eventually I expect most config files to be passed in via manual init or pulled from the repo, as static deployed config files won't work with the Configuration UI that is definitely happening at some point, and which I expect most folks will want to use. Whew. All the things. Anyhow, yeah, worth making |
Sorry, this is confusing. If you set it to manual init, the init config you pass is able to be read prior to the loading of the |
Context:
For example: config_path: "config.toml" That ^^ would be ideal, but it can't work currently because Netlify CMS doesn't process any configuration values until all configuration has been registered, and then the final object is used to configure the CMS. I expect that we'll at some point accept partial configuration for cases like this, config driven manual init, or setting just the backend where the actual config source is, which we would then pull through the API and use to configure the CMS. |
But that is where I am getting confused, because we do process the manual init prior to going after the We could just pass a |
True, guess we could just toss in the logic. |
Sorry if I'm missing context here, but lets not forget we have the header value that we can set format on as well. That was part of the original intent for that addition IIRC. #1132 |
@tech4him1 that PR opened the door for custom naming of the config file, and provided a means for specifying a non-yaml format, but didn't include support for actually handling non-yaml formats. By contrast, this issue isn't really concerned with renaming and focuses only on supporting non-yaml formats. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
You can use |
Thank you so much!This solves the problem that I am bothering me for two hours. |
is it possible to have a json config file ? or a js file tht exports json etc... |
- Do you want to request a feature or report a bug?
neither, but, a suggestion for the docs.
- What is the current behavior?
hexo can disable the CMS non-intuitively.
- If the current behavior is a bug, please provide the steps to reproduce.
- What is the expected behavior?
the docs would mention this :)
- Please mention your node.js, and operating system version.
(so really this is about the docs, not cms version)
The text was updated successfully, but these errors were encountered: