File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,37 @@ outputs:
108108< Head .Link rel= " icon" type= " image/svg+xml" href= " /favicon.svg" / >
109109```
110110
111+ ``` jsx mdx:preview
112+ import React , { useState } from " react" ;
113+ import Head from ' @uiw/react-head' ;
114+
115+ const favicon = ` data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🦖</text></svg>`
116+ const favicon2 = ` data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🤡</text></svg>`
117+
118+ export default function App () {
119+ const [show , setShow ] = useState (false );
120+ return (
121+ < div>
122+ < Head .Link rel= " icon" type= " image/svg+xml" href= {show ? favicon : favicon2} / >
123+ < button onClick= {() => setShow (! show)}>
124+ Change Favicon {show ? " 🦖" : " 🤡" } {String (show)}
125+ < / button>
126+ < / div>
127+ );
128+ }
129+ ```
130+
131+ outputs:
132+
133+ ``` html
134+ <head >
135+ <style >.box-test { color : red ; } </style >
136+ <style >.box-test { color : red ; } </style >
137+ </head >
138+ <!-- .... -->
139+ ```
140+
141+
111142## All Sub Components
112143
113144Elements that can be used inside the ` <head> ` :
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ export const HeadElement = <T extends ElementType<any> = 'link'>(props: { as?: T
1818 if ( props . as === 'meta' && props . charSet ) {
1919 selector = `meta[charset]:not([data-head])` ;
2020 }
21+ if ( props . as === 'link' && props . rel == 'icon' ) {
22+ selector = `link[rel="icon"]:not([data-head])` ;
23+ }
2124 if ( selector ) {
2225 const dom = document . querySelector ( selector ) ;
2326 dom ?. remove ( ) ;
You can’t perform that action at this time.
0 commit comments