-
Notifications
You must be signed in to change notification settings - Fork 43
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
multi-word tags should be hyphenated #23
Comments
If you're using Handlebars.registerHelper("safe", function (context) {
return context.replace(/ /g, '-');
}); And use it in a template (where this is the string with the tag name): {{#each tags}}
<a href="/tags/{{safe this}}">{{this}}</a>
{{/each}} |
@brianbrewer I think that your answer is a workaround to make the plugin usable. But I think this plugin should be usable by default, without the need of registering an additionnal helper. |
I completely understand, linking to a tag page is hassle without manipulating the tag string some other way, so I've made a fork and added a Using it should just be a case of: .use(tags({
handle: 'tags',
path:'topics/:tag.html',
layout:'/partials/tag.hbt',
sortBy: 'date',
reverse: true,
skipMetadata: false,
hyphenate: true
})); Hopefully that should make all tags with spaces in them hyphenates at all points, I was thinking about maybe adding hyphenated and spaced tags to the metadata separately for completeness. I'll just mention @hswolff to get his opinion on this. |
Your fork fixes the problem on my side, you should create a pull request as it should be merged. The Not only all tags with spaces should be hyphenated, but your option |
I checked an old website generated by metalsmith and metalsmith-tags and it appears that the default behaviour of metalsmith-tags used to hyphenate multi-word tags. As a consequence, not hyphenatig multi-word tags is something I would call a bug. |
I see, I've looked through the changes made that affected this version 0.9.0, it looks #5 is a previous issue about how spaces are represented using The suggested way to link to them is to rely on I'm currently going through the process of changing the plugin so it uses hyphens as default, with some sort of |
I'm hardly waiting for your pull request to be merged. @brianbrewer you might have forgotten to make your pull request... |
@brianbrewer your previous comment makes me think about #21 and metalsmith/permalinks#37. I had suspected that metalsmith-permalinks and metalsmith-tags were closely tied. Do you know how they should be used ? In what order ? With what configuration ? |
Really not sure, my configuration has Sorry I couldn't be of more help |
@brianbrewer I know that we're talking about something else than the main subject of this issue, but why would |
Just to credit another plugin, this issue has been discovered adding the metalsmith-broken-link-checker plugin. It found some broken links and these links were all tag related. Thanks for that @davidxmoody ! |
So just pushed up See my usage of it on my blog: hswolff/blog@29f7799 Another solution I was considering was to change the
But I felt that would be a bigger change. Let me know what you think! |
Thank you @hswolff for fixing this bug. I can confirm that your fix is also fixing the bug on my side. I just had to replace the I still wonder why you created another tag What for is the old |
For display purposes, that's what issue #5 was concerned with. If the tag name is |
Ok, I understand the point. But I don't think it is a good idea. If the tag name is I don't mind as your implementation makes any solution possible. But I don't really see any usecase where issue #5 happens. However, if someone created this issue, it means that he should have met this usecase... And by the way, I don't have any opinion on what is the best solution between the current one, and the other solution you're talking about. I let you and other experts decide. |
Right now we're just using |
With old version of metalsmith-tags (something like 0.6.x), multi-word tags were hyphenated :
the tag
my tag
would be converted tomy-tag
With the last version of metalsmith-tags (0.10.x or 0.11.x), tags are not hyphenated any-more.
This causes some problem, espcially when linking to the tag page. The generated page is hypenated indeed :
topics/my-tag/index.html
whereas the link to this page is not hyphenatedtopics/my tag/
.This leads to invalid links.
As a consequence, the fix should hyphenate the link to the tag 'my-tag :
should become :
The label
my tag
could also be converted tomy-tag
or not, I don't have any strong opinion on this.The text was updated successfully, but these errors were encountered: