chakra-ui / frontity-chakra-ui-theme

A Frontity theme built with Chakra UI
https://githubbox.com/chakra-ui/frontity-chakra-ui-theme
104 stars 20 forks source link

Theme breaks when posts list has just one item #7

Open SantosGuillamot opened 4 years ago

SantosGuillamot commented 4 years ago

If you install the frontity-chakra-ui-theme in a Frontity project, and point it to a WordPress where you just have one post, it stops working and it returns this error:

TypeError: Cannot destructure property `title` of 'undefined' or 'null'.
      at SecondaryPostPreview (webpack-internal:///./packages/frontity-chakra-theme/src/components/featured-post/featured-post.js:13:2258)
      at processChild (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:480:2385)
      at resolve (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:479:122)
      at ReactDOMServerRenderer.render (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:516:1153)
      at ReactDOMServerRenderer.read (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:516:55)
      at renderToString (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:555:116)
      at eval (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:45:243)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at eval (webpack-internal:///./node_modules/koa-mount/index.js:16:290)

It seems that the theme is expecting to find a second post (I guess for the homepage, for the first three posts), and as it doesn't exists it returns that error.

Afiliazon commented 4 years ago

@SantosGuillamot i think the problem is my wordpress site, but testing with frontity's demo blog causes the same error. Please search multiple times fastest.

SantosGuillamot commented 4 years ago

I am not able to reproduce the problem. With frontity's demo blog you refer to this one? https://frontity-chakra.now.sh/. I've done multiple searches there and it's working for me.

Koli14 commented 4 years ago

I had the same issue. If the source point to a WP where there is only 1 or 2 posts, you get the above error message. If you create at least 3 posts, it works.