Skip to content

Commit 3193e43

Browse files
committed
favicons added
1 parent 12fd1d0 commit 3193e43

34 files changed

+489
-7
lines changed

fav.png

539 KB
Loading

gen-favicons.mjs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { favicons } from "favicons";
2+
import { mkdirSync, writeFileSync } from "fs";
3+
import { basename, join } from "path";
4+
5+
export async function generateFavicons(
6+
metaDesc,
7+
version,
8+
baseImage = "fav.png",
9+
appName = basename(process.cwd()),
10+
basepath = join(process.cwd(), "public"),
11+
faviconsPath = "favicons",
12+
devName = "Darsan",
13+
devWebsite = "https://darsan.in"
14+
) {
15+
const options = {
16+
path: faviconsPath,
17+
18+
appName: appName,
19+
appDescription: metaDesc,
20+
version: version,
21+
22+
developerName: devName,
23+
developerURL: devWebsite,
24+
25+
background: "#fff",
26+
theme_color: "#fff",
27+
appleStatusBarStyle: "black-translucent",
28+
29+
display: "fullscreen",
30+
orientation: "natural",
31+
32+
start_url: "/",
33+
34+
manifestMaskable: true,
35+
36+
icons: {
37+
android: true,
38+
appleIcon: true,
39+
favicons: true,
40+
yandex: true,
41+
appleStartup: false,
42+
windows: false,
43+
},
44+
45+
shortcuts: {},
46+
};
47+
48+
try {
49+
const { images, files, html } = await favicons(baseImage, options);
50+
51+
const rootPath = join(basepath, faviconsPath);
52+
mkdirSync(rootPath, { recursive: true });
53+
54+
/* write images */
55+
images.forEach((image) => {
56+
writeFileSync(join(rootPath, image.name), image.contents, {
57+
encoding: "binary",
58+
});
59+
});
60+
61+
/* write config files */
62+
files.forEach((file) => {
63+
writeFileSync(join(rootPath, file.name), file.contents, {
64+
encoding: "utf8",
65+
});
66+
});
67+
68+
const faviconsHtmlLinks = html.join("");
69+
writeFileSync(join(basepath, "links.html"), faviconsHtmlLinks);
70+
} catch (err) {
71+
console.error(err);
72+
process.exit(1);
73+
}
74+
}
75+
76+
generateFavicons(
77+
"Hawk JS is the ultimate tool for web developers and SEO enthusiasts. Find out how it can streamline your SEO efforts, ensuring your website gains visibility and improves its search engine ranking.",
78+
"1.0.7"
79+
);

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
},
2323
"homepage": "https://cresteem.com/opensource/hawk-js",
2424
"devDependencies": {
25-
"typescript": "latest",
26-
"react": "latest",
27-
"react-dom": "latest",
25+
"@types/node": "latest",
2826
"next": "latest",
2927
"nextra": "latest",
3028
"nextra-theme-docs": "latest",
29+
"react": "latest",
30+
"react-dom": "latest",
3131
"react-icons": "^5.2.0",
3232
"sass": "latest",
33-
"@types/node": "latest"
33+
"typescript": "latest"
34+
},
35+
"dependencies": {
36+
"favicons": "^7.2.0"
3437
}
35-
}
38+
}
5 KB
Loading
6.96 KB
Loading
9.62 KB
Loading
1.1 KB
Loading
15.4 KB
Loading
1.51 KB
Loading
21.7 KB
Loading

0 commit comments

Comments
 (0)