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

set*Directory Configuration API methods #1503

Closed
valtlai opened this issue Nov 6, 2020 · 5 comments
Closed

set*Directory Configuration API methods #1503

valtlai opened this issue Nov 6, 2020 · 5 comments
Labels
enhancement: favorite Vanity label! The maintainer likes this enhancement request a lot. enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file

Comments

@valtlai
Copy link
Contributor

valtlai commented Nov 6, 2020

Is your feature request related to a problem? Please describe.
There’s no a corresponding method for the dir configuration property.

Describe the solution you'd like
Adding a setDirectories (or something like that) configuration method.

Describe alternatives you've considered
Using the existing property.

Additional context
I’d like to only use methods for consistency.

Also see #1502 for {data,markdown,html}TemplateEngine.

@zachleat
Copy link
Member

Completely agree with this and a +1 from me.

@zachleat zachleat added the enhancement: favorite Vanity label! The maintainer likes this enhancement request a lot. label Jul 29, 2021
@zachleat zachleat added the feature: 🛠 configuration Related to Eleventy’s Configuration file label Aug 16, 2021
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Apr 8, 2024
@zachleat
Copy link
Member

zachleat commented Apr 9, 2024

  • eleventyConfig.setInputDirectory
  • eleventyConfig.setLayoutsDirectory
  • eleventyConfig.setIncludesDirectory
  • eleventyConfig.setDataDirectory
  • eleventyConfig.setOutputDirectory

are shipping with 3.0.0-alpha.6.

These methods will throw an error if you attempt to use them in plugins. These are project-space features only for now!

@zachleat zachleat changed the title Missing configuration method for dir set*Directory Configuration API methods Apr 9, 2024
@zachleat
Copy link
Member

zachleat commented Apr 9, 2024

Having a few second thoughts about this API, hmm.

Consider this, where the order matters (not ideal):

export default function(eleventyConfig) {
  eleventyConfig.directories.input; // WARN has "./"

  eleventyConfig.addPlugin(eleventyConfig => {
    eleventyConfig.directories.input; // has "./content/"
  });

  eleventyConfig.setInputDirectory("content");

  eleventyConfig.directories.input; // has "./content/"
};

I’m kinda tempted to just move it to be an export level thing in your config file, like this:

export default function(eleventyConfig) {
  eleventyConfig.directories.input; // has "./content/"
};

export const config = {
  dir: {
    input: "content"
  }
}

The above would ensure consistent directory references in your project.

As discussed in #3244, the hope in adding these methods would improve the current situation (and it does improve it) but if we move to a named export we would eliminate these issues entirely:

export default function(eleventyConfig) {
  // IMPROVED by eleventyConfig.setInputDirectory("content");
  // But the API method still needs to be called first (order matters)

  eleventyConfig.directories.input; // WARN has "./"

  eleventyConfig.addPlugin(eleventyConfig => {
    eleventyConfig.directories.input; // has "./content/"
  });

  return {
    dir: {
      input: "content",
    }
  }
};

@zachleat
Copy link
Member

zachleat commented Apr 10, 2024

Moved that secondary feature to #3246. Given the feedback about this one we’ll keep it around for 3.0.0-alpha.6

@zachleat zachleat added the needs-documentation Documentation for this issue/feature is pending! label May 30, 2024
zachleat added a commit to 11ty/11ty-website that referenced this issue Sep 26, 2024
@zachleat
Copy link
Member

@zachleat zachleat removed the needs-documentation Documentation for this issue/feature is pending! label Sep 26, 2024
zachleat added a commit to 11ty/11ty-website that referenced this issue Sep 26, 2024
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 feature: 🛠 configuration Related to Eleventy’s Configuration file
Projects
None yet
Development

No branches or pull requests

2 participants