@mintlify/prebuild 1.0.507 → 1.0.508
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { MintConfig } from '@mintlify/models';
|
|
2
|
-
import { DocsConfig } from '@mintlify/validation';
|
|
3
|
-
|
|
2
|
+
import type { DocsConfig } from '@mintlify/validation';
|
|
3
|
+
import { type FaviconResponse, type FaviconOptions } from 'favicons';
|
|
4
|
+
export declare function generateFavicons(config: MintConfig | DocsConfig, contentDirectoryPath: string): Promise<FaviconResponse[] | undefined>;
|
|
5
|
+
export declare function getFaviconsConfig(name: string): FaviconOptions;
|
|
@@ -1,74 +1,61 @@
|
|
|
1
1
|
import favicons from 'favicons';
|
|
2
|
-
import {
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
|
|
5
|
-
export const generateFavicons = async (config, contentDirectoryPath) => {
|
|
4
|
+
export async function generateFavicons(config, contentDirectoryPath) {
|
|
6
5
|
if (config.favicon == null)
|
|
7
6
|
return;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
7
|
+
const faviconsConfig = getFaviconsConfig(config.name);
|
|
8
|
+
try {
|
|
9
|
+
if (typeof config.favicon === 'string') {
|
|
10
|
+
const desiredPath = join(contentDirectoryPath, config.favicon);
|
|
11
|
+
const favicon = await readFile(desiredPath);
|
|
12
|
+
const icons = await favicons(favicon, faviconsConfig);
|
|
13
13
|
return [icons];
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
if (typeof err === 'object' && err != null && 'message' in err)
|
|
17
|
-
console.log(err.message); // Error description e.g. "An unknown error has occurred"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// Light and dark favicons case
|
|
22
|
-
try {
|
|
15
|
+
else {
|
|
23
16
|
const lightPath = join(contentDirectoryPath, config.favicon.light);
|
|
24
17
|
const darkPath = join(contentDirectoryPath, config.favicon.dark);
|
|
25
18
|
const lightFavicon = await readFile(lightPath);
|
|
26
19
|
const darkFavicon = await readFile(darkPath);
|
|
27
20
|
const [lightIcons, darkIcons] = await Promise.all([
|
|
28
|
-
favicons(lightFavicon,
|
|
29
|
-
favicons(darkFavicon, {
|
|
30
|
-
...faviconConfig(config.name),
|
|
31
|
-
path: '/favicons-dark',
|
|
32
|
-
}),
|
|
21
|
+
favicons(lightFavicon, faviconsConfig),
|
|
22
|
+
favicons(darkFavicon, { ...faviconsConfig, path: '/favicons-dark' }),
|
|
33
23
|
]);
|
|
34
24
|
return [lightIcons, darkIcons];
|
|
35
25
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err instanceof Error) {
|
|
29
|
+
console.log(err.message);
|
|
39
30
|
}
|
|
40
31
|
}
|
|
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
|
-
yandex: false,
|
|
72
|
-
firefox: false,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
32
|
+
}
|
|
33
|
+
export function getFaviconsConfig(name) {
|
|
34
|
+
return {
|
|
35
|
+
path: '/favicons',
|
|
36
|
+
appName: name,
|
|
37
|
+
appShortName: name,
|
|
38
|
+
dir: 'auto',
|
|
39
|
+
lang: 'en-US',
|
|
40
|
+
background: 'transparent',
|
|
41
|
+
theme_color: 'transparent',
|
|
42
|
+
appleStatusBarStyle: 'black-translucent',
|
|
43
|
+
display: 'standalone',
|
|
44
|
+
orientation: 'any',
|
|
45
|
+
scope: '/',
|
|
46
|
+
start_url: '/?homescreen=1',
|
|
47
|
+
preferRelatedApplications: false,
|
|
48
|
+
version: '1.0',
|
|
49
|
+
pixel_art: false,
|
|
50
|
+
loadManifestWithCredentials: true,
|
|
51
|
+
manifestMaskable: false,
|
|
52
|
+
icons: {
|
|
53
|
+
android: ['android-chrome-192x192.png', 'android-chrome-256x256.png'],
|
|
54
|
+
appleIcon: ['apple-touch-icon.png'],
|
|
55
|
+
appleStartup: false,
|
|
56
|
+
favicons: true,
|
|
57
|
+
windows: ['mstile-150x150.png'],
|
|
58
|
+
yandex: false,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|