├── .gitignore ├── src ├── pages │ ├── pages.json │ ├── index.liquid │ ├── tag-archive.liquid │ └── about.liquid ├── posts │ ├── posts.json │ ├── post-5.liquid │ ├── post-1.liquid │ ├── post-4.liquid │ ├── post-3.liquid │ ├── post-2.liquid │ ├── post-8.njk │ ├── post-6.liquid │ └── post-7.liquid ├── _data │ └── versions.js └── _includes │ └── layouts │ ├── page.html │ ├── post.html │ └── base.html ├── package.json └── .eleventy.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | www 4 | -------------------------------------------------------------------------------- /src/pages/pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "layout": "layouts/page.html" 3 | } 4 | -------------------------------------------------------------------------------- /src/posts/posts.json: -------------------------------------------------------------------------------- 1 | { 2 | "layout": "layouts/post.html", 3 | "tags": ["post"] 4 | } 5 | -------------------------------------------------------------------------------- /src/posts/post-5.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 5 3 | tags: 4 | - eslint 5 | --- 6 | 7 | This is a post about linting your code with ESLint. :clap: 8 | -------------------------------------------------------------------------------- /src/posts/post-1.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 1 3 | tags: 4 | - eleventy 5 | - liquid 6 | --- 7 | 8 | This is an eleventy+liquid post. It's pretty great! 9 | -------------------------------------------------------------------------------- /src/posts/post-4.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 4 3 | tags: 4 | - nodejs 5 | - liquidjs 6 | --- 7 | 8 | This post shows how to use liquidjs directly with Node. 9 | -------------------------------------------------------------------------------- /src/_data/versions.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | eleventy: require("@11ty/eleventy/package.json").version, 3 | liquidjs: require("liquidjs/package.json").version 4 | }; 5 | -------------------------------------------------------------------------------- /src/posts/post-3.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 3 3 | tags: 4 | - wordpress 5 | - eleventy 6 | --- 7 | 8 | This is a post about migrating your WordPress blog to Eleventy. Ahhh yeaaaahhh! 9 | -------------------------------------------------------------------------------- /src/posts/post-2.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 2 3 | tags: 4 | - eleventy 5 | - nunjucks 6 | - filters 7 | --- 8 | 9 | This is a post about Nunjucks filters in Eleventy. It's pretty okay! 10 | -------------------------------------------------------------------------------- /src/posts/post-8.njk: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 8 (Nunjucks style) 3 | tags: 4 | - nunjucks 5 | - truthy 6 | --- 7 | 8 | {% if 0 or "" or false %} 9 | Fail: Unexpected FALSY?? 10 | {% else %} 11 | Expected: You can't handle the truthy! 12 | {% endif %} 13 | 14 | OK, let's party! 15 | -------------------------------------------------------------------------------- /src/posts/post-6.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 6 3 | tags: 4 | - nodejs 5 | - playwright 6 | --- 7 | 8 | This is a post about automated UI testing using Playwright to test with Chromium and Firefox binaries. 9 | 10 | Actual: {{ title | or: renderData.title }} 11 | Expect: "Seven" 12 | 13 | -------------------------------------------------------------------------------- /src/_includes/layouts/page.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/base.html 3 | --- 4 | 5 |
6 |
7 |

{{ title }}

8 |
9 |
{{ content | strip }}
10 | 13 |
14 | -------------------------------------------------------------------------------- /src/posts/post-7.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post 1 3 | tags: 4 | - lighthouse 5 | - nodejs 6 | --- 7 | 8 | This is a post about a11y and performance testing using Google's Lighthouse. 9 | 10 | {% if 0 or "" or false %} 11 | Fail: Unexpected FALSY?? 12 | {% else %} 13 | Expected: You can't handle the truthy! 14 | {% endif %} 15 | -------------------------------------------------------------------------------- /src/_includes/layouts/post.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/base.html 3 | --- 4 | 5 |
6 |
7 |

{{ $title }}

8 |
9 |
{{ content | strip }}
10 | 16 |
17 | -------------------------------------------------------------------------------- /src/pages/index.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | title: Homepage 3 | permalink: "index.html" 4 | --- 5 | 6 |

This is the homepage. Cool.

7 | 8 |

Here are all my posts:

9 | {% assign posts = collections.post %} 10 | {% for post in posts %} 11 |

{{ post.data.title }} — {{ post.date | date: "%Y-%m-%d" }}

12 | {% else %} 13 |

No posts found in {{ tag }} category.

14 | {% endfor %} 15 | -------------------------------------------------------------------------------- /src/pages/tag-archive.liquid: -------------------------------------------------------------------------------- 1 | --- 2 | layout: layouts/page.html 3 | eleventyExcludeFromCollections: true 4 | pagination: 5 | data: collections 6 | size: 1 7 | alias: tag 8 | filter: 9 | - post 10 | permalink: "/tags/{{ tag | slug }}/" 11 | renderData: 12 | title: "{{ tag }} Archive" 13 | --- 14 | 15 |

{{ tag }} Archive

16 | 17 | {% assign posts = collections[tag] %} 18 | {% for post in posts %} 19 |

{{ post.data.title }} — {{ post.date | date: "%Y-%m-%d" }}

20 | {% else %} 21 |

No posts found in {{ tag }} category.

22 | {% endfor %} 23 | -------------------------------------------------------------------------------- /src/_includes/layouts/base.html: -------------------------------------------------------------------------------- 1 | 2 | {%- assign $title = title | or: renderData.title1, renderData.title2, renderData.title -%} 3 | 4 | 5 | 6 | {{ $title }} 7 | 8 | 9 |
10 | {{ content | strip }} 11 |
12 | 13 |
14 | DEBUG 15 |
16 |
title:
17 |
{{ title | dump }}
18 | 19 |
renderData:
20 |
{{ renderData | dump }}
21 | 22 |
versions:
23 |
{{ versions | dump }}
24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "11ty-collection-tag-archive", 3 | "description": "Testing renderData with pagination and Liquid templates.", 4 | "version": "1.0.0", 5 | "author": "Peter deHaan (https://about.me/peterdehaan)", 6 | "bugs": { 7 | "url": "https://github.com/pdehaan/11ty-collection-tag-archive/issues" 8 | }, 9 | "dependencies": {}, 10 | "devDependencies": { 11 | "@11ty/eleventy": "^0.10.0" 12 | }, 13 | "homepage": "https://github.com/pdehaan/11ty-collection-tag-archive#readme", 14 | "keywords": [ 15 | "11ty", 16 | "eleventy", 17 | "pagination", 18 | "renderData" 19 | ], 20 | "license": "MPL-2.0", 21 | "private": true, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/pdehaan/11ty-collection-tag-archive.git" 25 | }, 26 | "scripts": { 27 | "build": "eleventy", 28 | "test": "echo \"Error: no test specified\" && exit 1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.eleventy.js: -------------------------------------------------------------------------------- 1 | module.exports = eleventyConfig => { 2 | eleventyConfig.addLiquidFilter("dump", require("util").inspect); 3 | // Usage: `{%- assign $title = title | or: renderData.title, site.title -%}` 4 | eleventyConfig.addLiquidFilter("or", (value="", ...values) => { 5 | // prepend the `value` value at the front of the `values[]` array. 6 | values.unshift(value); 7 | return values.find(truthy); 8 | }); 9 | 10 | eleventyConfig.addLiquidFilter("truthy", truthy); 11 | eleventyConfig.addLiquidFilter("falsy", value => !truthy(value)); 12 | eleventyConfig.addLiquidFilter("Boolean", Boolean); 13 | 14 | eleventyConfig.addLiquidFilter("check", value => value ? "✔️" : " "); 15 | 16 | eleventyConfig.setDataDeepMerge(true); 17 | eleventyConfig.setQuietMode(true); 18 | 19 | return { 20 | dir: { 21 | input: "src", 22 | output: "www" 23 | } 24 | }; 25 | }; 26 | 27 | function truthy(value) { 28 | if (value === 0) return true; 29 | return Boolean(value); 30 | } 31 | -------------------------------------------------------------------------------- /src/pages/about.liquid: -------------------------------------------------------------------------------- 1 | ---js 2 | { 3 | title: "About me", 4 | values: [ 5 | {label:"true", value:true}, 6 | {label:"false", value:false}, 7 | {label:"null", value:null}, 8 | {label:"undefined", value:undefined}, 9 | {label:"string", value:"string"}, 10 | {label:"empty string", value:""}, 11 | {label:"0", value:0}, 12 | {label:"integer", value:1}, 13 | {label:"float", value:1.1}, 14 | {label:"array", value:[1,2,3]}, 15 | {label:"empty array", value:[]} 16 | ] 17 | } 18 | --- 19 | 20 |

About me? I'm pretty underwhelming. Prepare to be underwhelmed.

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {% for item in values %} 32 | 33 | 34 | 35 | 36 | 37 | {% endfor %} 38 | 39 |
valuetruthyfalsy
{{ item.label }}{{ item.value | truthy | check }}{{ item.value | falsy | check }}
40 | --------------------------------------------------------------------------------