Skip to content

Instantly share code, notes, and snippets.

@kieranbarker
Last active October 18, 2020 14:12
Embed
What would you like to do?
Prevent draft and scheduled posts from being written to output in Eleventy
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;
}
}
};
@kieranbarker
Copy link
Author

kieranbarker commented Oct 18, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment