製品とビタミン
製品とビタミン
{%-comment-%}このコンポーネントは、`img`タグまたは`div style = "background-..."`を生成できます。 {%-endcomment-%} {%-is_global_asset =is_global_asset|を割り当てますデフォルト:false-%} {%-if bg-%} {%-comment-%}背景画像{%-endcomment-%} {%-assign tag_name = tag_name | デフォルト:'div'-%} {%-self_closing=self_closingを割り当てます| デフォルト:false-%} {%-コメント-%}属性を自分でレンダリングし、`style`を除外します。 {%-endcomment-%} {%-attr_list=attrsを割り当てます| to_attrs:list:true-%} {%-capture additional_attrs-%} {%-comment-%}コンテキストからの属性を含めます。 {%-endcomment-%} {%-for attr in attr_list-%} {%-untr [0] =='style'-%} {{-''-}} {{-attr [0]-} } {%-if attr [1] .size> 0-%} = "{{-attr [1]-}}" {%-endif-%} {%-endunless-%} {%-endfor-%} {{-''-}} style = "{%-comment-%} bgスタイルをレンダリングします。画像が取得されなかった場合はsrcを使用します。{%-endcomment-%} {%-assign has_bg_image = false-%} {%-has_bg_size = falseを割り当てます-%} {%-has_bg_position_x = falseを割り当てます-%} {%-has_bg_position_y = falseを割り当てます-%} {%-has_bg_repeat = falseを割り当てます-%} {%-bgのpropに-%} {%-case prop [0]-%} {%-when'image'-%} {%-assign has_bg_image = true-%} {%-when' size'-%} {%-assign has_bg_size = true-% } {%-when'position'-%} {%-assign has_bg_position_x = true-%} {%-assign has_bg_position_y = true-%} {%-when'position-x'-%} {%-assign has_bg_position_x = true -%} {%-when'position-y'-%} {%-assign has_bg_position_y = true-%} {%-when'repeat'-%} {%-assign has_bg_repeat = true-%} {%-endcase- %}背景-{{-prop [0]-}}:{{-p rop [1]-}}; {%-endfor-%} {%-has_bg_image-%を除く{%-endunless-%} {%-unless has_bg_size-%} background-size:cover; {%-endunless-%} {%-unless_bg_position_x-%} background-position-x:center; {%-endunless-%} {%-unless_bg_position_y-%} background-position-y:center; {%-endunless-%} {%-unless_bg_repeat-%} background-repeat:no-repeat; {%-endunless-%} {%-comment-%}style属性から任意のスタイルを追加します。 {%-endcomment-%} {{-attrs.style-}} "{%-endcapture-%} {%-comment-%} attrsを削除して、0回レンダリングしないようにします。{%-endcomment-%} { %-割り当てattrs = nil-%} {%-else-%} {%-コメント-%}通常のimgタグ{%-エンドコメント-%} {%-割り当てtag_name ='img'-%} {%-割り当てself_closeing = true-%} {%-capture additional_attrs-%} {%-if srcset.size> 0-%} {{-''-}} srcset = "{{srcset}}" {%-endif-%} { %-if size.size> XNUMX-%} {{-''-}} size = "{{sizes}}" {%-endif-%} {{-''-}} alt = "{{alt} } "{{-''-}} src =" {{src | Asset_url:global:is_global_asset}} "{%-endcapture-%} {%-endif-%} {%-include'atom / element'、tag_name:tag_name、self_closing:self_closing、additional_attrs:additional_attrs-%}{%-comment-%}`tag_name`から先頭と末尾の空白を削除します。 {%-endcomment-%} {%-assign tag_name = tag_name | strip-%} {%-comment-%} `tag_name:''`の場合を処理します。 {%-endcomment-%} {%-if tag_name and tag_name.size <1-%} {%-assign tag_name = false-%} {%-endif-%} {%-if tag_name-%} <{{tag_name }} {{-attrs | to_attrs-}} {{-additional_attrs-}} {%-if self_closeing == true-%} {{-'/'-}} {%-endif-%}> {%-endif-%} {%-unless self_closing == true-%} {%-ifslot-%} {%-slot-%} {%-else-%} {{-inner_html-}} {%-endifslot-%} {%-if tag_name-%} {%-endif-%} {%-endunless-%}
{%- キャプチャ id_attr -%} {{- item.id -}} {%- endcapture -%} {%- if id_attr.size > 0 -%} {%- キャプチャ id_attr -%} id="{{ item .id }}" {%- endcapture -%} {%- endif -%} {%- assign attrs = item.attrs | merge_props: クラス: 'card card--post' -%} {%- if link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 -%} {% else %} {% endif %} {%- img == false または item.img == nil でない限り -%} {%- assign _img = item.img -%} {%- assign 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 -%} {%- 無限 -%} {{ 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 -%} {%- ただし、link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 -%} {{ item.link_text }} {%- 無限 -%} {%- if link == false または item.link == nil または item.link.size < 1 または item.link_text == nil または item.link_text.size < 1 -%} {% else %} {% endif %}