Skip to content

Commit

Permalink
feat(config): allow config.yml file load to be skipped (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
talves authored and erquhart committed Feb 3, 2019
1 parent 22e047e commit 14f94a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/netlify-cms-core/src/actions/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ export function loadConfig() {
try {
const preloadedConfig = getState().config;
const configUrl = getConfigUrl();
const loadedConfig = await getConfig(configUrl, preloadedConfig && preloadedConfig.size > 1);
const loadedConfig =
preloadedConfig && preloadedConfig.get('load_config_file') === false
? {}
: await getConfig(configUrl, preloadedConfig && preloadedConfig.size > 1);

/**
* Merge any existing configuration so the result can be validated.
Expand Down
29 changes: 29 additions & 0 deletions website/content/docs/beta-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,35 @@ init({
},
})

/**
* Optionally pass in a complete config object and set a flag
* (`load_config_file: false`) to ignore the `config.yml`.
*
* For example, the code below contains a complete config. The
* `config.yml` will be ignored when setting `load_config_file` to false.
* It is not required if the `config.yml` file is missing to set
* `load_config_file`, but will improve performance and avoid a load error.
*/

init({
config: {
backend: {
name: 'git-gateway',
},
load_config_file: false,
media_folder: "static/images/uploads",
public_folder: "/images/uploads",
collections: [
{ label: "Blog", name: "blog", folder: "_posts/blog", create: true, fields: [
{ label: "Title", name: "title", widget: "string" },
{ label: "Publish Date", name: "date", widget: "datetime" },
{ label: "Featured Image", name: "thumbnail", widget: "image" },
{ label: "Body", name: "body", widget: "markdown" },
]},
],
},
})

// The registry works as expected, and can be used before or after init.
CMS.registerPreviewTemplate(...);
```
Expand Down

0 comments on commit 14f94a0

Please sign in to comment.