Skip to content

Commit

Permalink
feat(projects): add generate logo script
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 3, 2023
1 parent 9110d87 commit 25daa23
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="https://i.loli.net/2021/11/24/x5lLfuSnEawBAgi.png"/>
<img src="./public/logo.png" style="width: 240px;"/>
<h1>Soybean Admin</h1>
</div>

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"lint": "eslint . --fix",
"commit": "soybean git-commit",
"esno": "esno",
"logo": "esno ./scripts/logo.ts",
"cleanup": "esno ./scripts/cleanup.ts",
"compress": "esno ./scripts/compress.ts",
"git-hooks": "esno ./scripts/git-hooks.ts",
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
Binary file modified public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions scripts/logo.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { readFile } from 'fs/promises';
import nodeHtmlToImage from 'node-html-to-image';
import themeSettings from '../src/settings/theme.json';

async function generatePngLogoFromSvg(svgPath: string, color: string) {
const svgStr = await readFile(svgPath, 'utf-8');

const svgStrWithColor = svgStr.replace(/currentColor/g, color);

nodeHtmlToImage({
output: './public/logo1.png',
await nodeHtmlToImage({
output: './public/logo.png',
html: svgStrWithColor,
transparent: true
});
}

generatePngLogoFromSvg('./src/assets/svg-icon/logo.svg', '#1890ff');
generatePngLogoFromSvg('./src/assets/svg-icon/logo.svg', themeSettings.themeColor);

1 comment on commit 25daa23

@vercel
Copy link

@vercel vercel bot commented on 25daa23 Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.