Skip to content

Commit

Permalink
better shortname handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tandpfun committed Mar 5, 2022
1 parent b547521 commit f1789d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Cloudflare Worker
worker/
42 changes: 12 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
const icons = require("./dist/icons.json");
const longNames = {
const iconNameList = Object.keys(icons).map((i) => i.split("-")[0]);
const shortNames = {
js: "javascript",
ts: "typescript",
nodejs: "nodejs",
py: "python",
html: "html",
css: "css",
tailwind: "tailwindcss",
vue: "vuejs",
nuxt: "nuxtjs",
prisma: "prisma",
docker: "docker",
figma: "figma",
go: "golang",
rust: "rust",
react: "react",
cloudflare: "cloudflare",
java: "java",
php: "php",
ruby: "ruby",
cf: "cloudflare",
cs: "C#",
cpp: "c++",
c: "c",
swift: "swift",
kotlin: "kotlin",
dart: "dart",
wasm: "webassembly",
mysql: "mysql",
postgres: "postgresql",
redis: "redis",
jquery: "jquery",
angular: "angular",
svelte: "svelte",
git: "git",
k8s: "kubernetes",
deno: "deno",
vim: "vim",
};

const themedIcons = [
"nodejs",
"python",
Expand Down Expand Up @@ -88,11 +66,15 @@ function generateSvg(iconNames) {
}

function parseShortNames(names, theme = "dark") {
return names.map(
(name) =>
longNames[name] +
(themedIcons.includes(longNames[name]) ? `-${theme}` : "")
);
return names.map((name) => {
if (iconNameList.includes(name))
return name + (themedIcons.includes(name) ? `-${theme}` : "");
else if (name in shortNames)
return (
shortNames[name] +
(themedIcons.includes(shortNames[name]) ? `-${theme}` : "")
);
});
}

async function handleRequest(request) {
Expand Down
1 change: 0 additions & 1 deletion worker/script.js

This file was deleted.

0 comments on commit f1789d9

Please sign in to comment.