Last active
October 18, 2020 14:12
-
-
Save kieranbarker/95b1535449624efc834ab96dd288cfa4 to your computer and use it in GitHub Desktop.
Prevent draft and scheduled posts from being written to output in Eleventy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
layout: 'layouts/post.html', | |
eleventyComputed: { | |
permalink(data) { | |
if (!data.draft && new Date(data.date) <= new Date()) { | |
return data.permalink || '/blog/{{ title | slug }}/index.html'; | |
} | |
return false; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 6 assumes you're using Nunjucks and/or Liquid as your template language(s).
This directory data should be used in conjunction with the following collection in your Eleventy config file:
https://gist.github.com/kieranbarker/01e960ffa36ebeffc14e244414eb8270