styxlab / gatsby-theme-try-ghost

A Gatsby theme to build flaring fast blogs from headless Ghost CMS
MIT License
136 stars 56 forks source link

use shadowing add gatsby plugin in post.js ,error #185

Closed ghost closed 3 years ago

ghost commented 3 years ago

now ,useing gatsby-starter-try-ghost , i want to add gatsby-plugin-valine as comment system. the setup is

  1. install the npm package yarn add gatsby-plugin-valine
  2. Add the plugin into the gatsby-config.js script

{ resolve:gatsby-plugin-valine, options: { appId:axxxxxxxI, appKey:SxxxxxxxxxYp6hJ, avatar:robohash, }, },

  1. create path <my-project>\src\gatsby-theme-try-ghost\templates
  2. copy post.js from gatsby-theme-try-ghost/packages/gatsby-theme-try-ghost/src/templates/ to <my-project>\src\gatsby-theme-try-ghost\templates
  3. import and add the component to post.js

    ` ... import { Comments, TableOfContents, Subscribe } from '../components/common' import Valine from 'gatsby-plugin-valine'

... const Post = ({ data, location, pageContext }) => { const { basePath } = useOptions() ...

return (
   ...
                            <Comments id={post.id}/>

                        </article>
                    </div>
        <Valine />
                </Layout>
         ....

`

  1. run gatsby develop error info is ` ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/effects' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/effects' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/helpers' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/helpers' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/meta' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/meta' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/routing' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/routing' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/use-lang' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/use-lang' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

ERROR #98124 WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/use-options' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/use-options' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

failed Building development bundle - 18.386s `

styxlab commented 3 years ago

You need to adapt your import paths in src\gatsby-theme-try-ghost\templates\post.js. Have a look at gatsby-theme-ghost-commento to see how this is done. For future communications, please always send me a link to a working test example, so I can better analyze what's going on.

ghost commented 3 years ago

the repo is iNote-xyz, my site is https://inote.xyz, it's still not work

ghost commented 3 years ago

hi, even i shadowing post.js in src\gatsby-theme-try-ghost\templates\post.js, not change anything in post.js , the starter is not work also . what should i do?

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/effects' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/effects' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/helpers' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/helpers' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../components/common/meta' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../components/common/meta' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/routing' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/routing' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/use-lang' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/use-lang' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '../utils/use-options' in 'C:\inote-xyz\src\gatsby-theme-try-ghost\templates'

If you're trying to use a package make sure that '../utils/use-options' is installed. If you're trying to use a local file make sure that the path is correct.

File: src\gatsby-theme-try-ghost\templates\post.js

failed Building development bundle - 8.757s
styxlab commented 3 years ago

Hey @xiyizhou: I was going to have a look at iNote-xyz but your Ghost CMS cannot be reached on https://cms.inote.xyz.

ghost commented 3 years ago

thanks for your reply @styxlab , now you can check the repo , the cms , and the gatsby site. i had add the valine , but it still not work . because I am not familiar with English and codes.

styxlab commented 3 years ago

I sent you a pull request that should fix the issue. As I initially suspected, you have to adjust the import paths of the shadowing file. The shadowing file must get a proper reference to the original, have a look at the diff. Result looks good on first sight:

image

ghost commented 3 years ago

now it is work , i learned a lot again at least, very grateful!

styxlab commented 3 years ago

You are welcome, cool that it's working now.