-
-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESM docs for collections 11ty/eleventy#836
- Loading branch information
Showing
20 changed files
with
1,014 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{%- set tabid = "collections-add" %} | ||
<div class="codetitle codetitle-right-md">eleventy.config.js</div> | ||
<is-land on:visible import="/js/seven-minute-tabs.js"> | ||
<seven-minute-tabs class="tabs-flush" persist sync> | ||
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: tabid, only: "jsesm,jscjs"} %} | ||
<div id="{{ tabid }}-jsesm" role="tabpanel"> | ||
|
||
```js | ||
export default function (eleventyConfig) { | ||
// async-friendly | ||
eleventyConfig.addCollection("myCollectionName", async (collectionsApi) => { | ||
// get unsorted items | ||
return collectionsApi.getAll(); | ||
}); | ||
}; | ||
``` | ||
|
||
</div> | ||
<div id="{{ tabid }}-jscjs" role="tabpanel"> | ||
|
||
```js | ||
module.exports = function (eleventyConfig) { | ||
// async-friendly | ||
eleventyConfig.addCollection("myCollectionName", async (collectionsApi) => { | ||
// get unsorted items | ||
return collectionsApi.getAll(); | ||
}); | ||
}; | ||
``` | ||
|
||
</div> | ||
</seven-minute-tabs> | ||
</is-land> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<is-land on:visible import="/js/seven-minute-tabs.js"> | ||
<seven-minute-tabs persist sync class="tabs-flush"> | ||
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: "collectionsall"} %} | ||
<div id="collectionsall-liquid" role="tabpanel"> | ||
|
||
{% raw %} | ||
```liquid | ||
<ul> | ||
{%- for post in collections.all -%} | ||
<li><a href="{{ post.url }}">{{ post.url }}</a></li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsall-njk" role="tabpanel"> | ||
|
||
{% raw %} | ||
```jinja2 | ||
<ul> | ||
{%- for post in collections.all -%} | ||
<li><a href="{{ post.url }}">{{ post.url }}</a></li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsall-js" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
export function render(data) { | ||
return `<ul> | ||
${data.collections.all | ||
.map((post) => `<li><a href="${post.url}">${post.url}</a></li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsall-cjs" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
exports.render = function (data) { | ||
return `<ul> | ||
${data.collections.all | ||
.map((post) => `<li><a href="${post.url}">${post.url}</a></li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
</seven-minute-tabs> | ||
</is-land> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<is-land on:visible import="/js/seven-minute-tabs.js"> | ||
<seven-minute-tabs persist sync class="tabs-flush"> | ||
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: "collectionsnav"} %} | ||
<div id="collectionsnav-liquid" role="tabpanel"> | ||
|
||
{% raw %} | ||
```liquid | ||
<ul> | ||
{%- for post in collections.post -%} | ||
<li{% if page.url == post.url %} aria-current="page"{% endif %}>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsnav-njk" role="tabpanel"> | ||
|
||
{% raw %} | ||
```jinja2 | ||
<ul> | ||
{%- for post in collections.post -%} | ||
<li{% if page.url == post.url %} aria-current="page"{% endif %}>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsnav-js" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
export function render(data) { | ||
return `<ul> | ||
${data.collections.post | ||
.map( | ||
(post) => | ||
`<li${data.page.url === post.url ? ` aria-current="page"` : ""}>${ | ||
post.data.title | ||
}</li>` | ||
) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collectionsnav-cjs" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
exports.render = function (data) { | ||
return `<ul> | ||
${data.collections.post | ||
.map( | ||
(post) => | ||
`<li${data.page.url === post.url ? ` aria-current="page"` : ""}>${ | ||
post.data.title | ||
}</li>` | ||
) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
</seven-minute-tabs> | ||
</is-land> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<is-land on:visible import="/js/seven-minute-tabs.js"> | ||
<seven-minute-tabs persist sync class="tabs-flush"> | ||
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: "collections"} %} | ||
<div id="collections-liquid" role="tabpanel"> | ||
|
||
{% raw %} | ||
```liquid | ||
<ul> | ||
{%- for post in collections.post -%} | ||
<li>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-njk" role="tabpanel"> | ||
|
||
{% raw %} | ||
```jinja2 | ||
<ul> | ||
{%- for post in collections.post -%} | ||
<li>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-js" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
export function render(data) { | ||
return `<ul> | ||
${data.collections.post | ||
.map((post) => `<li>${post.data.title}</li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-cjs" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
exports.render = function (data) { | ||
return `<ul> | ||
${data.collections.post | ||
.map((post) => `<li>${post.data.title}</li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
</seven-minute-tabs> | ||
</is-land> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<is-land on:visible import="/js/seven-minute-tabs.js"> | ||
<seven-minute-tabs persist sync class="tabs-flush"> | ||
{% renderFile "./src/_includes/syntax-chooser-tablist.11ty.js", {id: "collections-dashwarn"} %} | ||
<div id="collections-dashwarn-liquid" role="tabpanel"> | ||
|
||
{% raw %} | ||
```liquid | ||
<ul> | ||
{%- for post in collections.post-with-dash -%} | ||
<li>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-dashwarn-njk" role="tabpanel"> | ||
|
||
{% raw %} | ||
```jinja2 | ||
<ul> | ||
{%- for post in collections['post-with-dash'] -%} | ||
<li>{{ post.data.title }}</li> | ||
{%- endfor -%} | ||
</ul> | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-dashwarn-js" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
export function render(data) { | ||
return `<ul> | ||
${data.collections['post-with-dash'] | ||
.map((post) => `<li>${post.data.title}</li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
<div id="collections-dashwarn-cjs" role="tabpanel"> | ||
|
||
{% raw %} | ||
```js | ||
exports.render = function (data) { | ||
return `<ul> | ||
${data.collections['post-with-dash'] | ||
.map((post) => `<li>${post.data.title}</li>`) | ||
.join("\n")} | ||
</ul>`; | ||
}; | ||
``` | ||
{% endraw %} | ||
|
||
</div> | ||
</seven-minute-tabs> | ||
</is-land> |
Oops, something went wrong.