Module: Jekyll::Shopsavvy::SiteHelpers
- Defined in:
- lib/jekyll/shopsavvy/tags.rb
Overview
Site-level helpers: shared client and cache.
Class Method Summary collapse
Class Method Details
.client_for(context) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jekyll/shopsavvy/tags.rb', line 29 def client_for(context) site = context.registers[:site] site.config["__shopsavvy_client"] ||= begin api_key = ENV["SHOPSAVVY_API_KEY"] || site.config.dig("shopsavvy", "api_key") Client.new(api_key: api_key, cache: (site.config["__shopsavvy_cache"] ||= {})) rescue ArgumentError => e Jekyll.logger.warn("ShopSavvy:", e.) nil end end |