From b2b04122a22489736f8c2bca9dd8cf9cdf826a6e Mon Sep 17 00:00:00 2001 From: Starfall Date: Mon, 3 Jul 2023 13:59:49 -0500 Subject: actually stop processing drafts on build --- eleventy.config.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'eleventy.config.js') diff --git a/eleventy.config.js b/eleventy.config.js index a33d908..0de9978 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -15,7 +15,6 @@ filter_rfc3339_datetime = function(date) { return date.toISOString().replace('T', ' '); } - module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(eleventyNavigation) eleventyConfig.addPlugin(eleventyRss) @@ -34,6 +33,19 @@ module.exports = function(eleventyConfig) { excerpt: true }) + // skip drafts + eleventyConfig.addGlobalData('eleventyComputed.permalink', function() { return (data) => { + return data.draft && !process.env.BUILD_DRAFTS ? false : data.permalink + }}) + eleventyConfig.addGlobalData('eleventyComputed.eleventyExcludeFromCollections', function() { return (data) => { + return data.draft && !process.env.BUILD_DRAFTS ? false : data.eleventyExcludeFromCollections + }}) + eleventyConfig.on('eleventy.before', ({runMode}) => { + if(runMode === 'serve' || runMode === 'watch') { + process.env.BUILD_DRAFTS = true + } + }) + return { dir: { input: 'src', -- cgit