pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

More flexible favicons

Open MEO265 opened this issue 1 year ago • 5 comments

I have two points that could work together. I'm willing to create a PR, but I would like to know in advance what you think is the best option or whether the feature is not wanted at all.

First of all, I would really like to see support for svg favicons. All you would have to do is insert a line in the header above the other icons if the logo is an svg.

<link rel="icon" type="image/svg+xml" href="favicon.svg">

This would allow (monochrome) logos to also have a variant for dark mode users.

Additionally or alternatively, you could use the yamel to allow the code embedded in the header for the favicon to be overwritten.

MEO265 avatar May 28 '24 06:05 MEO265

Looks like only supported by ~77% of browsers (https://caniuse.com/link-icon-svg), so wouldn't want to make this the default, but maybe if you have an svg logo we could add it as an extra link?

https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 suggests that dark mode support for svg requires custom css in the svg, which I suspect few folks will know how to do.

hadley avatar May 28 '24 13:05 hadley

So I don't think it makes sense to do this by default, but it would certainly be nice to give folks the ability to opt-in to an svg favicon. I think the main question on my mind is whether this needs to be an option, or if we could just have a convention for where such a file would be located. For example, maybe if pkgdown/favicon.svg existed, we could just add it to the <head> automatically? What do you think?

hadley avatar May 28 '24 17:05 hadley

For example, maybe if pkgdown/favicon.svg existed, we could just add it to the <head> automatically? What do you think?

I think it's a good idea to conditionally include the line depending on whether an SVG favicon (pkgdown/favicon.svg) exists. I will take care of the implementation and submit a PR.

MEO265 avatar May 30 '24 06:05 MEO265

https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 suggests that dark mode support for svg requires custom css in the svg, which I suspect few folks will know how to do.

Yes, that's true. However, https://realfavicongenerator.net/ offers not only its API but also a simple tool to create SVG favicons optimized for both dark and light mode.

Looks like only supported by ~77% of browsers (https://caniuse.com/link-icon-svg), so wouldn't want to make this the default, but maybe if you have an svg logo we could add it as an extra link?

When Apple (Safari) supports it, I will get back to you regarding the default behavior. Being able to work independently of the resolution is definitely an advantage, even without special features (e.g. dark mode support).

MEO265 avatar May 30 '24 07:05 MEO265

@MEO265 thanks for working on this!

hadley avatar May 30 '24 13:05 hadley

I think this was addressed in #2804 but please reopen if you still have an issue.

jayhesselberth avatar Nov 29 '24 14:11 jayhesselberth