Skip to content

Commit 8d77a53

Browse files
feat(frontend): add shortcut icon function
1 parent 6fabca3 commit 8d77a53

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/frontend/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "node:url";
22

33
export const assetsPath = fileURLToPath(new URL("assets", import.meta.url));
4-
export { appIcon } from "./lib/app-icon.js";
4+
export { appIcon, shortcutIcon } from "./lib/sharp.js";
55
export { templates } from "./lib/nunjucks.js";
66
export { styles } from "./lib/lightningcss.js";
77
export { scripts } from "./lib/rollup.js";

packages/frontend/lib/app-icon.js packages/frontend/lib/sharp.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "node:fs";
22
import { fileURLToPath } from "node:url";
33
import sharp from "sharp";
4+
import { icon } from "./globals/icon.js";
45

56
/**
67
* Get application icon image
@@ -21,3 +22,16 @@ export const appIcon = async (size, themeColor, purpose = "any") => {
2122
.png({ colours: 16 })
2223
.toBuffer();
2324
};
25+
26+
/**
27+
* Get shortcut icon image
28+
* @param {string|number} size - Icon size
29+
* @param {string} name - Icon name
30+
* @returns {Promise<Buffer>} PNG file
31+
*/
32+
export const shortcutIcon = async (size, name) => {
33+
return sharp(Buffer.from(icon(name)))
34+
.resize(Number(size))
35+
.png({ colours: 16 })
36+
.toBuffer();
37+
};

0 commit comments

Comments
 (0)