--- regenerate: true --- {% capture cache %} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/data/carousel.json # Liquid JSON template for ALL (Owl Carousel) sliders configured # # Product/Info: # http://jekyll.one # # Copyright (C) 2020 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE # ----------------------------------------------------------------------------- # The Liquid template sliders.json is used by J1 Slider (Owl Carousel). # This template is a helper that creates the carousel (JSON) data # for all sliders configured (if enabled or NOT). It's used by # the J1 Template Adapter to LOAD the carousel HTML markup portion # via AJAX get. # # The Liquid template engine generates a JSON file as an object of # arrays that contains all image data used by several sliders. See # below the fields taken from the YAML data file: # ~/_data/apps/j1_carousel.yml. # ----------------------------------------------------------------------------- # NOTE: # Be careful changing the Liquid code. If the code is changed, check # the integrity of the JSON data created. Corrupted JSON data makes # the Javascript of an Adapter to fail and no functionality will # be available for most UNCLEAR reasons. # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config files -------------------------------------------------------------------------------- {% endcomment %} {% assign apps = site.data.apps %} {% comment %} Set config data -------------------------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign carousel_config_defaults = apps.defaults.carousel.defaults %} {% assign carousel_config_settings = apps.carousel.settings %} {% comment %} Set config options -------------------------------------------------------------------------------- {% endcomment %} {% assign carousel_config = carousel_config_defaults | merge: carousel_config_settings %} {% assign production = false %} {% if environment == 'prod' or environment == 'production' %} {% assign production = true %} {% endif %} { {% for item in carousel_config.carousel %} "{{item.show.id}}" : [ {% if item.show.type == 'image' %} {% for image in item.show.images %} {% assign image_no = forloop.index %} {% capture image_full_path %}{{ item.show.images_path }}/{{ image }}{% endcapture %} { {% if item.show.lightbox %} "lb" : "{{ item.show.lightbox }}", {% for caption in item.show.lb_caption %} {% if forloop.index == image_no %} "lb_caption" : "{{ caption }}", {% endif %} {% endfor %} {% endif %} "img" : "{{ image_full_path }}", "alt" : "Owl Image {{ forloop.index }}"{% if item.show.links %},{% endif %} {% if item.show.links %} {% for link in item.show.links %} {% if forloop.index == image_no %} "href" : "{{ link }}" {% endif %} {% endfor %} {% endif %} }{% if forloop.last %}{% else %},{% endif %} {% endfor %} {% endif %} {% if item.show.type == 'text' %} {% for text in item.show.text %} {% assign txt_no = forloop.index %} { "text" : "{{ text }}"{% if item.show.links %},{% endif %} {% if item.show.links %} {% for link in item.show.links %} {% if forloop.index == txt_no %} "href" : "{{ link }}" {% endif %} {% endfor %} {% endif %} }{% if forloop.last %}{% else %},{% endif %} {% endfor %} {% endif %} ]{% if forloop.last %}{% else %},{% endif %} {% endfor %} } {% endcapture %} {% if production %} {{ cache | minifyJSON }} {% else %} {{ cache | strip_empty_lines }} {% endif %} {% assign cache = nil %}