osteele / gojekyll

A fast Go implementation of the Jekyll blogging engine
MIT License
332 stars 14 forks source link

Remove leading and trailing hyphens from slugs to match jekyll behavior #56

Closed sirwart closed 10 months ago

sirwart commented 10 months ago

When I tried to use gojekyll with my blog, a post that had a question mark at the end had the wrong slug and therefore links` to the post broke. This was due to the fact that jekyll will strip leading and trailing hyphens after it replaces non-alphanumeric with hyphens. You can see this behavior here:

https://github.com/jekyll/jekyll/blob/646b4241669ac54247d8bf1ce3e4c616ac71d9fe/lib/jekyll/utils.rb#L219

To fix this, I added similar behavior to the Slugify function in gojekyll, and after that my site built with the correct routes.

Checklist

danog commented 10 months ago

Thanks!