These are chat archives for jescalan/roots

4th
Feb 2015
star
@ilife5
Feb 04 2015 08:45

I am trying to write a extension.
Since jade support markdown filter, and I need a extension to read makedown file ,put it in a jade layout and write it using jade:)
The question is, in compile_hooks, how can I get the target path.

For example :

Markdowns in mdFiles.

/mdFiles/tools.md
/mdFiles/utils.md

In compile_hooks, I want get

/public/mdFiles/tools.html
/public/mdFiles/utils.html

star
@ilife5
Feb 04 2015 08:53

I get an idea :smile:

path.join(ctx.roots.config.output_path(), ctx.file_options._path)

Is that right?

star
@ilife5
Feb 04 2015 10:03
Can I use a compile_hook to change the write content?
Jeff Escalante
@jescalan
Feb 04 2015 15:38
Hi there @ilife5!
Just replied to your github issue. I think we're in different timezones so you sent all this in the middle of the night
This is a good idea for an extension though, definitely could be done
in compile_hooks, you can use ctx.roots.config.output_path() as it seems you have found above
Will be around today to field any other questions if you have them, happy to review the extension as well
star
@ilife5
Feb 04 2015 16:05

@jenius

I am awake:)
I am using roots to build a wiki.
Yeah, we`re in diffrent timezones...

We have many docs wrote with markdown.

What I`m doing is
Read markdown ==> record the markdown infomation && put the markdown content in .jade content ==> generate the menu && wiki html

Jeff Escalante
@jescalan
Feb 04 2015 16:14
ok...
so is your intent to have markdown files in the project and processed through an extension
or are you just looking to convert an initial batch of markdown to jade containing markdown
star
@ilife5
Feb 04 2015 16:21
eee...
I try to find the method to convert an initial batch of markdown to jade containing markdown.
As you see, I haven`t find and making a extension to do that.
Jeff Escalante
@jescalan
Feb 04 2015 16:21
yeah so I'd just write a script to do that
you dont even need an extension
it's a very basic transformation, you just change the extension to jade and add like 5 lines to the top specifying the layout and markdown filter
you could write a script to do this in a minute or two
in whatever language you prefer
the extensions run every time roots compiles. what you really are looking for here is a way to do this transformation once, right?
and let me know if anything I'm saying is confusing and I'll try putting it in another way
star
@ilife5
Feb 04 2015 16:23
I agree with you about the script.
Jeff Escalante
@jescalan
Feb 04 2015 16:25
:+1:
star
@ilife5
Feb 04 2015 16:25
But It`s pleasure that if I only run a command, and watch the things going...like roots watch:)
Jeff Escalante
@jescalan
Feb 04 2015 16:25
Well right, you'd run that script one time and after that only run roots watch
But yeah I do agree with you overall. I think it would be nice to have a way to include straight markdown files and maybe specify a layout you want them compiled into to an extension
star
@ilife5
Feb 04 2015 16:26
There is some way I can get a before_hook before compile?
Jeff Escalante
@jescalan
Feb 04 2015 16:26
I think this would be a pretty good idea for an extension
yeah there is a before hook
all the hooks are documented on http://rootx.cx/docs/extensions
star
@ilife5
Feb 04 2015 16:28
What about I run the script in the hook and simply run "roots watch":)
Jeff Escalante
@jescalan
Feb 04 2015 16:28
That's essentially what an extension would do
The difference is that for the markdown files, you need to usually put them into a layout
So you'd need a place to specify which layout you want on which markdown files
This is the kind of thing you'd pass into an extension to configure it
then the extension could take care of matching the markdown files to the correct layouts and rendering them
star
@ilife5
Feb 04 2015 16:30
Like this?
mdJade({
      basedir:__dirname,
      layout: path.join(__dirname, "./template/content.jade")
    })
Jeff Escalante
@jescalan
Feb 04 2015 16:33
I would say maybe markdown(files: 'docs/*.md', layout: 'docs/_layout.jade')
this allows more specific choices on the files being selected
I might also allow it to be passed an array, in case you have 2 or more folders of markdown files and each one you wanted to compile into a different layout
star
@ilife5
Feb 04 2015 16:34
:thumbsup:
Jeff Escalante
@jescalan
Feb 04 2015 16:36
you can use minimatch to snag the glob patterns
have you taken a look through the source of some of the other extensions?
star
@ilife5
Feb 04 2015 16:37
dynamic-content and js-pipeline
Jeff Escalante
@jescalan
Feb 04 2015 16:37
awesome
yeah we can help with a markdown extension though for sure. i think thats a good idea
star
@ilife5
Feb 04 2015 16:38
:thumbsup:
star
@ilife5
Feb 04 2015 17:38

I find the key for outputing.

:)

Next use minimatch to snag the glob patterns.

Jeff Escalante
@jescalan
Feb 04 2015 17:38
sweet! you're getting there
I know it can get complex with roots extensions
star
@ilife5
Feb 04 2015 17:40
Learning need a process of experience
Jeff Escalante
@jescalan
Feb 04 2015 17:40
wise words indeed
star
@ilife5
Feb 04 2015 17:42
I should have a rest
timezone aha
Jeff Escalante
@jescalan
Feb 04 2015 17:42
for sure -- what time is it there?
star
@ilife5
Feb 04 2015 17:44
01:42am Feb 5
Jeff Escalante
@jescalan
Feb 04 2015 17:44
oh yeah, pretty late
do you have your in progress code on github?
if so link it up and we'll make a pull request :)
star
@ilife5
Feb 04 2015 17:52
It is unfinished...
I`ll put it on github tomorrow:)
Jeff Escalante
@jescalan
Feb 04 2015 17:53
okk
even unfinished is ok
we can still take a look
star
@ilife5
Feb 04 2015 17:55
It`s a little late ... ... tomorrow ~~ tomorrow~~
Thanks for this...
Jeff Escalante
@jescalan
Feb 04 2015 17:56
haha ok, no problem!
good night
star
@ilife5
Feb 04 2015 17:56
good night