Skip to content

Commit

Permalink
add more fontawesome icons
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed May 24, 2024
1 parent 26fc6c8 commit 3cc51dd
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 31 deletions.
21 changes: 13 additions & 8 deletions packages/ui/fontawesome-cdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-brands-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/pro-duotone-svg-icons": "^6.5.1",
"@fortawesome/pro-light-svg-icons": "^6.5.1",
"@fortawesome/pro-regular-svg-icons": "^6.5.1",
"@fortawesome/pro-solid-svg-icons": "^6.5.1",
"@fortawesome/free-brands-svg-icons": "^6.5.2",
"@fortawesome/pro-duotone-svg-icons": "^6.5.2",
"@fortawesome/pro-light-svg-icons": "^6.5.2",
"@fortawesome/pro-regular-svg-icons": "^6.5.2",
"@fortawesome/pro-solid-svg-icons": "^6.5.2",
"@fortawesome/pro-thin-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/sharp-light-svg-icons": "^6.5.2",
"@fortawesome/sharp-regular-svg-icons": "^6.5.2",
"@fortawesome/sharp-solid-svg-icons": "^6.5.2",
"@fortawesome/sharp-thin-svg-icons": "^6.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand All @@ -49,11 +54,11 @@
"@types/react": "^18.0.20",
"depcheck": "^1.4.3",
"eslint": "^8.56.0",
"vitest": "^1.5.0",
"next": "^14.2.3",
"organize-imports-cli": "^0.10.0",
"prettier": "^3.2.4",
"stylelint": "^16.1.0",
"typescript": "5.4.3"
"typescript": "5.4.3",
"vitest": "^1.5.0"
}
}
16 changes: 16 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const metadata = {
title: 'Next.js',

Check failure on line 2 in packages/ui/fontawesome-cdn/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Strings must use doublequote
description: 'Generated by Next.js',

Check failure on line 3 in packages/ui/fontawesome-cdn/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Strings must use doublequote
}

Check failure on line 4 in packages/ui/fontawesome-cdn/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

export default function RootLayout({

Check failure on line 6 in packages/ui/fontawesome-cdn/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)

Check failure on line 15 in packages/ui/fontawesome-cdn/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
}
13 changes: 13 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/sharp-light/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fasl } from "@fortawesome/sharp-light-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fasl";
library.add(fasl);

export const runtime = "edge";

export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise<NextResponse> {
return svgResponse(prefix, params.icon);
}
13 changes: 13 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/sharp-regular/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fasr } from "@fortawesome/sharp-regular-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fasr";
library.add(fasr);

export const runtime = "edge";

export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise<NextResponse> {
return svgResponse(prefix, params.icon);
}
13 changes: 13 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/sharp-solid/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fass } from "@fortawesome/sharp-solid-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fass";
library.add(fass);

export const runtime = "edge";

export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise<NextResponse> {
return svgResponse(prefix, params.icon);
}
13 changes: 13 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/sharp-thin/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fast } from "@fortawesome/sharp-thin-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fast";
library.add(fast);

export const runtime = "edge";

export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise<NextResponse> {
return svgResponse(prefix, params.icon);
}
5 changes: 2 additions & 3 deletions packages/ui/fontawesome-cdn/src/app/solid/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fas } from "@fortawesome/free-solid-svg-icons";
import { fas as fasPro } from "@fortawesome/pro-solid-svg-icons";
import { fas } from "@fortawesome/pro-solid-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fas";
library.add(fas, fasPro);
library.add(fas);

export const runtime = "edge";

Expand Down
13 changes: 13 additions & 0 deletions packages/ui/fontawesome-cdn/src/app/thin/[icon]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { fat } from "@fortawesome/pro-thin-svg-icons";
import { NextRequest, NextResponse } from "next/server";
import { svgResponse } from "../../../svgResponse";

const prefix = "fat";
library.add(fat);

export const runtime = "edge";

export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise<NextResponse> {
return svgResponse(prefix, params.icon);
}
14 changes: 10 additions & 4 deletions packages/ui/fontawesome-cdn/src/svgResponse.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { AbstractElement, icon, IconPrefix } from "@fortawesome/fontawesome-svg-core";
import { AbstractElement, findIconDefinition, icon, IconPrefix } from "@fortawesome/fontawesome-svg-core";
import { IconName } from "@fortawesome/free-brands-svg-icons";
import { NextResponse } from "next/server";

export const runtime = "edge";

// This gets called on every request
export function svgResponse(prefix: IconPrefix, iconName: string): NextResponse {
if (!iconName.endsWith(".svg")) {
return new NextResponse(null, { status: 404 });
const icon = findIconDefinition({
prefix,
iconName: iconName as IconName,
});
if (icon === undefined) {
return new NextResponse(null, { status: 404 });
}

return NextResponse.json(icon);
}

const foundIcon = icon({ prefix, iconName: iconName.replace(".svg", "") as IconName });
Expand Down
90 changes: 74 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3cc51dd

Please sign in to comment.