This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
/
index.liquid
executable file
·163 lines (126 loc) · 5.27 KB
/
index.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
<!-- /templates/index.liquid -->
{% comment %}
This is the homepage of your site.
More info on global variables (available on all templates):
- http://docs.shopify.com/themes/liquid-variables/global
{% endcomment %}
<h2>{{ 'homepage.sections.frontpage_title' | t }}</h2>
{% comment %}
Use class grid-uniform to have evenly sized columns clear
each other properly at each breakpoint.
{% endcomment %}
<div class="grid-uniform">
{% comment %}
Loop through products in your Frontpage collection.
This collection is created by default, but you must add products to it.
{% endcomment %}
{% for product in collections.frontpage.products limit:4 %}
{% comment %}
Change the grid item width by using classes from the grid in
the grid_item_width variable.
Example:
- {% assign grid_item_width = 'large--one-third medium--one-half' %}
{% endcomment %}
{% assign grid_item_width = 'large--one-quarter medium--one-half' %}
{% include 'product-grid-item' %}
{% else %}
{% comment %}
For onboarding new users to your theme, we add some default products and onboarding tutorials to help populate their store
{% endcomment %}
{% unless emptyState %}
{{ 'theme-onboarding.css' | global_asset_url | stylesheet_tag }}
{% assign emptyState = true %}
{% endunless %}
{% include 'onboarding-featured-products' %}
{% endfor %}
</div>
<hr>
<h2>{{ 'homepage.sections.featured_title' | t }}</h2>
<div class="grid-uniform">
{% comment %}
Show five collections, unless it's 'frontpage'.
Use an index variable in combination to the limit filter
to account for the frontpage collection being in top six returned.
Use variable isEmpty to check if no collections will be shown.
For empty store demo only.
{% endcomment %}
{% assign index = 1 %}
{% assign isEmpty = true %}
{% for collection in collections limit:6 %}
{% unless index > 5 %}
{% unless collection.handle == 'frontpage' %}
{% assign isEmpty = false %}
{% assign collection_item_width = 'large--one-fifth medium--one-third' %}
<div class="grid__item {{ collection_item_width }} text-center">
{% comment %}
Use capture to put the collection title in a variable that is used in liquid filters
{% endcomment %}
{% capture collection_title %}{{ collection.title | escape }}{% endcapture %}
<a href="{{ collection.url }}" title="{{ 'collections.general.link_title' | t: title: collection_title }}" class="grid__image">
{% if collection.image %}
{{ collection.image.src | img_url: 'large' | img_tag: collection_title }}
{% else %}
{{ collection.products.first.featured_image | img_url: 'large' | img_tag: collection_title }}
{% endif %}
</a>
<p>
<a href="{{ collection.url }}" title="{{ 'collections.general.link_title' | t: title: collection_title }}">{{ collection.title }}</a><br>
{{ 'collections.general.items_with_count' | t: count: collection.all_products_count }}
</p>
</div>
{% assign index = index | plus: 1 %}
{% endunless %}
{% endunless %}
{% endfor %}
{% comment %}
For onboarding new users to your theme, we add some default collections and onboarding tutorials to help populate their store
{% endcomment %}
{% if isEmpty %}
{% unless emptyState %}
{{ 'theme-onboarding.css' | global_asset_url | stylesheet_tag }}
{% assign emptyState = true %}
{% endunless %}
{% include 'onboarding-featured-collections' %}
{% endif %}
</div>
<hr>
{% comment %}
Loop through three recent blog articles with the following code.
Since we're not on the blog template, we need to define the blog
handle we want to focus on. For this example we'll use the default 'news',
but you can create a blog page-specific content if you want.
{% endcomment %}
<h2>{{ 'homepage.sections.news_title' | t }}</h2>
<div class="grid">
{% for article in blogs['news'].articles limit:3 %}
<div class="grid__item large--one-third">
<time datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ article.published_at | date: format: 'month_day_year' }}</time>
<h3><a href="{{ article.url }}">{{ article.title }}</a></h3>
{% comment %}
Add a surrounding div with class 'rte' to anything that will come from the rich text editor.
Since this is just a listing page, you can either use the excerpt or truncate the full article.
{% endcomment %}
<div class="rte">
{% if article.excerpt.size > 0 %}
{{ article.excerpt }}
{% else %}
<p>{{ article.content | strip_html | truncatewords: 20 }}</p>
{% endif %}
</div>
{% comment %}
Show off meta information like number of comments and tags.
{% endcomment %}
<ul>
{% if blog.comments_enabled? %}
<li>
<a href="{{ article.url }}#comments">
{{ article.comments_count }}
{{ 'blogs.comments.comments_with_count' | t: count: article.comments_count }}
</a>
</li>
{% endif %}
</ul>
<p><a href="{{ article.url }}">{{ 'blogs.article.read_more' | t }} →</a></p>
</div>
{% endfor %}
</div>