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
Allow custom slugs #4918
Allow custom slugs #4918
Conversation
Some clarification regarding the changes currently in this Pull Request:
|
First this updates the documentation to encourage users to get icons by their slug rather than their title. Second, I attempted to explain where the name comes from with a comment, not sure if that works... I do think this could be valuable in general (i.e. also for CDN usage and indiviual imports in NodeJS) but am unsure how best to explain it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick, initial comment for now.
@@ -55,6 +55,9 @@ | |||
{% assign filename = filename | replace: ".", "-dot-" %} | |||
{% assign filename = filename | replace: "&", "-and-" %} | |||
{% assign filename = filename | replace: " ", "" | replace: "!", "" | replace: ":", "" | replace: "’", "" | replace: "'", "" | replace: "°", "" %} | |||
{% if icon.slug %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be an if/else
statement (assuming Liquid supports them), to avoid all those replacements if slug
is present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liquid does support if/else
statements and we can write it using one, this is just the lazy version (from the programmer's perspective): Liquid will first do all the replacements on the filename - for all icons - and if the icon has a slug specified then the filename is replaced by the slug. It's just wasting a bunch of CPU cycles for icons that have a custom slug.
I'd be happy to change it if you prefer 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, given that we'll have switched over to the new site before we have enough slug
entries for this to be a major issue, I don't think it's such a big deal if we don't update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my reasoning for this going with this easier but more obscure solution as well 😄
Could we make this a breaking change in Also, and I know it's a bit late in the day for this but I had an idea last night: Instead of adding the |
I'm not sure if I follow. I'm not against using the slug as key for all icons but that is indeed a "breaking" change (arguably it is not as this usage is not in our documentation, it is just there to keep some backwards compatibility with earlier versions), implying we can't release this until v5. The current approach is not breaking and perfectly backwards compatible and arguably (bit of a stretch perhaps) also consistent as 1) all brand without custom slugs are there and 2) all brands with custom slugs are not there.
Interesting suggestion, it seems a bit opaque to me as "modifier" does not really tell you what it is doing and is meaningless on its own - in other words it is only ever useful to us and never to the end user. It is arguably more future proof as you said though. Personally, I'm not sure future proofing outweighs the "downsides" here. It should be fairly straightforward to updates custom slugs manually with a Regular Expression-based Find-and-Replace with the current approach. Also, I would actually also prefer using
No, or at least not so difficult as not to do it. |
I was suggesting we make that change separately in v5 so as not to block the merging of this one.
True. The use of
Me too, using |
👍
I actually really liked your suggestion of putting them in subfolders, in which case we can ignore that category entirely!
Agreed 👍 Additionally, actually using it might give us more insight into the trade-offs of putting different kinds of restrictions on the format of the slug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I don't really like the _
solution, this will work, and as the implementation LGTM, feel free to merge this @ericcornelissen 👍 but, this is a breaking change, right? If so, should not be marked as is?
Oh yes, you're right! |
Indeed this isn't breaking because we're not actually changing any slugs yet, just adding the option to.
Again, if there are other suggestions I'd be happy to hear them 🙂 |
Until #4936 is resolved, I think |
Merging this in based on @mondeja's approval above 🤞🏻 Thanks for finally getting this one resolved, @ericcornelissen 👍🏻 |
Issue: Fixes #2260
Alexa rank: n/a
Checklist
_data/simple-icons.json
viewbox
is0 0 24 24
Description
This updates the
.jsonlintschema
, build script, and tests to allow for "custom" slugs. This entails:"slug"
in_data/simple-icons.json
, andtitleToFilename
function.As a result, in the case that two brand names map to the same automatic slug, one of them can specify a custom slug that will be used instead. As per the discussion in #2260, we require an underscore (
_
) in custom slugs to avoid collisions with automatically computed slugs which will not be/are notallowed to contain a slug (any existing slugs that contain an underscore will be renamed in v5, after which underscores will always be automatically removed when converting a title to a slug).I'm not sure if we should even mention custom slugs in the Contributing Guidelines, as it doesn't apply to most contributions and may cause some contributors to include it when it's not necessary.