1
0
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:
Daniel Barber 2018-01-25 17:56:43 -05:00
parent c2ba253e37
commit c01dc2df7c
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 21 additions and 18 deletions

View File

@ -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
View 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