#gatsby #ui
Read: https://www.gatsbyjs.org/docs/themes/shadowing/
This is a very interesting technique in [Gatsby] that helps you ~not so~ easily modify a source from theme or a plugin.
For example, if we have a theme named gatsby-theme-foo
, and a project named user-blog
. We want to modify the source file gatsby-theme-foo/src/components/Foo.js
.
What we need to do is create a file user-blog/src/gatsby-theme-foo/components/Foo.js
. And rewrite whatever in the original Foo.js
here, plus some modification as we wanted.
Noted that the shadowing path won't have the src
as it is in the original theme.
If in the source file, we have an import statement like:
import { Bar } from './Bar';
You will need to change it in show shadowing file, like this:
import { Bar } from 'gatsby-theme-foo/src/components/Bar';
Although it's helpful, it's violated the most important maintenable rule:
Never monkey patching files that not owned by your project
If the amount of shadowing works is reasonable, it's ok, but if there's a lot of stuff to be shadowing, you better fork the theme you're using and modify it instead.
Gatsby
#ui #gatsby Gatsby is a React-based site generator. Read the docs . The usage is as simple as: Init the project with npm init Install…
Home Page
Welcome! Look like you've found my personal notebook. This is the place where you can take a peek into my mind to see what I've been…
If you think this note resonated, be it positive or negative, please feel free to send me an email and we can talk.