Add documentation and tooling for SVG filenames (#2601)

* Create simple CLI tool to get the filename from a brandname

https://github.com/simple-icons/simple-icons/pull/2589#issuecomment-585902427

* Update contributing guidelines on new SVGs' filenames

* Fix incorrect filename in package.json script

* Add file header to get-filename script

* Update contributing guidelines' section on SVG filenames

Co-Authored-By: YoussefRaafatNasry <youssefraafatnasry@gmail.com>
This commit is contained in:
Eric Cornelissen 2020-02-26 18:54:54 +02:00 committed by GitHub
parent c6af93f240
commit 7ebf7f71fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 1 deletions

View File

@ -150,6 +150,39 @@ Here is the object for The Movie Database as an example:
Make sure the icon is added in alphabetical order. If you're in doubt, you can always run `npm run our-lint` - this will tell you if any of the JSON data is in the wrong order.
#### SVG Filename Convention
The filename of the SVG should correspond to the `title` used in the JSON file mentioned above, and it should follow the rules below. If you're in doubt, you can always run `npm run get-filename -- Brand name` to get the correct filename.
1. Use **lowercase letters** without **whitespace**, for example:
```yml
title: Adobe Photoshop
filename: adobephotoshop.svg
```
1. Only use **latin** letters, for example:
```yml
title: Citroën
filename: citroen.svg
```
1. Replace the following symbols with their alias depending on their position in the title:
| Symbol | Start | Middle | End |
| :----: | ----- | ------ | ---- |
| + | plus | plus | plus |
| . | dot- | -dot- | -dot |
| & | and- | -and- | -and |
for example:
```yml
title: .Net
filename: dot-net.svg
```
#### Source Guidelines
We use the source URL as a reference for the current SVG in our repository and as a jumping-off point to find updates if the logo changes. If you used one of the sources listed below, make sure to follow these guidelines. If you're unsure about the source URL you can open a Pull Request and ask for help from others.

View File

@ -37,6 +37,7 @@
"test": "jest",
"pretest": "npm run prepublishOnly",
"posttest": "npm run postpublish",
"svgo": "svgo --config=./.svgo.yml"
"svgo": "svgo --config=./.svgo.yml",
"get-filename": "node scripts/get-filename.js"
}
}

22
scripts/get-filename.js Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env node
/**
* @fileoverview
* Takes a brand name as argument and outputs the corresonding filename to
* standard output.
*/
const utils = require('./utils.js');
if (process.argv.length < 3) {
console.error("Provide a brand name as argument")
} else {
let brandName = "";
for (let i = 2; i < process.argv.length; i++) {
brandName += ` ${process.argv[i]}`;
}
brandName = brandName.substring(1);
const filename = utils.titleToFilename(brandName);
console.log(`For '${brandName}' use the filename '${filename}.svg'`);
}