From f4b05b567ee11a73ba7a834a0325fc4546bd6a0a Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sun, 12 Aug 2018 09:52:30 -0400 Subject: [PATCH] Limit analytics to production --- Rakefile | 4 +++- _includes/footer.html | 6 +++++- _lib/netlify.rb | 8 +++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index f7918a4..b9b82de 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,9 @@ task default: %w[build] desc "Build the site" task :build do config = Jekyll.configuration({ - url: Netlify.site_url + context: Netlify.context, + production?: Netlify.production?, + url: Netlify.site_url, }) site = Jekyll::Site.new(config) diff --git a/_includes/footer.html b/_includes/footer.html index b707bbf..cc92493 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -28,4 +28,8 @@ } -{% include analytics.html %} + + +{% if site.production? %} + {% include analytics.html %} +{% endif %} diff --git a/_lib/netlify.rb b/_lib/netlify.rb index a56021b..f695121 100644 --- a/_lib/netlify.rb +++ b/_lib/netlify.rb @@ -7,9 +7,11 @@ module Netlify end end - private - def self.production? - ENV["CONTEXT"] == "production" + context == "production" + end + + def self.context + ENV["CONTEXT"] end end