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

Question: how to know the order for plugins #195

Open
kud opened this Issue Dec 24, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@kud
Copy link

kud commented Dec 24, 2015

Hello,
A noob question and probably obvious for other people but how do you know the order of plugins?

For instance, I use metalsmith-drafts, how can I know where it should be placed in the queue of plugins?

@Ajedi32

This comment has been minimized.

Copy link
Collaborator

Ajedi32 commented Dec 24, 2015

Plugins basically just make some changes to the virtual directory of files, then pass it on to the next plugin. The plugins are applied in-order from first to last. So for metalsmith-drafts, you want to place it after any plugins that add the drafts: true metadata to your files (if you're just using the built-in frontmatter parsing, that's probably nothing), and before any plugins that expect the drafts to have already been deleted (such as metalsmith-collections, maybe?).

@woodyrew

This comment has been minimized.

Copy link
Collaborator

woodyrew commented Dec 24, 2015

Hi Kud,

Metalsmith is like a pipeline. It works sequentially through the plugins from the first to the last. Each plugin can change the state of the metadata, frontmatter, filename or the file contents. So, if one plugin relies on another, the dependency should come first.

With metalsmith-drafts, I would think that needs to be towards the start of your plugin pipeline.

Something to keep in mind: You could have a plugin in your pipeline multiple times with different parameters if needed.

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