mattmilburn/strapi-plugin-preview-button

Documentation could be more accurate on some points

Closed this issue Β· 8 comments

Hi, great plugin πŸ‘, easygoing instructions, but maybe you should precise a couple of things, as some of us are just starting out with v4 (I struggled with these at first):

  • Precise the configuration snippet has to be place inside a plugin.js file under the config folder.
  • Precise we have to rebuild the admin first before seeing changes (you used the development mode from your screenshot, but it’s likely we’ll just use the normal dev mode).
  • Precise we need to toggle the publicationState API parameter to preview when querying the content, otherwise, the draft will never be part of the response.

Also, not related to the issue but, unless I am mistaken, I noticed it's not working for single types, only collection types, right?

Precise we need to toggle the publicationState API parameter to preview when querying the content, otherwise, the draft will never be part of the response.

What do you mean? How do I do this?
Thanks

The "publicationState" parameter is part of the Strapi API.

If we want to get the draft version from the api response, it's mandatory to set it to "preview".
As we don't want to get the enabled all the time, I guess we should use a conditional depending if we are on a preview state or not. Eg:

const postRes = await fetchAPI('/post', {
    publicationState: context.preview ? 'preview' : 'live',
    /// ...

The documentation needs a revision. Unfortunately, there are missing crucial information. E.g. where to place the config file?

Also, not related to the issue but, unless I am mistaken, I noticed it's not working for single types, only collection types, right?

Correct, but check again πŸ™‚. The plugin has very recently been updated to support single types πŸ‘πŸ»

When it comes to configuring a plugin in Strapi, I did not include those specific details in the plugin README because those guides can already be found in the Strapi docs - https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.html

This plugin does not have a public API so if you are querying the API for draft/live versions, that is not related to the functionality of this plugin. Details on querying draft/live states can be found in the Strapi docs - https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html

@mattmilburn I have tested the latest version and successfully used it for a single type, so thanks for this important support! πŸ‘

Regarding the install instructions, nothing mandatory of course but I think it's never too much to precise things, especially as v4 is still relatively new in the game.

Here are some examples found across other marketplace plugins:

Screenshot 2022-03-27 at 19 00 45

Screenshot 2022-03-27 at 19 01 12

Same for regarding draft/live, nothing mandatory but it helps and avoid potential struggles to have this check in mind before using the package.

I close the issue as it's not critical, all the best for this package!

jpcmf commented

The documentation is confused. Any other guide to follow? Thank you.