Skip to content

Commit

Permalink
Added draft support, solves #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Apostolique committed Dec 21, 2023
1 parent c8c61fb commit 01a67ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/draft.draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Draft
This page is a draft example, it will never be generated with the site.
17 changes: 17 additions & 0 deletions src/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ module.exports = eleventyConfig => {
})
);

eleventyConfig.addGlobalData("eleventyComputed.permalink", () => {
return data => {
if (data.page.fileSlug.endsWith('.draft')) {
return false;
}
return data.permalink;
}
});
eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", () => {
return data => {
if (data.page.fileSlug.endsWith('.draft')) {
return true;
}
return data.eleventyExcludeFromCollections;
}
});

let options = {
html: true,
breaks: true,
Expand Down

0 comments on commit 01a67ea

Please sign in to comment.