-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a draft mode #2060
Comments
@pbowyer I know you're asking for a built-in mode, but for future travellers, I believe the current solution is a combination of |
@pdehaan Never thought of |
Ah, apologies. I assumed you were just asking for an EASIER way to do draft modes (which I also agree with). https://www.11ty.dev/docs/permalinks/#permalink-false is a good place to start reading. And I recall a few really good discussions in the issues and forums about it. I'll see if I can dig any up. |
Probably a bunch more interesting threads if you search issues/discussions for |
In fact, here was my solution. // ./src/src.11tydata.js
module.exports = {
eleventyComputed: {
permalink(data) {
// If the page is in `draft:true` mode, don't write it to disk...
if (data.draft) {
return false;
}
// Return the original value (which could be `false`, or a custom value,
// or default empty string).
return data.permalink;
},
eleventyExcludeFromCollections(data) {
// If the page is in `draft:true` mode, or has `permalink:false` exclude
// it from any collections since it shouldn't be visible anywhere.
if (data.draft || data.permalink === false) {
return true;
}
return data.eleventyExcludeFromCollections;
}
}
}; Posted my sample repo at https://github.com/pdehaan/11ty-drafts |
initially also tried to use draft:true, obv didn't work. per this issue tried to use permalink: false page didn't render but still showed in collections, so generated a 404 (also seems this is expected) then tried to add various combinations of following (to module.exports and to global .eleventy.js file) to fix latter, w/ no success :
perhaps where to add this is implicit based on some other resource. (tried eleventyComputed suggestion from OP but copy/paste w/bracket-count check didn't parse properly). since everybody that has a site creates drafts, this is probably something that could be simplified further imho. |
after a lot of looking, this is clealy being held off in eleventy. whether this is reason or not, fairly easy to do:
benefits:
|
I think you can improve on that approach using the Configuration API for ignores. I like that folks can decide what convention they want to use for drafts (the example below uses a
In this example |
Let’s consider #188 the home base for this, please subscribe over there |
Is your feature request related to a problem? Please describe.
Say I've got 10-15 drafts. I want them rendered locally but I don't want the file to exist in production
Describe the solution you'd like
I'd like a built-in draft mode.
Describe alternatives you've considered
I've added a setting to the front matter to exclude the files from my
sitemap.xml
and I comment them out of the navigation - but the draft is still generated as a page in the output directoryThe text was updated successfully, but these errors were encountered: