Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
yui10 committed Apr 8, 2024
2 parents f885d11 + e9b9e9b commit 432ccf8
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 97 deletions.
150 changes: 75 additions & 75 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icons-karuta",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -10,15 +10,15 @@
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@emotion/styled": "^11.11.5",
"@icons-pack/react-simple-icons": "^9.4.0",
"@mui/icons-material": "^5.15.14",
"@mui/material": "^5.15.14",
"@mui/icons-material": "^5.15.15",
"@mui/material": "^5.15.15",
"@vercel/analytics": "^1.2.2",
"next": "14.1.4",
"react": "^18",
"react-dom": "^18",
"simple-icons": "^11.10.0"
"simple-icons": "^11.12.0"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
31 changes: 31 additions & 0 deletions src/app/api/icons/slugs/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as fs from "fs";
import { NextRequest, NextResponse } from "next/server";
import { IconData, getIconDataPath } from 'simple-icons/sdk';
let icons: IconData[] = [];
const loadIcons = () => {
try {
const data = fs.readFileSync(getIconDataPath("node_modules/simple-icons"), { encoding: "utf8" });
const icons: IconData[] = JSON.parse(data)["icons"];
return icons;
}
catch (err) {
console.error(err);
return [];
}
}

loadIcons();

export async function GET(request: NextRequest) {
const headers = new Headers();
headers.set('Cache-Control', 's-maxage=31536000, stale-while-revalidate');

if (icons.length == 0) {
const load = fs.readFileSync(getIconDataPath("node_modules/simple-icons"), { encoding: "utf8" });
icons = JSON.parse(load)["icons"];
}

headers.set('Content-Type', 'application/json');
return NextResponse.json(icons, { status: 200, headers });
}

Loading

0 comments on commit 432ccf8

Please sign in to comment.