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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling import of theme configuration #8131

Merged
merged 7 commits into from May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/_docs/configuration/options.md
Expand Up @@ -72,6 +72,24 @@ class="flag">flags</code> (specified on the command-line) that control them.
<p><code class="flag">--disable-disk-cache</code></p>
</td>
</tr>
<tr class="setting">
<td>
<p class="name">
<strong>Ignore theme configuration</strong>
<span class="version-badge" title="Introduced in v4.1.0">4.1.0</span>
</p>
<p class="description">
Jekyll 4.0 started allowing themes to bundle a <code>_config.yml</code>
to simplify theme-onboarding for new users.
In the unfortunate situation that importing a bundled theme configuration
messes up the merged site-configuration, the user can configure Jekyll
to not import the theme-config entirely.
</p>
</td>
<td class="align-center">
<p><code class="option">ignore_theme_config: BOOL</code></p>
</td>
</tr>
<tr class="setting">
<td>
<p class="name"><strong>Exclude</strong></p>
Expand Down
7 changes: 5 additions & 2 deletions features/theme_configuration.feature
Expand Up @@ -3,8 +3,11 @@ Feature: Bundling Config file with Theme gems
I want to be able to pre-configure my gemified theme
In order to make it easier for other Jekyllites to use my theme

Scenario: Easy onboarding with a pre-configured theme
Given I have a configuration file with "theme" set to "test-theme"
Scenario: Enabling import of theme configuration
Given I have a configuration file with:
| key | value |
| theme | test-theme |
| import_theme_config | true |
ashmaroli marked this conversation as resolved.
Show resolved Hide resolved
And I have an "index.md" page that contains "{{ site.test_theme.skin }}"
When I run jekyll build
Then I should get a zero exit status
Expand Down
2 changes: 2 additions & 0 deletions lib/jekyll/site.rb
Expand Up @@ -432,6 +432,8 @@ def collections_path
private

def load_theme_configuration(config)
return config unless config["import_theme_config"] == true
ashmaroli marked this conversation as resolved.
Show resolved Hide resolved

theme_config_file = in_theme_dir("_config.yml")
return config unless File.exist?(theme_config_file)

Expand Down
6 changes: 1 addition & 5 deletions test/test_site.rb
Expand Up @@ -595,11 +595,7 @@ def convert(*_args)

should "set a theme if the config is a string" do
[:debug, :info, :warn, :error].each do |level|
if level == :info
expect(Jekyll.logger.writer).to receive(level)
else
expect(Jekyll.logger.writer).not_to receive(level)
end
expect(Jekyll.logger.writer).not_to receive(level)
end
site = fixture_site("theme" => "test-theme")
assert_instance_of Jekyll::Theme, site.theme
Expand Down