diff --git a/_layouts/default.html b/_layouts/default.html index 3ea3a5d..bc1cb67 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -16,12 +16,29 @@ + + + + + + + + + + + + + + + + + {% include sidebar.html %}
@@ -35,6 +52,6 @@ {{ content }} + - diff --git a/filters/compact.md b/filters/compact.md new file mode 100644 index 0000000..4b7648b --- /dev/null +++ b/filters/compact.md @@ -0,0 +1,53 @@ +--- +title: compact +description: Liquid filter that removes nil values from an array. +--- + +Removes any `nil` values from an array. + +For this example, assume `site.pages` is an array of content pages for a website, and some of these pages have an attribute called `category` that specifies their content category. If we `map` those categories to an array, some of the array items might be `nil` if any pages do not have a `category` attribute. + + +

Input

+{% raw %} +```liquid +{% assign site_categories = site.pages | map: 'category' %} + +{% for category in site_categories %} + {{ category }} +{% endfor %} +``` +{% endraw %} + +

Output

+```text + business + celebrities + + lifestyle + sports + + technology +``` + +By using `compact` when we create our `site_categories` array, we can remove all the `nil` values in the array. + +

Input

+{% raw %} +```liquid +{% assign site_categories = site.pages | map: 'category' | compact %} + +{% for category in site_categories %} + {{ category }} +{% endfor %} +``` +{% endraw %} + +

Output

+```text + business + celebrities + lifestyle + sports + technology +``` diff --git a/images/icons/water-drop-128x.png b/images/icons/water-drop-128x.png new file mode 100644 index 0000000..1b37db8 Binary files /dev/null and b/images/icons/water-drop-128x.png differ diff --git a/images/icons/water-drop-32x.png b/images/icons/water-drop-32x.png new file mode 100644 index 0000000..ffdaa3b Binary files /dev/null and b/images/icons/water-drop-32x.png differ diff --git a/images/icons/water-drop-64x.png b/images/icons/water-drop-64x.png new file mode 100644 index 0000000..64b55c4 Binary files /dev/null and b/images/icons/water-drop-64x.png differ diff --git a/images/icons/water-drop.svg b/images/icons/water-drop.svg new file mode 100644 index 0000000..80fe203 --- /dev/null +++ b/images/icons/water-drop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/water-drop.svg b/images/water-drop.svg new file mode 100644 index 0000000..80fe203 --- /dev/null +++ b/images/water-drop.svg @@ -0,0 +1 @@ + \ No newline at end of file