metalsmith / permalinks

A Metalsmith plugin for permalinks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permalinks should never try to create a folder outside(above) of Metalsmith(__dirname)

nikmartin opened this issue · comments

Related to #25:

.use(permalinks({
    relative: false,
    pattern: ':collection/:title'
  }))

will try to create about.md, which is NOT in a collection, as /about/index.html, which is the root of the drive on a LInux or OS X system. changing it to:

.use(permalinks({
    relative: false,
    pattern: './:collection/:title'
  }))

makes it relative to something, which happens to be the root of the build dir. What should probably happen is permalinks should always build paths relative to the build dir.

It would be preferable if the plugin code actually prevented the accidental use of a / at the start of a pattern. After getting the path maybe something like:

  // Remove leading / to avoid escaping to the root folder!!
  if (path.indexOf('/') === 0){
        path = path.substring(1);
  }