@mintlify/prebuild 1.0.507 → 1.0.509

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
@@ -2,3 +2,4 @@ export * from './fs/index.js';
2
2
  export * from './generate.js';
3
3
  export * from './utils.js';
4
4
  export * from './prebuild/index.js';
5
+ export { getFaviconsConfig } from './prebuild/generateFavicons.js';
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './fs/index.js';
2
2
  export * from './generate.js';
3
3
  export * from './utils.js';
4
4
  export * from './prebuild/index.js';
5
+ export { getFaviconsConfig } from './prebuild/generateFavicons.js';
@@ -1,3 +1,5 @@
1
1
  import type { MintConfig } from '@mintlify/models';
2
- import { DocsConfig } from '@mintlify/validation';
3
- export declare const generateFavicons: (config: MintConfig | DocsConfig, contentDirectoryPath: string) => Promise<import("favicons").FaviconResponse[] | undefined>;
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 { promises as _promises } from 'fs';
2
+ import { readFile } from 'fs/promises';
3
3
  import { join } from 'path';
4
- const { readFile } = _promises;
5
- export const generateFavicons = async (config, contentDirectoryPath) => {
4
+ export async function generateFavicons(config, contentDirectoryPath) {
6
5
  if (config.favicon == null)
7
6
  return;
8
- if (typeof config.favicon === 'string') {
9
- const desiredPath = join(contentDirectoryPath, config.favicon);
10
- const favicon = await readFile(desiredPath);
11
- try {
12
- const icons = await favicons(favicon, faviconConfig(config.name));
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
- catch (err) {
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, faviconConfig(config.name)),
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
- catch (err) {
37
- if (typeof err === 'object' && err != null && 'message' in err)
38
- console.log(err.message);
26
+ }
27
+ catch (err) {
28
+ if (err instanceof Error) {
29
+ console.log(err.message);
39
30
  }
40
31
  }
41
- };
42
- const faviconConfig = (name) => ({
43
- path: '/favicons', // Path for overriding default icons path. `string`
44
- appName: name, // Your application's name. `string`
45
- appShortName: name, // Your application's short_name. `string`. Optional. If not set, appName will be used
46
- appDescription: undefined, // Your application's description. `string`
47
- developerName: undefined, // Your (or your developer's) name. `string`
48
- developerURL: undefined, // Your (or your developer's) URL. `string`
49
- dir: 'auto', // Primary text direction for name, short_name, and description
50
- lang: 'en-US', // Primary language for name and short_name
51
- background: '#fff', // Background colour for flattened icons. `string`
52
- theme_color: '#fff', // Theme color user for example in Android's task switcher. `string`
53
- appleStatusBarStyle: 'black-translucent', // Style for Apple status bar: "black-translucent", "default", "black". `string`
54
- display: 'standalone', // Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser". `string`
55
- orientation: 'any', // Default orientation: "any", "natural", "portrait" or "landscape". `string`
56
- scope: '/', // set of URLs that the browser considers within your app
57
- start_url: '/?homescreen=1', // Start URL when launching the application from a device. `string`
58
- preferRelatedApplications: false, // Should the browser prompt the user to install the native companion app. `boolean`
59
- relatedApplications: undefined, // Information about the native companion apps. This will only be used if `preferRelatedApplications` is `true`. `Array<{ id: string, url: string, platform: string }>`
60
- version: '1.0', // Your application's version string. `string`
61
- logging: false, // Print logs to console? `boolean`
62
- pixel_art: false, // Keeps pixels "sharp" when scaling up, for pixel art. Only supported in offline mode.
63
- loadManifestWithCredentials: true, // Browsers don't send cookies when fetching a manifest, enable this to fix that. `boolean`
64
- manifestMaskable: false, // Maskable source image(s) for manifest.json. "true" to use default source. More information at https://web.dev/maskable-icon/. `boolean`, `string`, `buffer` or array of `string`
65
- icons: {
66
- android: ['android-chrome-192x192.png', 'android-chrome-256x256.png'],
67
- appleIcon: ['apple-touch-icon.png'],
68
- appleStartup: false,
69
- favicons: true,
70
- windows: ['mstile-150x150.png'],
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
+ }