theowenyoung / gatsby-theme-primer-wiki

A Gatsby Theme for Wiki/Docs/Knowledge Base, which using Primer style as the UI theme, can work well with Foam or Obsibian or just markdown files.
https://demo-wiki.owenyoung.com/
MIT License
117 stars 18 forks source link

Sourcing from Strapi #60

Closed grgvn closed 2 years ago

grgvn commented 2 years ago

Hi,

Once again, many thanks from my team for your great job and theme.

I'm facing an issue I can't resolve by myself, any help or hint would be greatly appreciated.

Problem

When sourcing from Strapi, the Gatsby Theme Primer Wiki can't generate the pages anymore, landing on 404.

Expected

Being able to source from Strapi, and being able to run Gatsby.

Steps to reproduce

  1. Start a new project : gatsby new wiki https://github.com/theowenyoung/gatsby-starter-primer-wiki

  2. In project root : npx create-strapi-app@latest backend --quickstart // this will create the Strapi backend in /backend

Now in Strapi (http://localhost:1337/admin):

  1. Create a Single Type ('Homepage' in my case), put some dummy content in, save, publish

  2. Settings / Users & Permissions Plugin -> give 'find' Permission to 'Public' and to 'Authentificated' on the previously selected Single Type

  3. create an API Token with FULL ACCESS and copy it for later use

  4. Restart strapi (in /backend) : yarn start develop

And now in Gatsby :

  1. npm install --save gatsby-source-strapi gatsby-plugin-image gatsby-plugin-sharp gatsby-source-filesystem gatsby-transformer-remark gatsby-transformer-sharp // https://www.gatsbyjs.com/plugins/gatsby-source-strapi/

  2. gatsby-config.js, add :

const strapiConfig = {
  apiURL: 'http://localhost:1337',
  accessToken: 'your-token',
  collectionTypes: [],
  singleTypes: ['homepage'],
};

and

{
      resolve: `gatsby-source-strapi`,
      options: strapiConfig,
},
  1. gatsby-clean
  2. gatsby-develop

You should see many issues in the Terminal. Looks like the Theme is not able to generate pages anymore and it lands to 404. See complete log

Some observations

Even if Gatsby crashes, I can see my strapiHomepage nodes in http://localhost:8000/__graphql ; sourcing seems to work.

In gatsby-config.js, changing the singleTypes['homepage'] by any dummy singleType, let's say singleTypes['dummyType'] doesn't generate the error.

My config

Gatsby CLI version: 4.16.0 Gatsby version: 4.6.0 Node v16.15.1 Strapi 3.1.0-alpha.5

Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 Codename: jammy

Did I miss something huge or is it something with the theme ? Any hint of help to fix this would be greatly appreciated.

Have a great day, Grégoire