Skip to content

Commit

Permalink
Merge pull request #163 from chrisrhymes/feature/customise-product-co…
Browse files Browse the repository at this point in the history
…llections

Allow custom collection name for products
  • Loading branch information
chrisrhymes authored Aug 5, 2024
2 parents 019704e + 78aca49 commit 9e94dc0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 3 additions & 3 deletions _includes/cookie-banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
{% if site.google_analytics %}
consentGrantedAdStorage();
{% endif %}
Cookies.set('showCookieBanner', 'false', { expires: 7, path: '/' });
Cookies.set('cookiesAccepted', 'true', {expires: 7, path: '/'});
Cookies.set('showCookieBanner', 'false', { expires: 365, path: '/' });
Cookies.set('cookiesAccepted', 'true', {expires: 365, path: '/'});
toggleCookieBanner();
}

function rejectCookies() {
Cookies.set('showCookieBanner', 'false', { expires: 7, path: '/' });
Cookies.set('showCookieBanner', 'false', { expires: 365, path: '/' });
toggleCookieBanner();
}

Expand Down
6 changes: 5 additions & 1 deletion _layouts/product-category.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
{{ page.content }}
</div>

{% assign sorted_products = site.products | sort: page.sort %}
{% if page.collection %}
{% assign sorted_products = site.[page.collection] | sort: page.sort %}
{% else %}
{% assign sorted_products = site.products | sort: page.sort %}
{% endif %}

{% for product in sorted_products %}
<div class="column is-4-desktop is-6-tablet">
Expand Down
17 changes: 16 additions & 1 deletion docs/products/category-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,19 @@ show_sidebar: false
sort: title
```
[View example Category page](/bulma-clean-theme/products/)
[View example Category page](/bulma-clean-theme/products/)
## Customising the collection
To use a different collection than `products`, set the collection name in the category page's front matter.

The below example uses a collection called `books`.

```yaml
title: Books
subtitle: Check out our range of books
layout: product-category
show_sidebar: false
sort: title
collection: books
```
10 changes: 9 additions & 1 deletion docs/products/product-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ toc: true

## Products Directory

Start by creating a `_products` directory to hold your product pages.
The default collection name for products is `products`, so create a `_products` directory to hold your product pages.

## Custom Collection Directory

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`.

## Product Pages

Expand Down Expand Up @@ -52,3 +56,7 @@ collections:
```

You can also set default product page values here if you like, such as the layout or image.

{% 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." %}

For more information on collections, please refer to the [Jekyll documentation](https://jekyllrb.com/docs/collections/).

0 comments on commit 9e94dc0

Please sign in to comment.