From 1c8bce4a66cab2ab0aee2ba4542a52536a5e46db Mon Sep 17 00:00:00 2001 From: Martin Rubli Date: Tue, 15 Apr 2025 09:29:48 +0200 Subject: [PATCH] layouts: layer: Allow retrieving API key from config The config key name is the layer name with '.' replaced with '_'. For example: params: modules: leaflet: com_thunderforest_outdoors: apiKey: abcdef1234567890abcdef1234567890 If the key is specified in both the config file and the tag attribute, the latter takes precedence. Implements #6 --- layouts/shortcodes/leaflet-layer.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/layouts/shortcodes/leaflet-layer.html b/layouts/shortcodes/leaflet-layer.html index 2a1e8e9..ea4edfb 100644 --- a/layouts/shortcodes/leaflet-layer.html +++ b/layouts/shortcodes/leaflet-layer.html @@ -9,10 +9,12 @@ {{ $uniqueMapId := (printf "%s:%d" .Page.File.UniqueID .Parent.Ordinal) | md5 | safeJS }} {{ $id := .Get "id" }} +{{ $configId := replace (.Get "id") "." "_" }} +{{ $apiKey := default (index .Site.Params.modules.leaflet $configId "apiKey") (.Get "apiKey") }}