-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-favicons.mjs
79 lines (64 loc) · 1.81 KB
/
gen-favicons.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { favicons } from "favicons";
import { mkdirSync, writeFileSync } from "fs";
import { basename, join } from "path";
export async function generateFavicons(
metaDesc,
version,
baseImage = "fav.png",
appName = basename(process.cwd()),
basepath = join(process.cwd(), "public"),
faviconsPath = "favicons",
devName = "Darsan",
devWebsite = "https://darsan.in"
) {
const options = {
path: faviconsPath,
appName: appName,
appDescription: metaDesc,
version: version,
developerName: devName,
developerURL: devWebsite,
background: "#fff",
theme_color: "#fff",
appleStatusBarStyle: "black-translucent",
display: "fullscreen",
orientation: "natural",
start_url: "/",
manifestMaskable: true,
icons: {
android: true,
appleIcon: true,
favicons: true,
yandex: true,
appleStartup: false,
windows: false,
},
shortcuts: {},
};
try {
const { images, files, html } = await favicons(baseImage, options);
const rootPath = join(basepath, faviconsPath);
mkdirSync(rootPath, { recursive: true });
/* write images */
images.forEach((image) => {
writeFileSync(join(rootPath, image.name), image.contents, {
encoding: "binary",
});
});
/* write config files */
files.forEach((file) => {
writeFileSync(join(rootPath, file.name), file.contents, {
encoding: "utf8",
});
});
const faviconsHtmlLinks = html.join("");
writeFileSync(join(basepath, "links.html"), faviconsHtmlLinks);
} catch (err) {
console.error(err);
process.exit(1);
}
}
generateFavicons(
"Discover how BONSE can help you optimize your website for search engines and improve your online visibility. Learn more about our SEO tool and start boosting your rankings today!",
"0.0.1"
);