From 851eafdc4c3a612142e0e6ae84f54cb0f0eb98b1 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 24 Jan 2023 15:32:58 -0600 Subject: [PATCH] Clean up the drafts code --- eleventy.config.drafts.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/eleventy.config.drafts.js b/eleventy.config.drafts.js index 9bd7f8b..8eb92dc 100644 --- a/eleventy.config.drafts.js +++ b/eleventy.config.drafts.js @@ -2,12 +2,8 @@ function eleventyComputedPermalink() { // When using `addGlobalData` and you *want* to return a function, you must nest functions like this. // `addGlobalData` acts like a global data file and runs the top level function it receives. return (data) => { - if(data.draft) { - if(process.env.BUILD_DRAFTS) { - return data.permalink; - } - - // Always skip during non-watch/serve builds + // Always skip during non-watch/serve builds + if(data.draft && !process.env.BUILD_DRAFTS) { return false; } @@ -19,12 +15,8 @@ function eleventyComputedExcludeFromCollections() { // When using `addGlobalData` and you *want* to return a function, you must nest functions like this. // `addGlobalData` acts like a global data file and runs the top level function it receives. return (data) => { - if(data.draft) { - if(process.env.BUILD_DRAFTS) { - return data.eleventyExcludeFromCollections; - } - - // Always exclude from non-watch/serve builds + // Always exclude from non-watch/serve builds + if(data.draft && !process.env.BUILD_DRAFTS) { return true; }