WordPress comments package

Those are all really good points, Luis, thank you! :slight_smile:

I’m happy to undo that change now or we could wait for the next opportunity when we are doing further work on wp-comments.

@SantosGuillamot what do you think?

If it’s a small change I would do it now. I haven’t released this version yet, so if you think it’s something we have to do, I’d include it before announcing it. I was planning to release and announce it once the new Yoast package is merged, but it can wait until tomorrow if this change doesn’t take long.

1 Like

I ll PR to undo this so that you can merge it before announcing the new release.

1 Like

Thanks for the PR Michal.

It’s not that this is that important, because the @comments/:post-id pattern introduced doesn’t use pagination or queries, but I think it’ll be important for future non-URL patterns made by us or the community :slightly_smiling_face:

This feature, the beta version, has been released :tada: : Read the full Release Announcement.

Following @mmczaplinski 's code, I created a CodeSandbox to show an example implementing it. I recommend you to point it to your own WordPress site, so you can test the different settings and submit new comments (it isn’t currently allowed in test.frontity.org).

We also created a demo explaining a bit this example and how the package works:

1 Like

I love the video @santosguillamot! It’s really well explained :clap:

The only suggestion I have is to add a check before adding the comments to your theme so it works without a comments package.

Maybe check state.comments before adding the main component:

state.comments && <Comments postId={post.id} />;

And maybe check actions.comments?.submit before adding the form:

actions.comments?.submit && <CommentsForm postId={postId} />;

Two other things:

  • Should we open a FD for the comments namespace to start discussing it?
  • Should we open FDs for other wp-comments features, like the Comments component, a setting to fetch comments in SSR and so on?

Hello Frontity team,

Thank you so much for releasing this package which supports WordPress comments. :clap:t2:
I’ve implemented it and all worked fine. Please check it out here:

However, one thing i’ve noticed is that, when i navigate through the other posts, the comments section is not rendered.

Scenario:

  1. Go to the Link i provided above
  2. Scroll down to “READ NEXT” section which is right after the comments section
  3. Click on some of the posts e.g.“How To Make Easy Homemade Pizza Dough”

You’ll find out that the comments section is not appearing, but after reloading the page.

Any advices on this?

Thanks so much.
Best,
Dejan

@dejangeorgiev is the repo available to check if this is a bug in the comments package or the error is somewhere else?

By the way, they look awesome :slightly_smiling_face:

Hi @luisherranz :wave:t3:

Thank you very much! :nerd_face:
Yes, here is the repo :point_right:t2: https://github.com/dejangeorgiev/ruthgeorgiev-frontity

Thanks @dejangeorgiev.

@mmczaplinski could you please check it out?

Hi @dejangeorgiev

It’s a bit hard to debug this as I’m looking at a few issues that are obscuring what is going on for me :sweat_smile:

  1. The comments form shows up correctly for me e.g. when I go to localhost:3000/how-to-make-perfect-carrot-cupcakes/ directly.

  2. However, the “Recommendations” section does not actually show up at all!

  3. When I open up the console, I get the following error:

ServerError: post type from endpoints "posts,pages,media" with slug "388" not found
    at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:37:21)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:4:1069)
    at _next (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:4:1383)
    at eval (webpack-internal:///./node_modules/@frontity/connect/src/scheduler.js:7:128)
    at batchedUpdates$1 (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:3683:146)
    at batch (webpack-internal:///./node_modules/@frontity/connect/src/scheduler.js:7:113)
    at batched (webpack-internal:///./node_modules/@frontity/connect/src/scheduler.js:10:261)

I think that you want to load the data from the recipes endpoint and not the posts, pages or media. Looks like you might have a misconfigured handler here, I’m not quite sure :slight_smile:

  1. I’ve noticed that when I browse with adblock on (uBlock origin), the page loads and then goes blank because the adsbygoogle object is not present in the window. This might actually be an error on our side, but we’ll have to investigate!

Are you able to reproduce the issues that I mention ?

1 Like

Hello,
I have implemented the new comments package, but it doesn’t display the comments (I have done it exactly like on the codesandbox https://javierlorrente.vercel.app/trenhotel-de-renfe
If I try to post a new comment, it appears, but disappears if I reload the page

I have logged the data and it shows error


this is the repo : https://github.com/alexadark/javierlorrente

1 Like

I think it’s related to the type param you’re adding in the frontity.setting.js file. This is being added trying to fetch the comments as well and it’s returning an error. Could you check if that’s the problem? Is there any special reason why you’re adding that params?

1 Like

Hi @mmczaplinski :wave:t3:

Thanks so much for investigating these issues. Yes, this is very helpful and i will try to fix it.
Could you please let me know if you are able to reproduce the issues regarding tot the adblock / adsbygoogle.

Many thanks.
Best,
Dejan

1 Like

Thanks, yes that fixes the problem!
I don’t remember why I had this type param!
Pfff I wrote this the other day, 5mn after your answer, and didn’t hit send :flushed:

2 Likes

Hi! I was working with this package in a typescript theme and I noticed that the interface for a comment entity is called WpComment and I was wondering if in order to match better what already exists in @frontity/source this interface should be called WpCommentEntity or CommentEntity.

Also, in addition to this, I want to ask something else, would it be better if these types started with the type of data they are? Like DataComment, EntityComment, so when trying to import them, if you are looking for an entity the first results in the autosuggest would be those starting for entity. I don’t know if it is worth the change, just thinking out loud.

1 Like

One more idea that could be added in a future version could be a Derived state to get the total comments of a post, as they might be nested inside each other and it is just not trivial as to use data.items.length, but we need to sum them up somehow.

1 Like

Definitely.

Great idea.

Feel free to open a PR for those two :slightly_smiling_face:

This is also a good idea, but I am afraid it’s a bit late for the v1 now.