Skip to content

Commit

Permalink
abstract site directory to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter authored and parkr committed Nov 2, 2016
1 parent 16217b2 commit 3eedfd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 27,10 @@ def docs_name
"#{name}-docs"
end

def docs_folder
"site"
end

def gemspec_file
"#{name}.gemspec"
end
Expand Down Expand Up @@ -102,7 106,7 @@ def siteify_file(file, overrides_front_matter = {})
"note" => "This file is autogenerated. Edit /#{file} instead."
}.merge(overrides_front_matter)
contents = "#{front_matter.to_yaml}---\n\n#{content_for(file)}"
File.write("site/_docs/#{slug}.md", contents)
File.write("#{docs_folder}/_docs/#{slug}.md", contents)
end

def content_for(file)
Expand Down
14 changes: 7 additions & 7 deletions rake/site.rake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 23,8 @@ namespace :site do
# Generate the site in server mode.
puts "Running Jekyll..."
options = {
"source" => File.expand_path("site"),
"destination" => File.expand_path("site/_site"),
"source" => File.expand_path(docs_folder),
"destination" => File.expand_path("#{docs_folder}/_site"),
"watch" => true,
"serving" => true
}
Expand All @@ -37,15 37,15 @@ namespace :site do
require "jekyll"
Jekyll::Commands::Build.process({
"profile" => true,
"source" => File.expand_path("site"),
"destination" => File.expand_path("site/_site")
"source" => File.expand_path(docs_folder),
"destination" => File.expand_path("#{docs_folder}/_site")
})
end
task :build => :generate

desc "Update normalize.css library to the latest version and minify"
task :update_normalize_css do
Dir.chdir("site/_sass") do
Dir.chdir("#{docs_folder}/_sass") do
sh 'curl "http://necolas.github.io/normalize.css/latest/normalize.css" -o "normalize.scss"'
sh 'sass "normalize.scss":"_normalize.scss" --style compressed'
rm ['normalize.scss', Dir.glob('*.map')].flatten
Expand Down Expand Up @@ -84,7 84,7 @@ namespace :site do
ENV['JEKYLL_ENV'] = 'production'
require "jekyll"
Jekyll::Commands::Build.process({
"source" => File.expand_path("site"),
"source" => File.expand_path(docs_folder),
"destination" => File.expand_path("gh-pages"),
"sass" => { "style" => "compressed" }
})
Expand Down Expand Up @@ -132,7 132,7 @@ namespace :site do
raise "Specify a version: rake site:releases:new['1.2.3']" unless args.version
today = Time.new.strftime('%Y-%m-%d')
release = args.version.to_s
filename = "site/_posts/#{today}-jekyll-#{release.split('.').join('-')}-released.markdown"
filename = "#{docs_folder}/_posts/#{today}-jekyll-#{release.split('.').join('-')}-released.markdown"

File.open(filename, "wb") do |post|
post.puts("---")
Expand Down

0 comments on commit 3eedfd8

Please sign in to comment.