Skip to content

Commit

Permalink
Move all src JS into external plugins installed through NPM:
Browse files Browse the repository at this point in the history
@11ty/eleventy-plugin-rss
@11ty/eleventy-plugin-syntaxhighlight
  • Loading branch information
zachleat committed Jan 29, 2018
1 parent c4b6550 commit ac5c7ed
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 235 deletions.
43 changes: 5 additions & 38 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,17 @@
const { DateTime } = require("luxon");
const metadata = require("./_data/metadata.json");
const absoluteUrl = require("./_src/AbsoluteUrl");
const HtmlToAbsoluteUrls = require("./_src/HtmlToAbsoluteUrls");
const syntaxHighlighter = require("./_src/eleventy-liquidjs-tag-highlight-prismjs");

function dateToISO(dateObj) {
return DateTime.fromJSDate(dateObj).toISO({ includeOffset: true, suppressMilliseconds: true });
}
const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");

module.exports = function(eleventyConfig) {
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginSyntaxHighlight);

eleventyConfig.addFilter("rssLastUpdatedDate", collection => {
if( !collection.length ) {
throw new Error( "Collection is empty in lastUpdatedDate filter." );
}
// Newest date in the collection
return dateToISO(collection[ collection.length - 1 ].date);
});

eleventyConfig.addFilter("rssDate", dateObj => {
return dateToISO(dateObj);
});
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");

eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
});

eleventyConfig.addNunjucksFilter("absoluteUrl", function(href, base) {
return absoluteUrl(href, base);
});

eleventyConfig.addNunjucksFilter("htmlToAbsoluteUrls", function(htmlContent, base, callback) {
if(!htmlContent) {
callback(null, "");
return;
}

HtmlToAbsoluteUrls(htmlContent, base).then(result => {
callback(null, result.html);
});
}, true);

// compatibility with existing {% highlight js %} and others
eleventyConfig.addLiquidTag("highlight", syntaxHighlighter);

// only content in the `posts/` directory
eleventyConfig.addCollection("posts", function(collection) {
return collection.getAllSorted().filter(function(item) {
Expand Down
5 changes: 0 additions & 5 deletions _src/AbsoluteUrl.js

This file was deleted.

33 changes: 0 additions & 33 deletions _src/HighlightLines.js

This file was deleted.

22 changes: 0 additions & 22 deletions _src/HtmlToAbsoluteUrls.js

This file was deleted.

83 changes: 0 additions & 83 deletions _src/LiquidHighlight.js

This file was deleted.

16 changes: 0 additions & 16 deletions _src/eleventy-liquidjs-tag-highlight-plain.js

This file was deleted.

12 changes: 0 additions & 12 deletions _src/eleventy-liquidjs-tag-highlight-prismjs.js

This file was deleted.

9 changes: 0 additions & 9 deletions _src/test/HtmlToAbsoluteUrlsTest.js

This file was deleted.

17 changes: 3 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,10 @@
},
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"dependencies": {
"@11ty/eleventy": "0.2.12",
"@11ty/eleventy": "0.2.13",
"@11ty/eleventy-plugin-rss": "^1.0.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^1.0.0",
"luxon": "^0.3.1",
"posthtml": "^0.11.2",
"posthtml-urls": "^1.0.0",
"prismjs": "^1.10.0"
},
"devDependencies": {
"ava": "^0.25.0"
},
"ava": {
"files": [
"_src/test/*.js"
],
"source": [
"_src/**/*.{js,jsx}"
]
}
}
4 changes: 2 additions & 2 deletions posts/firstpost.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Bring to the table win-win survival strategies to ensure proactive domination. A

Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.

{% highlight js 2-3 %}
{% highlight-plain js 2-3 %}
// this is a command
function myCommand() {
let counter = 0;
counter++;
}
{% endhighlight %}
{% endhighlight %}
5 changes: 4 additions & 1 deletion posts/secondpost.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ layout: layouts/post.njk
---
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

<a href="{{ '/posts/firstpost/' | url }}">First post</a>
<a href="{{ '/posts/thirdpost/' | url }}">Third post</a>

Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.

Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.

0 comments on commit ac5c7ed

Please sign in to comment.