Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Better setup options for custom scripts (and actions) #517

Closed
davidsneighbour opened this issue Feb 27, 2023 · 6 comments
Closed

Comments

@davidsneighbour
Copy link
Contributor

Currently (it seems) all custom scripts are added to the Actions box and available in all content types. Shutting it off is only possible by removing that meta box from the view (with a custom view mode for instance).

The following is a current sample in my system:

20230227-18:15:41-Selection-001

  • I would love to remove the "Optimize slug" button. It is an internal action, so I can't just delete the config option
  • Starting and stopping the server might be done outside of the CMS. Even if not, it would use up less space by being a "switch" button. "Start server" if it's off, "Stop server" if it's on.
  • "Open Preview" should be only available when the server is running
  • Custom action youtube - I would love to show these buttons only where they are needed, based on content type. The youtube preview button for instance would show up only in type: video posts.
  • Or: based on frontmatter. The unsplash button only if a field/group unsplash is defined in the frontmatter of the current post.

In general the sidebar tends to be very long and cluttered on post pages. Showing things conditionally or collapse all boxes might help.

In short:

  • custom actions based on content type
  • disable/enable internal actions (like server start/stop) and optimize how they show up
  • conditional rules where to show custom actions based on frontmatter variables
  • a config option to collapse all boxes by default (or all boxes after a selected one) would be nice.
@davidsneighbour davidsneighbour added the enhancement New feature or request label Feb 27, 2023
@estruyf
Copy link
Owner

estruyf commented Mar 7, 2023

Thanks, @davidsneighbour; some enhancements can be made to the custom actions.

  • Custom actions based on the content-type is a good idea!
  • Disable/enable internal actions is a good idea, I will check what I can do for this
  • Wouldn't you already have the field defined in the content-type? It might be easier to specify multiple content types for a script.
  • Not sure if I understand this, can you clarify this a bit?

Something else: knowing when the server is running is a bit trickier (for the stop and preview actions), as some only sometimes use the start action. You could run it separately.

@estruyf estruyf added help wanted Extra attention is needed good first issue Good for newcomers labels Oct 3, 2023
@estruyf
Copy link
Owner

estruyf commented Oct 3, 2023

Something else: knowing when the server is running is a bit trickier (for the stop and preview actions), as some only sometimes use the start action. You could run it separately.

This has been implemented #652

@estruyf
Copy link
Owner

estruyf commented Oct 4, 2023

The ability to hide custom actions per content type has been added:

{
  "frontMatter.custom.scripts": [{
      "title": "Generate social image",
      "script": "./scripts/social-img.js",
      "command": "~/.nvm/versions/node/v16.19.0/bin/node",
      "contentTypes": ["post"]
    }]
}

All you need to do is add the contentTypes property to the custom script and specify the content type names for which you want to enable the custom script. Once you do this, the custom action will only appear for the list of specified content types in the panel.

estruyf added a commit that referenced this issue Oct 4, 2023
@estruyf
Copy link
Owner

estruyf commented Oct 4, 2023

A new setting frontMatter.panel.actions.disabled is available for defining which actions you want to hide:

{
  "frontMatter.panel.actions.disabled": [
    "openDashboard",
    "createContent",
    "optimizeSlug",
    "preview",
    "openOnWebsite",
    "startStopServer",
    "customActions"
  ]
}

@estruyf estruyf removed help wanted Extra attention is needed good first issue Good for newcomers Status: To do labels Oct 4, 2023
@estruyf
Copy link
Owner

estruyf commented Oct 4, 2023

To collapse all zones, you can use the following action:

image

@davidsneighbour
Copy link
Contributor Author

I am sorry, I never saw your answers to my report. Those all are good options, thanks for the hard work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants