diff options
-rw-r--r-- | eleventy.config.js | 14 |
1 files changed, 13 insertions, 1 deletions
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', |