Adds sample drafts implementation

This commit is contained in:
Zach Leatherman
2023-01-23 16:35:14 -06:00
parent 092be5302e
commit 4c2cdf1746
4 changed files with 63 additions and 12 deletions

View File

@ -0,0 +1,36 @@
module.exports = {
tags: [
"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;
}
},
};

View File

@ -1,6 +0,0 @@
{
"tags": [
"posts"
],
"layout": "layouts/post.njk"
}

View File

@ -0,0 +1,6 @@
---
title: This is a fifth post (draft)
date: 2023-01-23
draft: true
---
This is a draft post