summary refs log tree commit diff
path: root/eleventy.config.js
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2023-07-03 13:59:49 -0500
committerStarfall <us@starfall.systems>2023-07-03 13:59:49 -0500
commitb2b04122a22489736f8c2bca9dd8cf9cdf826a6e (patch)
tree548658f923fe7396ec7f560ebd21f8f423d72a71 /eleventy.config.js
parent8b690ea38f113f2eb5c2921c453159039c953599 (diff)
actually stop processing drafts on build
Diffstat (limited to 'eleventy.config.js')
-rw-r--r--eleventy.config.js14
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',