-
Notifications
You must be signed in to change notification settings - Fork 7
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
Not working with FontAwesome 6 #22
Comments
+1 |
1 similar comment
+1 |
Updating the dependencies for this should fix it, doesn't look like much has changed with FontAwesome that would invalidate this workaround. For the interim, if you need to use this, it should be easy enough to maintain your own updated copy in your local @jzabala Are you still maintaining this package? |
@tnsicdr @vladzagorski @atrudeau-vitall @abhnvkmr I have had a PR open for a long time now attempting to fix this. I have now published a fork of this repo on NPM https://github.com/ed-wright/gatsby-plugin-fontawesome-css |
I think the easiest way should like this: Edit import { config } from '@fortawesome/fontawesome-svg-core'
import '@fortawesome/fontawesome-svg-core/styles.css'
config.autoAddCss = false Now all things should work well. I've found the problem last month. After a bit research, I decide remove the plugin with FontAwesome6, let me tell the reason. The plugin has no tree shaking and add all css to head when compiling project. It add to much useless styles. In fact, author or us just want no flashing icon, no page jumping. So the easest way solve the problem only need the style below with page: .svg-inline--fa {
display: inline-block;
font-size: inherit;
height: 1em;
overflow: visible;
vertical-align: -0.125em;
} I put it with my global css file. The main problem solved, even though it will produce dulicated styles overwrite, I think that is acceptable and ok. BTW, I just use the font svg mostly. As usally I will wrap icon with component import React from 'react'
import { config } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
config.autoAddCss = false
const FAIcon = props => {
return <FontAwesomeIcon {...props} />
}
export default FAIcon page to use, my import { Link } from 'gatsby'
import React from 'react'
import FAIcon from './fontAwesome'
import { faKissWinkHeart } from '@fortawesome/free-solid-svg-icons'
const Footer = ({ siteMetadata }) => (
<footer className="my-8 text-center text-gray-400">
<p className="mb-2">
<Link to="/" className="bg-clip-text text-transparent bg-gradient-to-r from-teal-400 to-blue-500">
{siteMetadata.title} © {new Date().getFullYear()}
</Link>
</p>
<ul className="flex justify-center items-center mt-4">
<li>
<Link to="/about-me" className="mx-2 text-xl text-teal-400 hover:text-rose-200" target="_blank">
<FAIcon icon={faKissWinkHeart} />
</Link>
</li>
</ul>
</footer>
)
export default Footer and last css .svg-inline--fa {
display: var(--fa-display, inline-block);
height: 1em;
overflow: visible;
vertical-align: -0.125em;
} In fact, code above is not my full code, of couse this will lose a part of styles if you code like:
It won't work with size properties, for a perfect solution, you can read all props, you can read offical doc, and extend your component yourself. |
There is a dependency issue with FontAwesome 6. I am using the latest release of
gatsby-plugin-fontawesome-css
.The text was updated successfully, but these errors were encountered: