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: Post processing script on content type #376

Closed
estruyf opened this issue Jul 27, 2022 · 3 comments
Closed

Enhancement: Post processing script on content type #376

estruyf opened this issue Jul 27, 2022 · 3 comments
Labels
enhancement New feature or request Project: v8.1.0

Comments

@estruyf
Copy link
Owner

estruyf commented Jul 27, 2022

Add the ability to reference a script that will be executed after content creation happened.

@estruyf estruyf added the enhancement New feature or request label Jul 27, 2022
@davidsneighbour
Copy link
Contributor

I would add a complete "hook system" where we can reference scripts on several activities/events, but post-creation comes to mind first.

@davidsneighbour
Copy link
Contributor

I have a specific use case in mind: I have a content type that is basically a youtube video. When creating that post I would want to retrieve that videos thumbnail as a preview image to be saved next to the markdown file of the content. Currently I am doing that via creating the content > manual action with frontmatter button.

I would think that is what this feature might be about?

estruyf added a commit that referenced this issue Aug 4, 2022
@estruyf
Copy link
Owner Author

estruyf commented Aug 4, 2022

@davidsneighbour correct, that is my use case as well.

The postscript functionality is now available in the latest beta.

Here is what you need to do:

Create a script

The postscript functionality uses the content scripts from the frontMatter.custom.scripts settings. All you have to do is add a new id property to the script.

{
  "frontMatter.custom.scripts": [
    {
      "id": "generate-social-image",
      "title": "Generate social image",
      "script": "./scripts/social-img.js",
    }
}

Info: If you want to hide the script/action from the UI, you can add a property hidden and set it to true.

Define the postscript in the content type

The content type has a new property called: postScript, which requires the id of the script to execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Project: v8.1.0
Projects
None yet
Development

No branches or pull requests

2 participants