andrejewski / smithsonian

web interface for Metalsmith
ISC License
36 stars 1 forks source link

Support for source() and destination() ? #4

Closed diroru closed 8 years ago

diroru commented 8 years ago

Hello,

when i include the source() and destination() method calls into the build.js-chain, i get a type error:

TypeError: Smithsonian(...).use(...).use(...).use(...).use(...).use(...).destination is not a function.

Am i doing something wrong or is it an (intentional) omission? Thanks and cheers!

andrejewski commented 8 years ago

Yes, this is intentional. Smithsonian only has methods directly on it when they override or extend Metalsmith's behavior, such as with use or build. Instead of playing whack-a-mole with Metalsmith's API changes, methods like source and destination are accessible via Smithsonian.metalsmith.source() and Smithsonian.metalsmith.destination(). Smithsonian.metalsmith being the instantiated Metalsmith instance.

diroru commented 8 years ago

Thank you very much for the prompt response, and apologies for not reading the documentation more thoroughly!

Still, i would like to ask if / how i could integrate the above calls into the usual build.js-chain, like so:

Smithsonian(__dirname)
  .metalsmith.source('src')
  .use(drafts())
  ....

With this setup i am getting an error, probably because the source() call returns only the metalsmith-instance and not the smithsonian wrapper.

At this stage, this issue is not a showstopper, just wondering if i have some wrong assumptions or might need to change my setup.

Thanks again!

andrejewski commented 8 years ago

Any calls you make to Metalsmith directly will have to happen outside of the build chain. In this case, "./src" is the default so that call in your example would be unnecessary. Like most modules, chaining is completely optional and only for aesthetics so it's not unnatural to do something more procedural.

diroru commented 8 years ago

Thank you for indulging the ramblings of an apprentice! It was most enlightening. Cheers, dimitar