{%- comment -%} Section published at https://sections.design/blogs/shopify/faq-rich-snippets-section Get the latest version: https://github.com/mirceapiturca/Sections/tree/master/FAQ {%- endcomment -%} {%- comment -%} ---------------- THE CSS ---------------- {%- endcomment -%} {%- assign id = '#shopify-section-' | append: section.id -%} {% style %} {{ id }} { background: {{ section.settings.background_color }}; --panel-bg: {{ section.settings.panel_color }}; --border-color: {{ section.settings.border_color }}; --question-color: {{ section.settings.q_color }}; --answer-color: {{ section.settings.a_color }}; {%- assign min = section.settings.q_size_small -%} {%- assign max = section.settings.q_size_large -%} {%- assign min_rem = min | append: 'rem' -%} {%- assign max_rem = max | append: 'rem' -%} --title-font-size: clamp({{ min_rem }}, calc({{ min_rem }} + ({{ max }} - {{ min }}) * ((100vw - 25rem) / (64 - 25))), {{ max_rem }}); } {% endstyle %} {%- comment -%} ---------------- THE MARKUP ---------------- {%- endcomment -%}
{%- for block in section.blocks -%} {%- if block.settings.title != blank and block.settings.content != blank -%} {%- if block.settings.checkbox_expanded == true -%} {%- assign expanded = 'true' -%} {%- assign hidden = '' -%} {%- else -%} {%- assign expanded = 'false' -%} {%- assign hidden = 'hidden' -%} {%- endif -%}

{%- endif -%} {%- endfor -%}
{%- comment -%} -------------- THE RICH SCHEMA ------------- {%- endcomment -%} {%- if section.settings.enable_rich_schema -%} {%- endif -%} {%- comment -%} ---------------- THE CONFIG ---------------- {%- endcomment -%} {%- comment -%} ---------------- THE SETTINGS ---------------- {%- endcomment -%} {% schema %} { "name": "FAQ", "class": "sd-faq", "tag": "article", "settings": [ { "type": "header", "content": "Rich schema" }, { "type": "checkbox", "id": "enable_rich_schema", "default": true, "label": "Enable FAQ rich schema?" }, { "type": "header", "content": "Dimensions" }, { "type": "text", "id": "max_width", "label": "Max width", "default": "64rem" }, { "type": "range", "id": "margin_top", "min": 0, "max": 10, "step": 0.1, "unit": "rem", "label": "Margin top", "default": 1 }, { "type": "range", "id": "margin_bottom", "min": 0, "max": 10, "step": 0.1, "unit": "rem", "label": "Margin bottom", "default": 1 }, { "type": "header", "content": "Colors" }, { "type": "color", "id": "background_color", "label": "Background color", "default": "#ffffff" }, { "type": "color", "id": "border_color", "label": "Border color", "default": "#eeeeee" }, { "type": "color", "id": "panel_color", "label": "Panel color", "default": "#fdfdfd" }, { "type": "header", "content": "Question" }, { "type": "range", "id": "q_size_small", "min": 1, "max": 2, "step": 0.1, "unit": "rem", "label": "Small devices font size", "default": 1 }, { "type": "range", "id": "q_size_large", "min": 1, "max": 3, "step": 0.1, "unit": "rem", "label": "Large devices font size", "default": 1.4 }, { "type": "color", "id": "q_color", "label": "Question text color" }, { "type": "header", "content": "Answer" }, { "type": "color", "id": "a_color", "label": "Answer text color" } ], "blocks": [ { "type": "faq", "name": "FAQ", "settings": [ { "type": "checkbox", "id": "checkbox_expanded", "default": false, "label": "Expanded?" }, { "type": "text", "id": "title", "label": "FAQ title", "default": "FAQ title" }, { "type": "richtext", "id": "content", "label": "FAQ content", "default": "

FAQ content

" } ] } ], "presets": [ { "name": "FAQ" } ] } {% endschema %} {%- comment -%} ------------------ THE JS ----------------- {%- endcomment -%} {%- comment -%} ---------------- THE NO-JS ---------------- {%- endcomment -%} {%- comment -%} ---------------- THE EDITOR ------------------ {%- endcomment -%} {%- if request.design_mode -%} {%- endif -%}