Skip to content

Commit 9e94dc0

Browse files
authored
Merge pull request #163 from chrisrhymes/feature/customise-product-collections
Allow custom collection name for products
2 parents 019704e + 78aca49 commit 9e94dc0

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

_includes/cookie-banner.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
{% if site.google_analytics %}
2424
consentGrantedAdStorage();
2525
{% endif %}
26-
Cookies.set('showCookieBanner', 'false', { expires: 7, path: '/' });
27-
Cookies.set('cookiesAccepted', 'true', {expires: 7, path: '/'});
26+
Cookies.set('showCookieBanner', 'false', { expires: 365, path: '/' });
27+
Cookies.set('cookiesAccepted', 'true', {expires: 365, path: '/'});
2828
toggleCookieBanner();
2929
}
3030

3131
function rejectCookies() {
32-
Cookies.set('showCookieBanner', 'false', { expires: 7, path: '/' });
32+
Cookies.set('showCookieBanner', 'false', { expires: 365, path: '/' });
3333
toggleCookieBanner();
3434
}
3535

_layouts/product-category.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
{{ page.content }}
88
</div>
99

10-
{% assign sorted_products = site.products | sort: page.sort %}
10+
{% if page.collection %}
11+
{% assign sorted_products = site.[page.collection] | sort: page.sort %}
12+
{% else %}
13+
{% assign sorted_products = site.products | sort: page.sort %}
14+
{% endif %}
1115

1216
{% for product in sorted_products %}
1317
<div class="column is-4-desktop is-6-tablet">

docs/products/category-page.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,19 @@ show_sidebar: false
2121
sort: title
2222
```
2323
24-
[View example Category page](/bulma-clean-theme/products/)
24+
[View example Category page](/bulma-clean-theme/products/)
25+
26+
## Customising the collection
27+
28+
To use a different collection than `products`, set the collection name in the category page's front matter.
29+
30+
The below example uses a collection called `books`.
31+
32+
```yaml
33+
title: Books
34+
subtitle: Check out our range of books
35+
layout: product-category
36+
show_sidebar: false
37+
sort: title
38+
collection: books
39+
```

docs/products/product-pages.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ toc: true
99

1010
## Products Directory
1111

12-
Start by creating a `_products` directory to hold your product pages.
12+
The default collection name for products is `products`, so create a `_products` directory to hold your product pages.
13+
14+
## Custom Collection Directory
15+
16+
You can override the default and create a folder with your own collection name. For example, using a collection of `books` would require you to create a folder called `_books`.
1317

1418
## Product Pages
1519

@@ -52,3 +56,7 @@ collections:
5256
```
5357

5458
You can also set default product page values here if you like, such as the layout or image.
59+
60+
{% include notification.html message="If you use a custom collection name then update `products` to your custom collection name. In the example above for the `_books` folder use `books` as the collection name." %}
61+
62+
For more information on collections, please refer to the [Jekyll documentation](https://jekyllrb.com/docs/collections/).

0 commit comments

Comments
 (0)