Skip to content
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

Data option to process a template file but not write it to the output directory #61

Closed
zachleat opened this issue Feb 16, 2018 · 13 comments
Labels
enhancement: favorite Vanity label! The maintainer likes this enhancement request a lot. enhancement
Milestone

Comments

@zachleat
Copy link
Member

zachleat commented Feb 16, 2018

Something like write: false

This would be similar to the _underscoreprefix.html in jekyll.

@chrisdmacrae
Copy link
Contributor

I think output: false|true would make the most sense.

It would also be create for the json files that map to entire folder(s).

@zachleat zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label May 3, 2018
@zachleat
Copy link
Member Author

zachleat commented May 3, 2018

This repository is now using lodash style issue management for enhancements (see https://twitter.com/samselikoff/status/991395669016436736)

This means enhancement issues will now be closed instead of leaving them open. The enhancement backlog can be found here: https://github.com/11ty/eleventy/issues?utf8=%E2%9C%93&q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+

@zachleat zachleat closed this as completed May 3, 2018
@zachleat zachleat added the enhancement: favorite Vanity label! The maintainer likes this enhancement request a lot. label Jul 6, 2018
@zachleat
Copy link
Member Author

Related: #188

@zachleat
Copy link
Member Author

zachleat commented Sep 4, 2018

Note that this matter option could also be set in template / directory data files.

@zachleat
Copy link
Member Author

zachleat commented Sep 8, 2018

One good idea that @octoxalis surfaced in #206 is permalink: false for this

@adamsilver
Copy link

Would be good to be able to have draft articles sent to the output with a flag:

npx eleventy --drafts

@zachleat
Copy link
Member Author

A working implementation of this is now in the permalink-false branch for marinating/testing/review

@zachleat zachleat added this to the 0.5.4 milestone Sep 13, 2018
@edwardhorsford
Copy link
Contributor

@zachleat does having permalink: false allow conditional output depending on environment variables?

Eg as per @adamsilver above - being able to set --drafts to render those pages marked draft. Or not render them if the arg is not included? Those draft pages will have permalinks assigned for testing, it's just that I want to be able to not render them in production.

My reading of it currently is that by reusing permalink for this, it means pages can't have a permalink applied. Perhaps I'm misunderstanding the feature though.

@zachleat
Copy link
Member Author

@edwardhorsford yes, for data properties you can set them in data files (JS or JSON) or in front matter. This data cascade is documented here: https://www.11ty.io/docs/data/

With this feature, @adamsilver should be able to implement this himself by creating a directory-specific JS data file that looks for a --drafts command line flag. https://www.11ty.io/docs/data-js/ It could be conditional based on development or production environment variables too, sure.

E.g. a drafts.11tydata.js file in a drafts/ folder, continuing from this example: https://www.11ty.io/docs/data-js/#example%3A-exposing-environment-variables

module.exports = {
  permalink: process.env.ELEVENTY_ENV === "production" ? false : "/{{ fileSlug }}/"
};

@edwardhorsford
Copy link
Contributor

@zachleat if an individual page already has a permalink, would that still work?

In my head, a page would have both a permalink AND a drafts flag. And something separate evaluates the both to decide whether to process.

@edwardhorsford
Copy link
Contributor

@zachleat unless I'm misunderstanding, I think this could be tricky you don't keep drafts all in one folder. Each time you want to have a conditional draft, it's a lot of extra code to add.

Turning a draft on and off isn't a case of adding status: draft or similar to frontmatter (unless I've got it wrong).

Idea - would something like this work in eleventy config?

if (process.env.NODE_ENV == production){
	eleventyConfig.ignoreFiles("status", "draft");
}

@zachleat
Copy link
Member Author

Hm? If you wanted to do this for an individual file you could use a template specific JS data file or probably even in front matter if you use the JS front matter type: https://www.11ty.io/docs/data-frontmatter/#javascript-front-matter

However, I’d rather move bikeshed discussions for a higher level drafts feature to #188 if we could!

@zachleat
Copy link
Member Author

Related: #244, #245.

@zachleat zachleat removed the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: favorite Vanity label! The maintainer likes this enhancement request a lot. enhancement
Projects
None yet
Development

No branches or pull requests

4 participants