Replies: 1 comment
-
@ClxUne09 if we change this to an svg, we can use a built-in feature. And truth be told, this is a docusaurus feature more than an oh-my-posh one. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, I was trying to add theme-based favicon switching for site, and I almost got it to work. However, I think Docusaurus doesn't have a built-in feature to change the favicon based on the theme. So, I made some changes to
docusaurus.config.js
to switch the favicon dynamically. This adds a script tag to the head of the site, which switches the favicon depending on the theme:<link rel="icon" href="/img/favicon-dark.ico">
when the theme is light, and<link rel="icon" href="/img/favicon-light.ico">
when it's dark. It updates the favicon without requiring a page reload, and it mostly works correctly.However, the problem is that you can't remove the
favicon
field fromdocusaurus.config.js
. This means that Docusaurus will still include something like<link data-rh="true" rel="icon" href="/img/favicon.ico">
, which interferes with the theme-based switching. The dynamic favicon change still happens every time the theme switches, but because of the default favicon, the switch might not always work correctly—especially if you reload the page while the dark theme is active.I think making some changes related to existed link tag and deleting the
favicon
field could fix this, but it seems like Docusaurus requires it to function properly. It would be great if someone could help add this feature correctly.Changes made:
Created new file for light theme named favicon-dark.ico that placed it static/img
Created new file for dark theme named favicon-light.ico that placed it static/img
Changed docusaurus.config.js:
Beta Was this translation helpful? Give feedback.
All reactions