diff --git a/content/blog/blog.11tydata.js b/content/blog/blog.11tydata.js index 7657d51..2d655b1 100644 --- a/content/blog/blog.11tydata.js +++ b/content/blog/blog.11tydata.js @@ -3,34 +3,4 @@ module.exports = { "posts" ], "layout": "layouts/post.njk", - - // Draft posts: - eleventyComputed: { - permalink: data => { - if(data.draft) { - // BUILD_DRAFTS is set in eleventy.config.js - if(process.env.BUILD_DRAFTS) { - return data.permalink; - } - - // Always skip during non-watch/serve builds - return false; - } - - return data.permalink; - }, - eleventyExcludeFromCollections: data => { - if(data.draft) { - // BUILD_DRAFTS is set in eleventy.config.js - if(process.env.BUILD_DRAFTS) { - return data.eleventyExcludeFromCollections; - } - - // Always exclude from non-watch/serve builds - return true; - } - - return data.eleventyExcludeFromCollections; - } - }, }; diff --git a/content/content.11tydata.js b/content/content.11tydata.js new file mode 100644 index 0000000..8c2455d --- /dev/null +++ b/content/content.11tydata.js @@ -0,0 +1,31 @@ +module.exports = { + // Draft posts: + eleventyComputed: { + permalink: data => { + if(data.draft) { + // BUILD_DRAFTS is set in eleventy.config.js + if(process.env.BUILD_DRAFTS) { + return data.permalink; + } + + // Always skip during non-watch/serve builds + return false; + } + + return data.permalink; + }, + eleventyExcludeFromCollections: data => { + if(data.draft) { + // BUILD_DRAFTS is set in eleventy.config.js + if(process.env.BUILD_DRAFTS) { + return data.eleventyExcludeFromCollections; + } + + // Always exclude from non-watch/serve builds + return true; + } + + return data.eleventyExcludeFromCollections; + } + }, +}; diff --git a/eleventy.config.js b/eleventy.config.js index 5267771..0defe0b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -57,7 +57,7 @@ module.exports = function(eleventyConfig) { }); }); - // Drafts implementation, see `content/blog/blog.11tydata.js` for additional code. + // Drafts implementation, see `content/content.11tydata.js` for additional code. // This section *could* be simplified to an environment variable in an npm script, // but this way an ENV is not required and this code works cross-platform. eleventyConfig.addPlugin(function enableDrafts(eleventyConfig) {