forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatured-blog.liquid
148 lines (142 loc) · 6.05 KB
/
featured-blog.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<link rel="stylesheet" href="{{ 'component-slider.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'component-card.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'component-article-card.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'section-featured-blog.css' | asset_url }}" media="print" onload="this.media='all'">
<noscript>{{ 'component-slider.css' | asset_url | stylesheet_tag }}</noscript>
<noscript>{{ 'component-card.css' | asset_url | stylesheet_tag }}</noscript>
<noscript>{{ 'component-article-card.css' | asset_url | stylesheet_tag }}</noscript>
{{ 'section-featured-blog.css' | asset_url | stylesheet_tag }}
<div class="blog{% if section.settings.soft_background %} background-secondary{% endif %}{% if section.settings.heading == blank %} no-heading{% endif %}">
<div class="page-width-desktop">
<div class="title-wrapper-with-link{% if section.settings.heading == blank %} title-wrapper-with-link--no-heading{% endif %} title-wrapper--self-padded-tablet-down">
<h2 class="blog__title">{{ section.settings.heading | escape }}</h2>
{%- if section.settings.blog != blank and section.settings.show_view_all and section.settings.post_limit < section.settings.blog.articles_count -%}
<a href="{{ section.settings.blog.url }}"
class="link underlined-link large-up-hide"
>
{{ 'sections.featured_blog.view_all' | t }}
</a>
{%- endif -%}
</div>
{%- liquid
if section.settings.post_limit <= section.settings.blog.articles_count
assign posts_exceed_limit = true
endif
-%}
{%- if section.settings.blog != blank and section.settings.blog.articles_count > 0 -%}
<slider-component class="slider-mobile-gutter">
<ul id="Slider-{{ section.id }}"
class="blog__posts articles-wrapper grid grid--peek grid--2-col-tablet grid--3-col-desktop slider slider--tablet{% if posts_exceed_limit %} blog__posts--{{ section.settings.post_limit }}-items{% else %} blog__posts--{{ section.settings.blog.articles_count }}-items{% endif %}"
role="list"
>
{%- for article in section.settings.blog.articles limit: section.settings.post_limit -%}
<li class="blog__post grid__item article slider__slide slider__slide--full-width">
{% render 'article-card', blog: section.settings.blog, article: article, show_image: section.settings.show_image, show_date: section.settings.show_date, show_author: section.settings.show_author %}
</li>
{%- endfor -%}
</ul>
{%- if posts_exceed_limit -%}
<div class="slider-buttons no-js-hidden{% if section.settings.post_limit < 3 %} medium-hide{% endif %}{% if section.settings.post_limit < 2 %} small-hide{% endif %}">
<div class="slider-counter caption">
<span class="slider-counter--current">1</span>
<span aria-hidden="true"> / </span>
<span class="visually-hidden">{{ 'accessibility.of' | t }}</span>
<span class="slider-counter--total">{{ section.settings.post_limit }}</span>
</div>
<button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'accessibility.previous_slide' | t }}">{% render 'icon-caret' %}</button>
<button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'accessibility.next_slide' | t }}">{% render 'icon-caret' %}</button>
</div>
{%- endif -%}
</slider-component>
{%- if section.settings.show_view_all and section.settings.post_limit < section.settings.blog.articles_count -%}
<div class="blog__view-all center small-hide medium-hide">
<a href="{{ section.settings.blog.url }}" class="blog__button button">
{{ 'sections.featured_blog.view_all' | t }}
</a>
</div>
{%- endif -%}
{%- else -%}
<div class="blog-placeholder">
<div class="placeholder media media--landscape">
{{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
</div>
<div class="blog-placeholder__content">
<h2>
{{ 'sections.featured_blog.onboarding_title' | t }}
</h2>
<p class="rte-width">
{{ 'sections.featured_blog.onboarding_content' | t }}
</p>
</div>
</div>
{%- endif -%}
</div>
</div>
{% schema %}
{
"name": "t:sections.featured-blog.name",
"tag": "section",
"class": "spaced-section spaced-section--full-width",
"settings": [
{
"type": "text",
"id": "heading",
"default": "Blog posts",
"label": "t:sections.featured-blog.settings.heading.label"
},
{
"type": "blog",
"id": "blog",
"label": "t:sections.featured-blog.settings.blog.label"
},
{
"type": "range",
"id": "post_limit",
"min": 1,
"max": 3,
"step": 1,
"default": 3,
"label": "t:sections.featured-blog.settings.post_limit.label"
},
{
"type": "checkbox",
"id": "show_image",
"default": true,
"label": "t:sections.featured-blog.settings.show_image.label",
"info": "t:sections.featured-blog.settings.show_image.info"
},
{
"type": "checkbox",
"id": "show_date",
"default": true,
"label": "t:sections.featured-blog.settings.show_date.label"
},
{
"type": "checkbox",
"id": "show_author",
"default": false,
"label": "t:sections.featured-blog.settings.show_author.label"
},
{
"type": "checkbox",
"id": "soft_background",
"default": false,
"label": "t:sections.featured-blog.settings.soft_background.label"
},
{
"type": "checkbox",
"id": "show_view_all",
"default": true,
"label": "t:sections.featured-blog.settings.show_view_all.label"
}
],
"presets": [
{
"name": "t:sections.featured-blog.presets.name",
"settings": {
"blog": "News"
}
}
]
}
{% endschema %}