Gridsome: TypeError: gridsome.server.js: Cannot destructure property `collection` of 'undefined' or 'null'.

Created on 31 Oct 2019  Â·  3Comments  Â·  Source: gridsome/gridsome

Description

Trying to build static files. The Plugin source-ghost is included.
store.getContentType('Post') returns undefined.

Steps to reproduce

Dunno…

Expected result

Build without errors.

Actual result

`gridsome build
Gridsome v0.7.9

Initializing plugins...
Loading data from undefined
Load sources - 1.16s
Create GraphQL schema - 0.06s
Create pages and templates - 0.05s
Generate temporary code - 0.02s
Bootstrap finish - 2.4s
TypeError: gridsome.server.js: Cannot destructure property collection of 'undefined' or 'null'. (50:34)

48 |
49 | // Generate an index file for Fuse to search Posts

50 | const { collection } = store.getContentType('Post');
| ^
51 |
52 | const posts = collection.data.map(post => {
53 | return pick(post, ['title', 'path', 'summary']);
`

Package.json
"dependencies": { "@fullhuman/postcss-purgecss": "^1.2.0", "@gridsome/plugin-sitemap": "^0.2.1", "@gridsome/source-filesystem": "^0.5.0", "@gridsome/source-ghost": "^0.2.0", "@gridsome/transformer-remark": "^0.4.0", "axios": "^0.19.0", "gridsome": "^0.7.9", "gridsome-plugin-remark-shiki": "^0.3.0", "gridsome-plugin-rss": "^1.2.0", "lodash.pick": "^4.4.0", "vue-fuse": "^2.1.2", "vue-scrollto": "^2.17.1" }, "devDependencies": { "cypress": "^3.4.1", "netlify-cli": "^2.15.0", "tailwindcss": "^1.1.2" }

Environment

prod

Most helpful comment

@MarcoFaul Yep. Vue will initialize on built out static pages and rehydrate your content so you can use standard Vue conventions for fetching data from the ghost API

All 3 comments

The collection name might be GhostPost if you haven't set a custom typeName option for the Ghost source plugin.

Ohhh, ofc… 🙈 Thanks a lot.
One more silly concern. Is it possible to use gridsome and build static files and those will dynamically fetch the ghost 3.0 api?

@MarcoFaul Yep. Vue will initialize on built out static pages and rehydrate your content so you can use standard Vue conventions for fetching data from the ghost API

Was this page helpful?
0 / 5 - 0 ratings

Related issues

upandfine picture upandfine  Â·  3Comments

ghost picture ghost  Â·  3Comments

renestalder picture renestalder  Â·  3Comments

ameistad picture ameistad  Â·  3Comments

tyrion picture tyrion  Â·  3Comments