製品とビタミン
製品とビタミン
{%- comment -%} このコンポーネントは、`img` タグまたは `div style="background-..."` を生成できます。
{%- endcomment -%} {%- assignment is_global_asset = is_global_asset | default: false -%} {%- if bg -%} {%- comment -%} 背景画像 {%- endcomment -%} {%- assignment tag_name = tag_name | default: 'div' -%} {%- assignment self_closing = self_closing | default: false -%} {%- comment -%} 属性を独自にレンダリングし、`style` を除外します。 {%- endcomment -%} {%- assignment attr_list = attrs | to_attrs: list: true -%} {%- capture additional_attrs -%} {%- comment -%} コンテキストから属性を含めます。 {%- endcomment -%} {%- for attr in attr_list -%} {%- except attr[0] == 'style' -%} {{- ' ' -}} {{- attr[0] -}} {%- if attr[1].size > 0 -%} ="{{- attr[1] -}}" {%- endif -%} {%- endunless -%} {%- endfor -%} {{- ' ' -}} style=" {%- comment -%} 背景スタイルをレンダリングします。 画像が取得できなかった場合は src を使用します。 {%- endcomment -%} {%- assignment has_bg_image = false -%} {%- assignment has_bg_size = false -%} {%- assignment has_bg_position_x = false -%} {%- assignment has_bg_position_y = false -%} {%- assignment has_bg_repeat = false -%} {%- for prop in bg -%} {%- case prop[0] -%} {%- when 'image' -%} {%- assignment has_bg_image = true -%} {%- when 'size' -%} {%- assignment has_bg_size = true -%} {%- when 'position' -%} {%- assignment has_bg_position_x = true -%} {%- assignment has_bg_position_y = true -%} {%- when 'position-x' -%} {%- assignment has_bg_position_x = true -%} {%- when 'position-y' -%} {%- assignment has_bg_position_y = true -%} {%- when 'repeat' -%} {%- assignment has_bg_repeat = true -%} {%- endcase -%} background-{{- prop[0] -}}: {{- prop[1] -}}; {%- endfor -%} {%- except has_bg_image -%} background-image: url('{{- src | asset_url: global: is_global_asset -}}'); {%- endunless -%} {%- except has_bg_size -%} background-size: cover; {%- endunless -%} {%- except has_bg_position_x -%} background-position-x: center; {%- endunless -%} {%- except has_bg_position_y -%} background-position-y: center; {%- endunless -%} {%- except has_bg_repeat -%} background-repeat: no-repeat; {%- endunless -%} {%- comment -%} style 属性から任意のスタイルを追加します。 {%- endcomment -%} {{- attrs.style -}} " {%- endcapture -%} {%- comment -%} attrs を削除して、2 回レンダリングされないようにします。 {%- comment -%} `tag_name` から先頭と末尾の空白を削除します。 {%- endcomment -%} {%- assignment tag_name = tag_name | strip -%} {%- comment -%} `tag_name: ''` ケースを処理します。 {%- endcomment -%} {%- if tag_name and tag_name.size < 1 -%} {%- assignment tag_name = false -%} {%- endif -%} {%- if tag_name -%} <{{ tag_name }} {{- attrs | to_attrs -}} {{- additional_attrs -}} {%- if self_closing == true -%} {{- ' /' -}} {%- endif -%} > {%- endif -%} {%- unless self_closing == true -%} {%- ifslot -%} {%- slot -%} {%- else -%} {{- inner_html -}} {%- endifslot -%} {%- if tag_name -%} {%- endif -%} {%- endunless -%}
{%- capture id_attr -%} {{- item.id -}} {%- endcapture -%} {%- if id_attr.size > 0 -%} {%- capture id_attr -%} id="{{ item.id }}" {%- endcapture -%} {%- endif -%} {%- assignment attrs = item.attrs | merge_props: class: 'card card--post' -%} {%- if link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 -%} {% else % } {% endif %} {%- unless img == false または item.img == nil -%} {%- assign _img = item.img -%} {%- assignment img_attrs = _img.attrs | merge_props: class: 'card__image' -%} {%- include 'atom/img', alt: _img.alt, src: _img.src, srcset: _img.srcset, sizes: _img.sizes, attrs: img_attrs, bg: _img.bg -%} {%- endunless -%} {{ item.title }} {%- author == false または item.author == nil または item.author.size < 3 -% でない限り} {{ item.author }} {%- endunless -%} {%- date == false または item.date == nil または item.date.size < 3 -% でない限り} {{ item.date }} {%- endunless -%} {%- summary == false または item.summary == nil または item.summary.size < 1 でない限り -%} {{ item.summary }} {%- endunless -%} {%- unless link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 -%} {{ item.link_text }} {%- 終了しない -%} {%- link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 の場合 -%} {% それ以外の場合 %} {% 終了した場合 %}