mirror of
https://github.com/danbee/danbarber.me
synced 2025-03-04 08:59:10 +00:00
Move the Netlify env stuff into a library
This commit is contained in:
parent
c2ba253e37
commit
c01dc2df7c
24
Rakefile
24
Rakefile
@ -1,27 +1,15 @@
|
||||
# Including only the changed build task
|
||||
require 'jekyll'
|
||||
require "jekyll"
|
||||
require "./_lib/netlify"
|
||||
|
||||
task default: %w[build]
|
||||
|
||||
desc "Build the site"
|
||||
task :build do
|
||||
config = Jekyll.configuration(config_params)
|
||||
config = Jekyll.configuration({
|
||||
url: Netlify.site_url
|
||||
})
|
||||
site = Jekyll::Site.new(config)
|
||||
|
||||
Jekyll::Commands::Build.build(site, config)
|
||||
end
|
||||
|
||||
def config_params
|
||||
{ url: site_url }
|
||||
end
|
||||
|
||||
def site_url
|
||||
if production?
|
||||
ENV["URL"]
|
||||
else
|
||||
ENV["DEPLOY_URL"]
|
||||
end
|
||||
end
|
||||
|
||||
def production?
|
||||
ENV["CONTEXT"] == "production"
|
||||
end
|
||||
|
||||
15
_lib/netlify.rb
Normal file
15
_lib/netlify.rb
Normal file
@ -0,0 +1,15 @@
|
||||
module Netlify
|
||||
def self.site_url
|
||||
if production?
|
||||
ENV["URL"]
|
||||
else
|
||||
ENV["DEPLOY_URL"]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.production?
|
||||
ENV["CONTEXT"] == "production"
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user