Skip to content

Commit

Permalink
Support for Eleventy v2 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-cc committed Feb 7, 2023
1 parent 97114ff commit 76c1e52
Show file tree
Hide file tree
Showing 29 changed files with 7,081 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ module.exports = function (eleventyConfig, defaultOptions) {
eleventyConfig.addLiquidTag('ccInfo', function (liquidEngine) {
return {
parse: function () {},
render: function (ctx) {
render: async function (ctx) {
log(`⭐️ Starting ${blue('eleventy-plugin-cloudcannon')}`);
const context = ctx.getAll();
const config = readConfig(context, options);
const info = getInfo(context, config);
const info = await getInfo(context, config);
const json = stringifyJson(info);
log(`🏁 Generated ${bold('_cloudcannon/info.json')} ${green('successfully')}`);
return json;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/0.12.1-legacy/site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/0.12.1/site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/1.0.0-file-source/site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/1.0.0-source/site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/1.0.0/site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

189 changes: 189 additions & 0 deletions integration-tests/2.0.0-beta.3/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"timezone": "Etc/UTC",
"_inputs": {
"layout": {
"hidden": "true"
}
},
"collections_config": {
"authors": {
"path": "authors",
"output": false,
"auto_discovered": false,
"name": "The Authors"
},
"posts": {
"path": "posts",
"output": true,
"auto_discovered": true
},
"pages": {
"path": "pages",
"output": true,
"filter": "strict",
"auto_discovered": true
},
"data": {
"path": "_data",
"output": false,
"auto_discovered": false
}
},
"base_url": "",
"source": "",
"paths": {
"static": "",
"uploads": "uploads",
"data": "_data",
"collections": "",
"pages": "pages",
"layouts": "_includes"
},
"cloudcannon": {
"name": "eleventy-plugin-cloudcannon",
"version": "0.0.21"
},
"collections": {
"authors": [
{
"filePathStem": "/authors/jane-doe",
"fileSlug": "jane-doe",
"tags": [
"authors"
],
"permalink": false,
"name": "Jane Doe",
"description": "Tall",
"path": "authors/jane-doe.md",
"url": "",
"output": false,
"collection": "authors"
},
{
"filePathStem": "/authors/john-doe",
"fileSlug": "john-doe",
"tags": [
"authors"
],
"permalink": false,
"name": "John Doe",
"description": "Very tall",
"path": "authors/john-doe.md",
"url": "",
"output": false,
"collection": "authors"
}
],
"posts": [
{
"filePathStem": "/posts/totally-awesome",
"fileSlug": "totally-awesome",
"layout": "default.njk",
"tags": [
"posts",
"News"
],
"permalink": "/posts/{{ page.fileSlug }}/",
"title": "Totally awesome",
"date": "2021-08-10T00:00:00.000Z",
"author": "/authors/jane-doe.md",
"authorItem": "[FILTERED]",
"path": "posts/totally-awesome.md",
"url": "/posts/totally-awesome/",
"output": true,
"collection": "posts"
},
{
"filePathStem": "/posts/wicked-cool",
"fileSlug": "wicked-cool",
"layout": "default.njk",
"tags": [
"posts"
],
"permalink": "/posts/{{ page.fileSlug }}/",
"title": "Wicked cool",
"date": "2021-12-11T00:00:00.000Z",
"author": "/authors/john-doe.md",
"authorItem": "[FILTERED]",
"path": "posts/wicked-cool.md",
"url": "/posts/wicked-cool/",
"output": true,
"collection": "posts"
}
],
"pages": [
{
"filePathStem": "/pages/about",
"fileSlug": "about",
"layout": "default.njk",
"permalink": "/{{ page.fileSlug }}/",
"title": "About",
"description": "All about us!",
"path": "pages/about.njk",
"url": "/about/",
"output": true,
"collection": "pages"
},
{
"filePathStem": "/pages/blog",
"fileSlug": "blog",
"layout": "default.njk",
"permalink": "/blog/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber + 1 }}/{% endif %}",
"title": "Blog",
"path": "pages/blog.njk",
"url": "/blog/",
"output": true,
"collection": "pages"
},
{
"filePathStem": "/pages/index",
"fileSlug": "pages",
"layout": "default.njk",
"permalink": "/",
"title": null,
"quotes": [
{
"message": "So awesome!",
"name": "Happy Chappy"
},
{
"message": "Totally rad!",
"name": "Skatey One Eighty"
},
{
"message": "Gnarly!",
"name": "Surfer Dude"
}
],
"path": "pages/index.njk",
"url": "/",
"output": true,
"collection": "pages"
},
{
"filePathStem": "/pages/notes",
"fileSlug": "notes",
"layout": "default.njk",
"permalink": "/{{ page.fileSlug }}/",
"title": "The notes!",
"path": "pages/notes.md",
"url": "/notes/",
"output": true,
"collection": "pages"
}
]
},
"data": {},
"generator": {
"name": "eleventy",
"version": "1.0.0",
"environment": "",
"metadata": {
"markdown": "markdown-it",
"markdown-it": {
"html": true
}
}
},
"version": "0.0.3"
}
23 changes: 23 additions & 0 deletions integration-tests/2.0.0-beta.3/site/.eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const pluginCloudCannon = require('eleventy-plugin-cloudcannon');

module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.setDataDeepMerge(true);

eleventyConfig.addCollection('postsWithAuthor', (collectionApi) => {
const authors = collectionApi.getFilteredByTag('authors');

return collectionApi.getFilteredByTag('posts').map((post) => {
post.data.authorItem = authors.find((author) => author.inputPath === `.${post.data.author}`);
return post;
});
});

eleventyConfig.cloudcannonOptions = {
dir: {
pages: 'pages'
}
};

eleventyConfig.addPlugin(pluginCloudCannon);
};
2 changes: 2 additions & 0 deletions integration-tests/2.0.0-beta.3/site/.eleventyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
_site/
4 changes: 4 additions & 0 deletions integration-tests/2.0.0-beta.3/site/_data/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"site_title": "Test site",
"description": "Testing example content."
}
24 changes: 24 additions & 0 deletions integration-tests/2.0.0-beta.3/site/_includes/default.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
---
<!DOCTYPE html>

<html>
<head>
<title>Test</title>
</head>

<body>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/notes/">Notes</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</nav>

<main>
{{ content | safe }}
</main>
</body>
</html>
4 changes: 4 additions & 0 deletions integration-tests/2.0.0-beta.3/site/authors/authors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tags": "authors",
"permalink": false
}
4 changes: 4 additions & 0 deletions integration-tests/2.0.0-beta.3/site/authors/jane-doe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
name: Jane Doe
description: Tall
---
4 changes: 4 additions & 0 deletions integration-tests/2.0.0-beta.3/site/authors/john-doe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
name: John Doe
description: Very tall
---
15 changes: 15 additions & 0 deletions integration-tests/2.0.0-beta.3/site/cloudcannon.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
timezone: 'Etc/UTC',
_inputs: {
layout: {
hidden: 'true'
}
},
collections_config: {
authors: {
name: 'The Authors',
path: 'authors',
output: false
}
}
};
Loading

0 comments on commit 76c1e52

Please sign in to comment.