Instead of a sleep hack, just use a Jekyll hook! 😄
This commit is contained in:
parent
b108f4c87e
commit
8b2a35dc50
|
@ -12,11 +12,11 @@ namespace :site do
|
||||||
require "launchy"
|
require "launchy"
|
||||||
require "jekyll"
|
require "jekyll"
|
||||||
|
|
||||||
# Yep, it's a hack! Wait a few seconds for the Jekyll site to generate and
|
browser_launched = false
|
||||||
# then open it in a browser. Someday we can do better than this, I hope.
|
Jekyll::Hooks.register :site, :post_write do |site|
|
||||||
Thread.new do
|
next if browser_launched
|
||||||
sleep 4
|
browser_launched = true
|
||||||
puts "Opening in browser..."
|
Jekyll.logger.info "Opening in browser..."
|
||||||
Launchy.open("http://localhost:4000")
|
Launchy.open("http://localhost:4000")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace :site do
|
||||||
task :generate => :generated_pages do
|
task :generate => :generated_pages do
|
||||||
require "jekyll"
|
require "jekyll"
|
||||||
Jekyll::Commands::Build.process({
|
Jekyll::Commands::Build.process({
|
||||||
"profile" => true,
|
"profile" => true,
|
||||||
"source" => File.expand_path(docs_folder),
|
"source" => File.expand_path(docs_folder),
|
||||||
"destination" => File.expand_path("#{docs_folder}/_site")
|
"destination" => File.expand_path("#{docs_folder}/_site")
|
||||||
})
|
})
|
||||||
|
@ -54,14 +54,8 @@ namespace :site do
|
||||||
|
|
||||||
desc "Generate generated pages and publish to GitHub Pages"
|
desc "Generate generated pages and publish to GitHub Pages"
|
||||||
task :publish => :generated_pages do
|
task :publish => :generated_pages do
|
||||||
puts "Committing and pushing to GitHub Pages..."
|
puts "GitHub Pages now compiles our docs site on every push to the `master` branch. Cool, huh?"
|
||||||
sha = `git rev-parse HEAD`.strip
|
exit 1
|
||||||
Dir.chdir('gh-pages') do
|
|
||||||
sh "git add docs/"
|
|
||||||
sh "git commit --allow-empty -m 'Generating pages for #{sha}.'"
|
|
||||||
sh "git push origin master"
|
|
||||||
end
|
|
||||||
puts 'Done.'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Create a nicely formatted history page for the jekyll site based on the repo history."
|
desc "Create a nicely formatted history page for the jekyll site based on the repo history."
|
||||||
|
|
Loading…
Reference in New Issue