Skip to content

Commit 822e7d7

Browse files
committed
added the support of base64 svg logos
1 parent 83dfacd commit 822e7d7

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[*]
22
charset = utf-8
3-
insert_final_newline = false
3+
insert_final_newline = true
44
end_of_line = lf
55
indent_style = space
66
indent_size = 2

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [📚 Adding a new theme](#-adding-a-new-theme)
3333
- [🧠 Tips](#-tips)
3434
- [🪢 Align the card in the markdown](#-align-the-card-in-the-markdown)
35+
- [🎭 Adding custom SVG logo](#-adding-custom-svg-logo)
3536
- [⚒️ Building from source](#️-building-from-source)
3637
- [📝 License](#-license)
3738
- [🧑‍🤝‍🧑 Contributing](#-contributing)
@@ -222,6 +223,16 @@ If you're using markdown, you may want to align your cards. There's an easy way
222223
<img align="center" src="https://github-readme-tech-stack.vercel.app/api/cards" alt="My Tech Stack" />
223224
```
224225

226+
### 🎭 Adding custom SVG logo
227+
Let's assume that you have a [line created](#-how-to-customize-a-line) and want to use your own SVGs. We support that using [Base64](https://en.wikipedia.org/wiki/Base64) format.
228+
**[\*](https://stackoverflow.com/questions/38985050/how-do-i-use-the-logo-option-in-shields-io-badges) Here's an easy 3-step guide:**
229+
1. Download the image and use one of the many online tools, e.g. [http://b64.io/](http://b64.io/), to encode it.
230+
2. Encode the Base64 string in [percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding). Take the Base64 string and use one of the many online tools, e.g. [http://meyerweb.com/eric/tools/dencoder/](http://meyerweb.com/eric/tools/dencoder/), to encode the string.
231+
3. Finally, replace the first element of the badge (the `logoName`) with this string. (e.g `<Base64>,typescript,2D79C7;`)
232+
233+
>> **Note**
234+
>> Sometimes the encoded string, of either step 2 or 3, may be too long to be used. You should then try to reduce the size (total pixels) of the image and try again.
235+
225236
<hr>
226237

227238
## ⚒️ Building from source
@@ -262,4 +273,4 @@ I was inspired by dozens of other projects, check 'em out as well!
262273
- [github-readme-stats](https://github.com/anuraghazra/github-readme-stats)
263274
- [github-profile-summary-cards](https://github.com/vn7n24fzkq/github-profile-summary-cards)
264275
- [markdown-badges](https://github.com/Ileriayo/markdown-badges)
265-
- [shields.io](https://shields.io/)
276+
- [shields.io](https://shields.io/)

client/package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,18 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^5.16.5",
7-
"@testing-library/react": "^13.4.0",
8-
"@testing-library/user-event": "^13.5.0",
9-
"@types/jest": "^27.5.2",
106
"@types/node": "^16.18.3",
117
"@types/react": "^18.0.25",
128
"@types/react-dom": "^18.0.9",
139
"react": "^18.2.0",
1410
"react-dom": "^18.2.0",
1511
"react-icons": "^4.6.0",
1612
"react-scripts": "5.0.1",
17-
"typescript": "^4.9.3",
18-
"web-vitals": "^2.1.4"
13+
"typescript": "^4.9.3"
1914
},
2015
"scripts": {
2116
"start": "react-scripts start",
22-
"build": "react-scripts build",
23-
"test": "react-scripts test",
24-
"eject": "react-scripts eject"
17+
"build": "react-scripts build"
2518
},
2619
"eslintConfig": {
2720
"extends": [

client/public/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
<meta name="coverage" content="Worldwide" />
2323
<meta name="distribution" content="Global" />
2424
<meta name="rating" content="General" />
25-
<title>
26-
GitHub Readme Tech Stack
27-
</title>
25+
<title>GitHub Readme Tech Stack</title>
2826
</head>
2927
<body>
3028
<noscript>You need to enable JavaScript to run this app.</noscript>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-readme-tech-stack",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "",
55
"main": "src/app.ts",
66
"scripts": {

src/utils/validator.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export const validateAlign = (align: string): BadgeAlign => {
4949
* @returns {Badge[]} The converted badges
5050
*/
5151
export const validateLine = (line: string): Badge[] => {
52+
// replace the comma and the semicolon if the line contains "base64"
53+
line = line.replace(";base64,", "-base64-");
54+
5255
// split the line by semicolon
5356
// each item in this array is one single badge
5457
const splitBySemi = line.split(";");
@@ -65,15 +68,19 @@ export const validateLine = (line: string): Badge[] => {
6568
for (const badgeLine of splitBySemi) {
6669
// this should have 3 items
6770
const splitByComma = badgeLine.split(",");
71+
6872
if (splitByComma.length !== 3) {
6973
continue;
7074
}
7175

76+
// add the comma and the semicolon back
77+
const logoName = splitByComma[0].replace("-base64-", ";base64,");
78+
7279
const logoColor =
7380
splitByComma[2] === "auto" ? "" : formatHexColor(splitByComma[2]);
7481

7582
badges.push({
76-
logoName: splitByComma[0],
83+
logoName: logoName,
7784
label: splitByComma[1],
7885
logoColor: logoColor,
7986
});

0 commit comments

Comments
 (0)