Skip to content

Commit 61cdb7a

Browse files
committed
Themes can define configuration data
Themes can define a 'settings.yml' file which will get injected into the root default.html layout YAML Front Matter which can be accessed through the 'page' variable.
1 parent 45b894f commit 61cdb7a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Rakefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ end # task :new_post
3535
desc "Switch between Jekyll-bootstrap themes."
3636
task :switch_theme, :theme do |t, args|
3737
theme_path = File.join(CONFIG['themes'], args.theme)
38+
settings_file = File.join(theme_path, "settings.yml")
39+
non_layout_files = ["settings.yml"]
3840

3941
abort("rake aborted: '#{CONFIG['themes']}/#{args.theme}' directory not found.") unless FileTest.directory?(theme_path)
4042
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])
4143

4244
Dir.glob("#{theme_path}/*") do |filename|
45+
next if non_layout_files.include?(File.basename(filename).downcase)
4346
puts "Generating '#{args.theme}' layout: #{File.basename(filename)}"
4447

4548
open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
4649
if File.basename(filename, ".html").downcase == "default"
4750
page.puts "---"
51+
page.puts File.read(settings_file) if File.exist?(settings_file)
4852
page.puts "---"
4953
page.puts "{% assign theme_asset_path = \"/assets/themes/#{args.theme}\" %}"
5054
else

0 commit comments

Comments
 (0)