feat(wordpress): add find post action
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Find post',
|
||||
key: 'findPost',
|
||||
description: 'Finds a post.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Post ID',
|
||||
key: 'postId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Choose a post to update.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listPosts',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { postId } = $.step.parameters;
|
||||
|
||||
const response = await $.http.get(`?rest_route=/wp/v2/posts/${postId}`);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,4 +1,5 @@
|
||||
import createPost from './create-post/index.js';
|
||||
import findPost from './find-post/index.js';
|
||||
import updatePost from './update-post/index.js';
|
||||
|
||||
export default [createPost, updatePost];
|
||||
export default [createPost, findPost, updatePost];
|
||||
|
@@ -3,6 +3,8 @@ favicon: /favicons/wordpress.svg
|
||||
items:
|
||||
- name: Create post
|
||||
desc: Creates a new post.
|
||||
- name: Find post
|
||||
desc: Finds a post.
|
||||
- name: Update post
|
||||
desc: Updates a post.
|
||||
---
|
||||
|
Reference in New Issue
Block a user