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

Make optional SVG favicon come after the fallback #27566

Closed
wants to merge 1 commit into from
Closed

Make optional SVG favicon come after the fallback #27566

wants to merge 1 commit into from

Conversation

ciromattia
Copy link
Contributor

@ciromattia ciromattia commented Oct 20, 2020

Description

Make SVG favicon come after PNG one, because Chrome chooses the favicon which comes last, thus preferring PNG over SVG.

Documentation

See Chrome bugreport: https://bugs.chromium.org/p/chromium/issues/detail?id=1104663

Related Issues

Fixes #26083

Fixes #26083 Chrome choosing the favicon which comes last.
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 20, 2020
@moonmeister
Copy link
Contributor

Thanks! You'll probably need to update test snapshots to get tests to pass

@pvdz pvdz added type: bug An issue or pull request relating to a bug in Gatsby and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 20, 2020
@ciromattia
Copy link
Contributor Author

Thanks! You'll probably need to update test snapshots to get tests to pass

uh, I edited directly from github, let me look at the whole contributing process :)

@moonmeister
Copy link
Contributor

no worries if not, I'll have time in a couple days to finish it.

Copy link
Contributor

@trevorblades trevorblades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moonmeister @ciromattia one possible reason for the tests not passing is mixed up brackets/parens in the code. I commented on the two lines in question, but here's a full example of what the implementation should be:

if (srcIconExists) {
  if (insertFaviconLinkTag) {
    favicons.forEach(favicon => {
      headComponents.push(
        <link
          key={`gatsby-plugin-manifest-icon-link-png`}
          rel="icon"
          href={withPrefix(
            addDigestToPath(favicon.src, cacheDigest, cacheBusting)
          )}
          type="image/png"
        />
      )
    })
    if (icon?.endsWith(`.svg`)) {
      headComponents.push(
        <link
          key={`gatsby-plugin-manifest-icon-link-svg`}
          rel="icon"
          href={withPrefix(
            addDigestToPath(`favicon.svg`, cacheDigest, cacheBusting)
          )}
          type="image/svg+xml"
        />
      )
    }
  }
}

)}
type="image/png"
type="image/svg+xml"
/>
)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be a } since it's the end of a conditional statement

)}
type="image/svg+xml"
type="image/png"
/>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be }) since it's the end of a forEach loop

@trevorblades
Copy link
Contributor

trevorblades commented Nov 5, 2020

I've made these changes and PR'd them to @ciromattia's branch. They should be able to be merged in and hopefully tests will pass then 😄

We may still need to update snapshots since the order of <link>s changed, but I'll look into that now.

@moonmeister
Copy link
Contributor

I've made these changes and PR'd them to @ciromattia's branch. They should be able to be merged in and hopefully tests will pass then 😄

We may still need to update snapshots since the order of <link>s changed, but I'll look into that now.

You're a gem. Thanks for doing this, I've been to busy for oss work.

@trevorblades
Copy link
Contributor

No problem! I just ran tests and tried to update snapshots, but I guess none of them needed to be updated after all. I just opened #27843 (the branch I was PR'ing into this branch) to see if I could get the tests to pass there. I suppose if they do, merging that PR would be the same thing as merging my PR into this branch, and then this branch into gatsby/master.

@moonmeister
Copy link
Contributor

Yeah, no need to make more work, if that passes I'll close this in favor of the other.

@moonmeister
Copy link
Contributor

closing in favor of #27843

@moonmeister moonmeister closed this Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gatsby-plugin-manifest icon producing pngs and svg - but svg is not preferred icon of choice
4 participants