Repository navigation
Rating system + how to pass rating callback from nodejs/config to browser #6527
Replies: 3 comments 6 replies
|
The theme config must be entirely serializable, because If you want to pass callbacks on the client side, you have to inject it through as a client-side file (e.g. in |
|
Oh, I see... It's generally a feature to give feedback about the usefulness of the docs, that's what I mean by a rating of doc pages. Would be a pity if I coded all of that in vain. My motivation was the fact that many developer documentation sited implement this feature. In that sense, You can of course configure it to show this UI component or not. Having such a component in a theme out of the box seems pretty useful and you're right that you can swizzle it easily for further customization to provide that API callback. I'm happy to document it. Here's what it looks like at the moment in my dev env: Bottom of the page I made it configurable through the |
|
@Josh-Cena, I haven't found plenty of services that would provide smth useful. The sites I've checked mostly had their own implementation like even react docs. The issues with 3rd party services are:
This page rating pattern with +1/-1 or true/false logic is very widespread. React, Google Support, and many others use it. That's why I think having a native Docusaurus component for it makes sense at least with What belongs to the user land is implementation of that callback and here I agree it's a userland part. I think it can be solved with the swizzling pattern if no other way exists. At the end of the day even if the internals of the UI component change but API stays the same - the upgrade path should be rather easy. @slorber, before I commit to the tests and docs, do you think this can make it in? We've prototyped it in our docs and use Docusaurus from its early alfa. Now, I had trouble upgrading the theme and core because of some swizzled components and decided to contribute this for good. If that's not worth it, we'll probably just kill that rating snippet as the maintenance effort would not justify having it. That's actually why I think many docs' owners won't implement it. With styling, stateful logic, context wrapping, and all - it's time-consuming. Whereas if you need only a function that triggers your GA tags or Plausible endpoint - that's a no-brainer. Looking forward to hearing what you think. p.s.: examples from Google Cloud and React, or check our docs |





Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi there, I'm developing a voting component and need to pass a callback to my component which will serve as an adapter for different backends which users can be leveraging for recording votes (Google Tags, API Hook, etc).
I tried passing it via a

themeConfiglikemyCollabc: value => { makeCallToMyAPI(value)}but that doesn't work. I can see properties that I pass but the callback is not there:I assume some sanitizing is going on? What would be the best practice to allow the user to develop their own adapter for recording the votes and then pass it to be invoked via the component?
Or am I doing something wrong and that's why I don't see the callback on the component side? I checked and destructuring and all the types are correct.
All reactions