Closed RobLoach closed 7 years ago
Is this going to happen anytime soon?
Would be nice to have. Do you have any ideas of how it would be set up?
No, I don't know how this would be done. I cannot use this extension until this feature has been added, because I need to tell stylus to use axis
, jeet
, and rupture
.
What are those extensions from?
axis
, jeet
, and rupture
are NPM modules.
Here is stylus
' use method:
http://stylus-lang.com/docs/js.html#usefn
stylus(str)
.use(mylib)
.render(...)
I really really really really want to start using metalsmith-jstransformer
. It will take me back to a toolset like I used to have with DocPad, but superior in almost every way.
But I need to be able to provide options to the transformers. I like the automatic aspect of this Metalsmith plugin, but one of Metalsmith’s main attractions is the ultimate freedom it provides…and that means “let me use whatever options I want”.
What about the following?
options
passed in…Add an extra option (alongside pattern
, layoutPattern
, and defaultLayout
) called transformerOptions
.
The transformerOptions
would be an object where each key matches the name of the transformer, and each value are the options to pass to that transformer.
Example:
metalsmith.use(
jstransformer({
'transformerOptions': {
// these options will be passed to `jstransformer-marked`
'marked': { … }
}
})
);
…Unfortunately, I don’t know how to do this in any way that would scale.
Stylus has a nice .use()
method, but every library has a different API, and the entire point of using JSTransformers is to normalize APIs.
If there were a way to pre-configure something, then pass it into a JSTransformer to use, that might be approaching something useful…but I think the idea needs refinement. (Or, it needs to be replaced by a better idea.)
I don't see a problem with just passing the options to the transformers. Stylus' use
is supported in jstransformers through the use
property in the options.
Right now, it assumes you'd pass the options in through the file metadata...
---
use:
- stylus-plugin-something
---
body
color red
font 14px Arial, sans-serif
It would be nice to have what @Zearin provided, because then the use
settings would apply to every file that is rendered through Stylus....
metalsmith.use(
jstransformer({
'transformerOptions': {
// these options will be passed to `jstransformer-stylus`
'stylus': {
'use': [
'stylus-plugin-something'
]
}
}
})
);
---
# No more `use` needed!
---
body
color red
font 14px Arial, sans-serif
It would be nice to have what @Zearin provided, because then the use settings would apply to every file that is rendered through Stylus....
Exactly! I don’t want to have to add YAML frontmatter to a bunch of files because my entire project uses one Stylus plugin or another.
It’s another push for “DRY”. I should be able to specify the plugins I want Stylus to use once.
I'm with Zearin on this.
Allow passing in arguments stating which inputformats/transformers to process.