mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-04-14 00:29:33 +03:00
Document slugs of brands (#5002)
This commit is contained in:
parent
d56a2b3b9d
commit
52a0c5b07b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6,6 +6,7 @@
|
|||||||
# Don't diff machine generated files
|
# Don't diff machine generated files
|
||||||
package-lock.json -diff
|
package-lock.json -diff
|
||||||
Gemfile.lock -diff
|
Gemfile.lock -diff
|
||||||
|
slugs.md -diff
|
||||||
|
|
||||||
# Treat images as binary
|
# Treat images as binary
|
||||||
*.ico binary
|
*.ico binary
|
||||||
|
27
.github/workflows/create-release.yml
vendored
27
.github/workflows/create-release.yml
vendored
@ -5,9 +5,34 @@ on:
|
|||||||
- cron: "0 0 * * 0"
|
- cron: "0 0 * * 0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release-pr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
did-create-pr: ${{ steps.release.outputs.did-create-pr }}
|
||||||
|
new-version: ${{ steps.release.outputs.new-version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: simple-icons/release-action@master
|
- uses: simple-icons/release-action@master
|
||||||
|
id: release
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version-bump:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release-pr
|
||||||
|
if: needs.release-pr.outputs.did-create-pr == 'true'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# Ensure we are checked out on the develop branch
|
||||||
|
ref: develop
|
||||||
|
- name: Bump version
|
||||||
|
run: node ./scripts/bump-version.js "${{ needs.release-pr.outputs.new-version }}"
|
||||||
|
- name: Update slugs table
|
||||||
|
run: node ./scripts/build-slugs-table.js
|
||||||
|
- name: Commit version bump
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4.8.0
|
||||||
|
with:
|
||||||
|
commit_message: version bump
|
||||||
|
commit_user_name: GitHub Actions
|
||||||
|
commit_user_email: actions@github.com
|
||||||
|
commit_author: GitHub Actions <actions@github.com>
|
||||||
|
27
README.md
27
README.md
@ -24,11 +24,11 @@ Icons can be downloaded as SVGs directly from [our website](https://simpleicons.
|
|||||||
Icons can be served from a CDN such as [JSDelivr](https://www.jsdelivr.com/package/npm/simple-icons) or [Unpkg](https://unpkg.com/browse/simple-icons/). Simply use the `simple-icons` npm package and specify a version in the URL like the following:
|
Icons can be served from a CDN such as [JSDelivr](https://www.jsdelivr.com/package/npm/simple-icons) or [Unpkg](https://unpkg.com/browse/simple-icons/). Simply use the `simple-icons` npm package and specify a version in the URL like the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<img height="32" width="32" src="https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/[ICON NAME].svg" />
|
<img height="32" width="32" src="https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/[ICON SLUG].svg" />
|
||||||
<img height="32" width="32" src="https://unpkg.com/simple-icons@v4/icons/[ICON NAME].svg" />
|
<img height="32" width="32" src="https://unpkg.com/simple-icons@v4/icons/[ICON SLUG].svg" />
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `[ICON NAME]` is replaced by the icon name, for example:
|
Where `[ICON SLUG]` is replaced by the [slug] of the icon you want to use, for example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<img height="32" width="32" src="https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/simpleicons.svg" />
|
<img height="32" width="32" src="https://cdn.jsdelivr.net/npm/simple-icons@v4/icons/simpleicons.svg" />
|
||||||
@ -45,13 +45,13 @@ The icons are also available through our npm package. To install, simply run:
|
|||||||
$ npm install simple-icons
|
$ npm install simple-icons
|
||||||
```
|
```
|
||||||
|
|
||||||
The API can then be used as follows:
|
The API can then be used as follows, where `[ICON SLUG]` is replaced by a [slug]:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const simpleIcons = require('simple-icons');
|
const simpleIcons = require('simple-icons');
|
||||||
|
|
||||||
// Get a specific icon by its name as:
|
// Get a specific icon by its slug as:
|
||||||
simpleIcons.get('[ICON NAME]');
|
simpleIcons.get('[ICON SLUG]');
|
||||||
|
|
||||||
// For example:
|
// For example:
|
||||||
const icon = simpleIcons.get('simpleicons');
|
const icon = simpleIcons.get('simpleicons');
|
||||||
@ -76,12 +76,12 @@ NOTE: the `license` entry will be `undefined` if we do not yet have license data
|
|||||||
*/
|
*/
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively you can import the needed icons individually.
|
Alternatively you can import the needed icons individually, where `[ICON SLUG]` is replaced by a [slug].
|
||||||
This is useful if you are e.g. compiling your code with [webpack](https://webpack.js.org/) and therefore have to be mindful of your package size:
|
This is useful if you are e.g. compiling your code with [webpack](https://webpack.js.org/) and therefore have to be mindful of your package size:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Import a specific icon by its name as:
|
// Import a specific icon by its slug as:
|
||||||
require('simple-icons/icons/[ICON NAME]');
|
require('simple-icons/icons/[ICON SLUG]');
|
||||||
|
|
||||||
// For example:
|
// For example:
|
||||||
const icon = require('simple-icons/icons/simpleicons');
|
const icon = require('simple-icons/icons/simpleicons');
|
||||||
@ -134,12 +134,15 @@ The icons are also available through our Packagist package. To install, simply r
|
|||||||
$ composer require simple-icons/simple-icons
|
$ composer require simple-icons/simple-icons
|
||||||
```
|
```
|
||||||
|
|
||||||
The package can then be used as follows:
|
The package can then be used as follows, where `[ICON SLUG]` is replaced by a [slug]:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
// Import a specific icon by its slug as:
|
||||||
|
echo file_get_contents('path/to/package/icons/[ICON SLUG].svg');
|
||||||
|
|
||||||
echo file_get_contents('path/to/package/icons/simple-icons.svg');
|
// For example:
|
||||||
|
echo file_get_contents('path/to/package/icons/simpleicons.svg');
|
||||||
|
|
||||||
// <svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">...</svg>
|
// <svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">...</svg>
|
||||||
?>
|
?>
|
||||||
@ -178,3 +181,5 @@ Icons are also available as a [Vue package](https://github.com/mainvest/vue-simp
|
|||||||
### WordPress
|
### WordPress
|
||||||
|
|
||||||
Icons are also available as a [WordPress plugin](https://wordpress.org/plugins/simple-icons/) created by [@tjtaylo](https://github.com/tjtaylo).
|
Icons are also available as a [WordPress plugin](https://wordpress.org/plugins/simple-icons/) created by [@tjtaylo](https://github.com/tjtaylo).
|
||||||
|
|
||||||
|
[slug]: ./slugs.md
|
||||||
|
33
scripts/build-slugs-table.js
Normal file
33
scripts/build-slugs-table.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* @fileoverview
|
||||||
|
* Generates a MarkDown file that lists every brand name and their slug.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const dataFile = path.resolve(__dirname, "..", "_data", "simple-icons.json");
|
||||||
|
const slugsFile = path.resolve(__dirname, "..", "slugs.md");
|
||||||
|
|
||||||
|
const data = require(dataFile);
|
||||||
|
const { getIconSlug } = require("./utils.js");
|
||||||
|
|
||||||
|
let content = `<!--
|
||||||
|
This file is automatically generated. If you want to change something, please
|
||||||
|
update the script at '${__filename.replace(__dirname, "scripts")}'.
|
||||||
|
-->
|
||||||
|
|
||||||
|
# Simple Icons slugs
|
||||||
|
|
||||||
|
| Brand name | Brand slug |
|
||||||
|
| :--- | :--- |
|
||||||
|
`;
|
||||||
|
|
||||||
|
data.icons.forEach(icon => {
|
||||||
|
const brandName = icon.title;
|
||||||
|
const brandSlug = getIconSlug(icon);
|
||||||
|
content += `| \`${brandName}\` | \`${brandSlug}\` |\n`
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.writeFileSync(slugsFile, content);
|
41
scripts/bump-version.js
Normal file
41
scripts/bump-version.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* @fileoverview
|
||||||
|
* Updates the version of this package to the CLI specified version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const PACKAGE_JSON_FILE = path.resolve(__dirname, '..', 'package.json');
|
||||||
|
const PACKAGE_LOCK_FILE = path.resolve(__dirname, '..', 'package-lock.json');
|
||||||
|
|
||||||
|
function readManifest(file) {
|
||||||
|
const manifestRaw = fs.readFileSync(file).toString();
|
||||||
|
const manifestJson = JSON.parse(manifestRaw);
|
||||||
|
return manifestJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeManifest(file, json) {
|
||||||
|
const manifestRaw = JSON.stringify(json, null, 2) + '\n';
|
||||||
|
fs.writeFileSync(file, manifestRaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main(newVersion) {
|
||||||
|
try {
|
||||||
|
const manifest = readManifest(PACKAGE_JSON_FILE);
|
||||||
|
const manifestLock = readManifest(PACKAGE_LOCK_FILE);
|
||||||
|
|
||||||
|
manifest.version = newVersion
|
||||||
|
manifestLock.version = newVersion
|
||||||
|
|
||||||
|
writeManifest(PACKAGE_JSON_FILE, manifest);
|
||||||
|
writeManifest(PACKAGE_LOCK_FILE, manifestLock);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to bump package version to ${newVersion}:`, error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main(process.argv[2]);
|
Loading…
Reference in New Issue
Block a user