Skip to content

Commit 48b348b

Browse files
committed
Pass GEOLONIA_API_KEY via custom Jekyll plugin for easy local development
1 parent 12a95c8 commit 48b348b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.github/workflows/deploy_to_pages.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
2727
- name: 🔧 Build & Test
2828
run: |
29-
JEKYLL_ENV=production bundle exec jekyll build
30-
JEKYLL_ENV=production bundle exec jekyll doctor
29+
bundle exec jekyll build
30+
bundle exec jekyll doctor
3131
# SKIP_BUILD=true bundle exec rake test
3232
3333
# This is NOT for security reason but for others, especially who fork,

_plugins/environment_variables.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# GitHub Gist - Environment variables in Jekyll templates
2+
# https://gist.github.com/nicolashery/5756478
3+
4+
# Plugin to add environment variables to the `site` object in Liquid templates
5+
6+
module Jekyll
7+
class EnvironmentVariables < Generator
8+
def generate(site)
9+
site.config['env'] = {}
10+
site.config['env']['GEOLONIA_API_KEY'] = ENV['GEOLONIA_API_KEY'] || 'YOUR-API-KEY'
11+
# Add other environment variables to `site.config` here...
12+
end
13+
end
14+
end

index.html

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
---
3+
14
<!DOCTYPE html>
25
<html lang="ja">
36
<head>
@@ -72,7 +75,11 @@
7275

7376
<script
7477
type="text/javascript"
78+
{% if site.env.GEOLONIA_API_KEY %}
79+
src="https://cdn.geolonia.com/v1/embed?geolonia-api-key={{ site.env.GEOLONIA_API_KEY }}"
80+
{% else %}
7581
src="https://cdn.geolonia.com/v1/embed?geolonia-api-key=YOUR-API-KEY"
82+
{% endif %}
7683
></script>
7784

7885
<!-- Google tag (gtag.js) -->

0 commit comments

Comments
 (0)