Automatically load _config.toml (#7299)

Merge pull request 7299
This commit is contained in:
argv-minus-one 2018-10-05 06:43:06 -07:00 committed by jekyllbot
parent fec13b3d05
commit 052dbf8b98
3 changed files with 15 additions and 4 deletions

View File

@ -4,9 +4,9 @@ permalink: /docs/configuration/
---
Jekyll gives you a lot of flexibility to customize how it builds your site. These
options can either be specified in a `_config.yml` file placed in your sites
root directory, or can be specified as flags for the `jekyll` executable in the
terminal.
options can either be specified in a `_config.yml` or `_config.toml` file placed
in your sites root directory, or can be specified as flags for the `jekyll`
executable in the terminal.
* [Configuration Options](/docs/configuration/options/)
* [Default Configuration](/docs/configuration/default/)

View File

@ -154,7 +154,7 @@ module Jekyll
# Get configuration from <source>/_config.yml or <source>/<config_file>
config_files = override["config"]
if config_files.to_s.empty?
default = %w(yml yaml).find(-> { "yml" }) do |ext|
default = %w(yml yaml toml).find(-> { "yml" }) do |ext|
File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}"))
end
config_files = Jekyll.sanitized_path(source(override), "_config.#{default}")

View File

@ -143,6 +143,17 @@ class TestConfiguration < JekyllUnitTest
allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(true)
assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
end
should "return .toml if that exists" do
allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(false)
allow(File).to receive(:exist?).with(source_dir("_config.yaml")).and_return(false)
allow(File).to receive(:exist?).with(source_dir("_config.toml")).and_return(true)
assert_equal [source_dir("_config.toml")], @config.config_files(@no_override)
end
should "return .yml if both .yml and .toml exist" do
allow(File).to receive(:exist?).with(source_dir("_config.yml")).and_return(true)
allow(File).to receive(:exist?).with(source_dir("_config.toml")).and_return(true)
assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
end
should "return the config if given one config file" do
assert_equal %w(config.yml), @config.config_files(@one_config_file)
end