forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-article.liquid
271 lines (261 loc) · 12 KB
/
main-article.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
{{ 'section-blog-post.css' | asset_url | stylesheet_tag }}
<article class="article-template" itemscope itemtype="http://schema.org/BlogPosting">
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'featured_image'-%}
{%- if article.image -%}
<div class="article-template__hero-container">
<div class="article-template__hero-{{ block.settings.image_height }} media"
itemprop="image"
{% if block.settings.image_height == 'adapt' and article.image %} style="padding-bottom: {{ 1 | divided_by: article.image.aspect_ratio | times: 100 }}%;"{% endif %}
>
<img srcset="{% if article.image.width >= 350 %}{{ article.image | img_url: '350x' }} 350w,{% endif %}
{% if article.image.width >= 700 %}{{ article.image | img_url: '700x' }} 700w,{% endif %}
{% if article.image.width >= 749 %}{{ article.image | img_url: '749x' }} 749w,{% endif %}
{% if article.image.width >= 1498 %}{{ article.image | img_url: '1498x' }} 1498w,{% endif %}
{% if article.image.width >= 1100 %}{{ article.image | img_url: '1100x' }} 1100w,{% endif %}
{% if article.image.width >= 2200 %}{{ article.image | img_url: '2200x' }} 2200w,{% endif %}"
sizes="(min-width: 1200px) 1100px, (min-width: 750px) calc(100vw - 10rem), 100vw"
src="{{ article.image | img_url: '1100x' }}"
loading="lazy"
width="{{ article.image.width }}"
height="{{ article.image.height }}"
alt="{{ article.image.alt | escape }}">
</div>
</div>
{%- endif -%}
{%- when 'title'-%}
<header class="page-width page-width--narrow">
<h1 class="article-template__title" itemprop="headline">{{ article.title | escape }}</h1>
{%- if block.settings.blog_show_date -%}
<span class="circle-divider caption-with-letter-spacing" itemprop="dateCreated pubdate datePublished">{{ article.published_at | time_tag: format: 'month_year' }}</span>
{%- endif -%}
{%- if block.settings.blog_show_author -%}
<span class="caption-with-letter-spacing" itemprop="author" itemscope itemtype="http://schema.org/Person">
<span itemprop="name">{{ article.author }}</span>
</span>
{%- endif -%}
</header>
{%- when 'content'-%}
<div class="article-template__content page-width page-width--narrow rte" itemprop="articleBody">
{{ article.content }}
</div>
{%- when 'social_sharing'-%}
<div class="article-template__social-sharing page-width page-width--narrow">
{% render 'social-sharing', share_title: article.title, share_permalink: article.url, share_image: article.image %}
</div>
{%- endcase -%}
{%- endfor -%}
<div class="element-margin center">
<a href="{{ blog.url }}" class="article-template__link link{% if blog.comments_enabled? == false %} spaced-section{% endif %}">
{% render 'icon-arrow' %}
{{ 'blogs.article.back_to_blog' | t: title: blog.title }}
</a>
</div>
{%- if blog.comments_enabled? -%}
<div class="article-template__comment-wrapper background-secondary">
<div id="comments" class="page-width page-width--narrow">
{%- if article.comments_count > 0 -%}
{%- assign anchorId = '#Comments-' | append: article.id -%}
<h2 id="Comments-{{ article.id }}">{{ 'blogs.article.comments' | t: count: article.comments_count }}</h2>
{% paginate article.comments by 5 %}
<div class="article-template__comments">
{%- if comment.status == 'pending' and comment.content -%}
<article id="{{ comment.id }}" class="article-template__comments-comment">
{{ comment.content }}
<footer class="right">
<span class="circle-divider caption-with-letter-spacing">{{ comment.author }}</span>
</footer>
</article>
{%- endif -%}
{%- for comment in article.comments -%}
<article id="{{ comment.id }}" class="article-template__comments-comment">
{{ comment.content }}
<footer class="right">
<span class="circle-divider caption-with-letter-spacing">{{ comment.author }}</span><span class="caption-with-letter-spacing">{{ comment.created_at | time_tag: format: 'month_year' }}</span>
</footer>
</article>
{%- endfor -%}
{% render 'pagination', paginate: paginate, anchor: anchorId %}
</div>
{% endpaginate %}
{%- endif -%}
{% form 'new_comment', article %}
{%- liquid
assign post_message = 'blogs.article.success'
if blog.moderated? and comment.status == 'unapproved'
assign post_message = 'blogs.article.success_moderated'
endif
-%}
<h2>{{ 'blogs.article.comment_form_title' | t }}</h2>
{%- if form.errors -%}
<div class="form__message" role="alert">
<h3 class="form-status caption-large" tabindex="-1" autofocus>
{% render 'icon-error' %} {{ 'templates.contact.form.error_heading' | t }}
</h3>
</div>
<ul class="form-status-list caption-large">
{%- for field in form.errors -%}
<li>
<a href="#CommentForm-{{ field }}" class="link">
{%- if form.errors.translated_fields[field] contains 'author' -%}
{{ 'blogs.article.name' | t }}
{%- elsif form.errors.translated_fields[field] contains 'body'-%}
{{ 'blogs.article.message' | t }}
{%- else -%}
{{ form.errors.translated_fields[field] }}
{%- endif -%}
{{ form.errors.messages[field] }}
</a>
</li>
{%- endfor -%}
</ul>
{%- elsif form.posted_successfully? -%}
<div class="form-status-list form__message" role="status">
<h3 class="form-status" tabindex="-1" autofocus>{% render 'icon-success' %} {{ post_message | t }}</h3>
</div>
{%- endif -%}
<div{% if blog.moderated? == false %} class="article-template__comments-fields"{% endif %}>
<div class="article-template__comment-fields">
<div class="field field--with-error">
<input
type="text"
name="comment[author]"
id="CommentForm-author"
class="field__input"
autocomplete="name"
value="{{ form.author }}"
aria-required="true"
{% if form.errors contains 'author' %}
aria-invalid="true"
aria-describedby="CommentForm-author-error"
{% endif %}
placeholder="{{ 'blogs.article.name' | t }}"
>
<label class="field__label" for="CommentForm-author">{{ 'blogs.article.name' | t }} <span aria-hidden="true">*</span></label>
{%- if form.errors contains 'author' -%}
<small id="CommentForm-author-error">
<span class="form__message">{% render 'icon-error' %}{{ 'blogs.article.name' | t }} {{ form.errors.messages['author'] }}.</span>
</small>
{%- endif -%}
</div>
<div class="field field--with-error">
<input
type="email"
name="comment[email]"
id="CommentForm-email"
autocomplete="email"
class="field__input"
value="{{ form.email }}"
autocorrect="off"
autocapitalize="off"
aria-required="true"
{% if form.errors contains 'email' %}
aria-invalid="true"
aria-describedby="CommentForm-email-error"
{% endif %}
placeholder="{{ 'blogs.article.email' | t }}"
>
<label class="field__label" for="CommentForm-email">{{ 'blogs.article.email' | t }} <span aria-hidden="true">*</span></label>
{%- if form.errors contains 'email' -%}
<small id="CommentForm-email-error">
<span class="form__message">{% render 'icon-error' %}{{ 'blogs.article.email' | t }} {{ form.errors.messages['email'] }}.</span>
</small>
{%- endif -%}
</div>
</div>
<div class="field field--with-error">
<textarea
rows="5"
name="comment[body]"
id="CommentForm-body"
class="text-area field__input"
aria-required="true"
{% if form.errors contains 'body' %}
aria-invalid="true"
aria-describedby="CommentForm-body-error"
{% endif %}
placeholder="{{ 'blogs.article.message' | t }}"
>{{ form.body }}</textarea>
<label class="form__label field__label" for="CommentForm-body">{{ 'blogs.article.message' | t }} <span aria-hidden="true">*</span></label>
</div>
{%- if form.errors contains 'body' -%}
<small id="CommentForm-body-error">
<span class="form__message">{% render 'icon-error' %}{{ 'blogs.article.message' | t }} {{ form.errors.messages['body'] }}.</span>
</small>
{%- endif -%}
</div>
{%- if blog.moderated? -%}
<p class="article-template__comment-warning caption">{{ 'blogs.article.moderated' | t }}</p>
{%- endif -%}
<input type="submit" class="button" value="{{ 'blogs.article.post' | t }}">
{% endform %}
</div>
</div>
{%- endif -%}
</article>
{% schema %}
{
"name": "t:sections.main-article.name",
"tag": "section",
"blocks": [
{
"type": "featured_image",
"name": "t:sections.main-article.blocks.featured_image.name",
"limit": 1,
"settings": [
{
"type": "select",
"id": "image_height",
"options": [
{
"value": "adapt",
"label": "t:sections.main-article.blocks.featured_image.settings.image_height.options__1.label"
},
{
"value": "medium",
"label": "t:sections.main-article.blocks.featured_image.settings.image_height.options__2.label"
},
{
"value": "large",
"label": "t:sections.main-article.blocks.featured_image.settings.image_height.options__3.label"
}
],
"default": "adapt",
"label": "t:sections.main-article.blocks.featured_image.settings.image_height.label",
"info": "t:sections.main-article.blocks.featured_image.settings.image_height.info"
}
]
},
{
"type": "title",
"name": "t:sections.main-article.blocks.title.name",
"limit": 1,
"settings": [
{
"type": "checkbox",
"id": "blog_show_date",
"default": true,
"label": "t:sections.main-article.blocks.title.settings.blog_show_date.label"
},
{
"type": "checkbox",
"id": "blog_show_author",
"default": false,
"label": "t:sections.main-article.blocks.title.settings.blog_show_author.label"
}
]
},
{
"type": "content",
"name": "t:sections.main-article.blocks.content.name",
"limit": 1
},
{
"type": "social_sharing",
"name": "t:sections.main-article.blocks.social_sharing.name",
"limit": 1
}
]
}
{% endschema %}