metalsmith / permalinks

A Metalsmith plugin for permalinks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Path contains a backslash and can't be used as URL

Jackbennett opened this issue · comments

commented

Hello, So I've got just one link that's getting a backslash instead of a forward slash it's a bit odd to track down but I suspect it's this plugin. I could be wrong. I'm on windows and I see lots of path.join used in this plugin, should path be building a url safe metadata value as opposed to a filesystem one?

Plugins that could meddle with path;

.use(collections({
      blog:{
        pattern:'blog/**/*.html' // create a collection of blog files by file path
      }
  }))
  .use(permalinks({
    pattern: ':collection/:title',
    relative: false
  }))
  .use(title())

Template;

<ul>
    <li><a href="/">A</a></li>
    <li><a href="/hello">B</a></li>
    <li>subnav
        {{#if blog.length}}
        <ul>
            {{#each blog}}
            <li><a href="/{{path}}">{{title}}</a></li>
            {{/each}}
        </ul>
        {{/if}}
    </li>
</ul>

output, note the "Post two" href;

    <ul>
        <li><a href="/">A</a></li>
        <li><a href="/hello">B</a></li>
        <li>subnav
            <ul>
                <li><a href="/blog/post-one">Post one</a></li>
                <li><a href="/blog\post-two">Post two</a></li>
                <li><a href="/blog/post-the-third">Post, The Third.</a></li>
            </ul>
        </li>
    </ul>
  • Post 1 is a lone html file at blog/post-one.html with a h1 tag.
  • Post 2 is blog/post-two/index.html with a h1 tag
  • Post 3 is blog/third-post/mythrid.html with a title: metadata "Post, the third"

I believe this will be fixed with #95

@Ajedi32 I think you can close this one and we track the Windows issues on #93