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

dest path always relative to src #43

Closed
franz-josef-kaiser opened this issue Jun 12, 2014 · 4 comments
Closed

dest path always relative to src #43

franz-josef-kaiser opened this issue Jun 12, 2014 · 4 comments

Comments

@franz-josef-kaiser
Copy link

My problem is, that I was unable to achieve a path relative to the Gruntfile.js in the root dir. grunt-markdown didn't stop to append the src dir name(s) to the dest names.

Here's my temporary work around to build a sane file name:

markdown : {
    dev : {
        files : [
            {
                expand : true,
                cwd    : '<%= site.mustache %>',
                src    : '<%= site.md %>/*.md',
                dest   : '<%= site.mustache %>/<%= site.mddeploy %>',
                ext    : '.mustache',
                rename : function ( dest, src ) {
                    var parts = src.split( '/' ),
                        file = parts[ parts.length -1 ],
                        final = dest + '/' +  file;

                    grunt.log.writeln( 'File created at: ' + final );

                    return final;
                }
            }
        ]
    }
}

Note: The grunt.log() is just a double confirmation that the callback returns the right thing. It's not necessary and you could instantly return dest + '/' + file.

I hope the current behavior is not intended. But if it is, I'd suggest adding above code to the README.md to tell people about it.

Related: #27 #42

Anyway, thanks for a plugin - it's really helpful for building docs :)

@patik
Copy link

patik commented Jun 24, 2014

👍 Thanks for the workaround. This is bugging me as well. I wanted to end up with this:

docs/source_files/ABC.md
docs/source_files/DEF.md
docs/ABC.html
docs/DEF.html

But I could put the HTML files seemingly everywhere except one level up :(

@haroldtreen
Copy link

I think Grunt is taking care of all the file management stuff here and has an option for doing that.

This worked for me:

markdown: {
      all: {
        files: [
          {
            expand: true,
            src: 'src/md/*.md',
            dest: 'src/html',
            flatten: true,
            ext: '.html'
          }
        ]
      }
    }

The result is:

src/md/ABC.md
src/md/DEF.md

gets converted to

src/html/ABC.html
src/html/DEF.html

More info here: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

@talha131
Copy link

Thank you @haroldtreen flatten solved the issue for me.

@franz-josef-kaiser
Copy link
Author

👍 for flatten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants