Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hadimostafapour
Copy link

  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
Copy link
Collaborator

andy128k commented Jun 2, 2023

@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.

None yet

2 participants