-
-
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
Allow for un-captured route of config.yml #1182
Conversation
Deploy preview for netlify-cms-www ready! Built with commit 82e450c |
Deploy preview for cms-demo ready! Built with commit 82e450c |
@erquhart This works, but was not sure if I needed to actually parse the empty string config: |
src/actions/config.js
Outdated
if (!preloadedConfig && !requestSuccess) { | ||
throw new Error(`Failed to load config.yml (${ response.status })`); | ||
if (!preloadedConfig && !fetchedConfig) { | ||
throw new Error(`Failed to load configuration.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in error message is to open up to the config no longer being "config.yml" with the understanding that a failed request will already generate a message in the console.
Added a commit for that, can you test against your setup? |
The latest commit was what I was proposing to combine the checking of the validity of a yaml download and returning a config based on whether there was a valid file existing and if the preloaded configuration actually exists. This would also allow for a reload of a configuration later using a different action in the case we end up using dynamic configuration loading. It will also allow for dynamic file path locations to the yaml.
|
throw new Error(`Failed to load config.yml (${ response.status })`); | ||
} | ||
const contentType = response.headers.get('Content-Type') || 'Not-Found'; | ||
const isYaml = contentType.indexOf('yaml') !== -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are different type strings for yaml that can exist, so this should allow for each. After some thought, I think we can allow for an external location later as long as it returns a valid header type for yaml, it should be accepted. Later we could allow for a preloaded path in the preloaded config that could supply the location of the file.
} | ||
|
||
const loadedConfig = parseConfig(requestSuccess ? await response.text() : ''); | ||
const loadedConfig = await getConfig('config.yml', preloadedConfig && preloadedConfig.size > 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In testing, preloadedConfig has an iterable object map with one key isFetching
if the preload did not have a JSON preload using init()
.
a4f9b08
to
dcb3676
Compare
dcb3676
to
82e450c
Compare
This fixes if there was an invalid route to the
config.yml
because it did not exist and it was handled without a 404.Delete this branch when merged.