Skip to content

Add feature to set different source image(s) for each platform. - #431

Open
hadimostafapour wants to merge 2 commits into
itgalaxy:masterfrom
hadimostafapour:master
Open

Add feature to set different source image(s) for each platform.#431
hadimostafapour wants to merge 2 commits into
itgalaxy:masterfrom
hadimostafapour:master

Conversation

@hadimostafapour

Copy link
Copy Markdown
  const options = {
    icons: {
      favicons: false,
      android: {
          source: ({width, height}) => {
                     return width < 800 ? "/path/to/foo" : "/path/to/bar";
           }
      },
      appleStartup: {
          offset: 2,
          source: "/path/to/asset"
      },
      windows: false,
      yandex: false,
      appleIcon: true,
    },
  };

@andy128k

andy128k commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator

@hadimostafapour I like the direction where it goes, but I am not sure that such extension of config type is a right thing to do. Let's say, someone wants to specify a source for each platform individually, then they need to pass some dummy source to favicons() function to bypass a validator.

There are other ways to achieve similar result. E.g. extend

type Source = string | Buffer | (string | Buffer)[];
type PerPlatform<T> = Record<PlatformName | '*', T>;

export async function favicons(
  source: Source | PerPlatform<Source>,
  options: FaviconOptions = {}
): Promise<FaviconResponse> {
  // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants