@mintlify/prebuild 1.0.342 → 1.0.344

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.
@@ -1,4 +1,3 @@
1
- export declare const generateFavicons: (mintConfig: {
2
- favicon: string | null;
3
- name: string;
4
- }, contentDirectoryPath: string) => Promise<import("favicons").FaviconResponse | undefined>;
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,17 +2,41 @@ import favicons from 'favicons';
2
2
  import { promises as _promises } from 'fs';
3
3
  import { join } from 'path';
4
4
  const { readFile } = _promises;
5
- export const generateFavicons = async (mintConfig, contentDirectoryPath) => {
6
- if (mintConfig.favicon == null)
5
+ export const generateFavicons = async (config, contentDirectoryPath) => {
6
+ if (config.favicon == null)
7
7
  return;
8
- const desiredPath = join(contentDirectoryPath, mintConfig.favicon);
9
- const favicon = await readFile(desiredPath);
10
- try {
11
- return favicons(favicon, faviconConfig(mintConfig.name));
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));
13
+ return [icons];
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
+ }
12
19
  }
13
- catch (err) {
14
- if (typeof err === 'object' && err != null && 'message' in err)
15
- console.log(err.message); // Error description e.g. "An unknown error has occurred"
20
+ else {
21
+ // Light and dark favicons case
22
+ try {
23
+ const lightPath = join(contentDirectoryPath, config.favicon.light);
24
+ const darkPath = join(contentDirectoryPath, config.favicon.dark);
25
+ const lightFavicon = await readFile(lightPath);
26
+ const darkFavicon = await readFile(darkPath);
27
+ const [lightIcons, darkIcons] = await Promise.all([
28
+ favicons(lightFavicon, faviconConfig(config.name)),
29
+ favicons(darkFavicon, {
30
+ ...faviconConfig(config.name),
31
+ path: '/favicons-dark',
32
+ }),
33
+ ]);
34
+ return [lightIcons, darkIcons];
35
+ }
36
+ catch (err) {
37
+ if (typeof err === 'object' && err != null && 'message' in err)
38
+ console.log(err.message);
39
+ }
16
40
  }
17
41
  };
18
42
  const faviconConfig = (name) => ({