-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.eleventy.js
32 lines (28 loc) · 1.12 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const pkg = require("./package.json");
const twitter = require("./twitter")
module.exports = {
initArguments: {},
configFunction: function(eleventyConfig, {cacheDirectory = "", useInlineStyles = true, autoEmbed = false} = {}) {
// combine destructured option params
let options = {cacheDirectory, useInlineStyles, autoEmbed}
try {
eleventyConfig.versionCheck(pkg["11ty"].compatibility);
} catch (e) {
console.log(
`WARN: Eleventy Plugin (${pkg.name}) Compatibility: ${e.message}`
);
}
// added in 0.10.0
eleventyConfig.addNunjucksAsyncShortcode("tweet", async(tweetId) => {
return await twitter.getTweet(tweetId, options)
});
eleventyConfig.addNunjucksAsyncShortcode("tweetStyles", async() => {
return await twitter.getStyles()
});
if (options.autoEmbed) {
eleventyConfig.addTransform("autoEmbedTweets", async (content, outputPath) => {
return await twitter.autoEmbedTweets(content, outputPath, options)
});
}
}
}