Skip to content

Commit 4acb5e2

Browse files
authored
Merging pull request #18209
1 parent 069b8f7 commit 4acb5e2

File tree

3 files changed

+186
-7
lines changed

3 files changed

+186
-7
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import app from "../../typeflo.app.mjs";
2+
3+
export default {
4+
key: "typeflo-create-post",
5+
name: "Create Post",
6+
description: "Creates and publish posts in yout blog. [See the documentation](https://typeflo.io/knowledge-base/headless-cms-admin-api-documentation#1-posts)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
title: {
12+
propDefinition: [
13+
app,
14+
"title",
15+
],
16+
},
17+
content: {
18+
propDefinition: [
19+
app,
20+
"content",
21+
],
22+
},
23+
slug: {
24+
propDefinition: [
25+
app,
26+
"slug",
27+
],
28+
},
29+
excerpt: {
30+
propDefinition: [
31+
app,
32+
"excerpt",
33+
],
34+
},
35+
metatitle: {
36+
propDefinition: [
37+
app,
38+
"metatitle",
39+
],
40+
},
41+
metadescription: {
42+
propDefinition: [
43+
app,
44+
"metadescription",
45+
],
46+
},
47+
tocStatus: {
48+
propDefinition: [
49+
app,
50+
"tocStatus",
51+
],
52+
},
53+
scheduled: {
54+
propDefinition: [
55+
app,
56+
"scheduled",
57+
],
58+
},
59+
publishDate: {
60+
propDefinition: [
61+
app,
62+
"publishDate",
63+
],
64+
},
65+
isDraft: {
66+
propDefinition: [
67+
app,
68+
"isDraft",
69+
],
70+
},
71+
},
72+
async run({ $ }) {
73+
const response = await this.app.createPost({
74+
$,
75+
data: {
76+
postData: {
77+
title: this.title,
78+
content: this.content,
79+
slug: this.slug,
80+
excerpt: this.excerpt,
81+
metatitle: this.metatitle,
82+
metadescription: this.metadescription,
83+
toc_status: this.tocStatus,
84+
scheduled: this.scheduled,
85+
publish_date: this.publishDate,
86+
is_draft: this.isDraft,
87+
},
88+
},
89+
});
90+
$.export("$summary", "Successfully sent the request to create a post");
91+
return response;
92+
},
93+
};

components/typeflo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/typeflo",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Typeflo Components",
55
"main": "typeflo.app.mjs",
66
"keywords": [
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

components/typeflo/typeflo.app.mjs

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,97 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "typeflo",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
title: {
8+
type: "string",
9+
label: "Title",
10+
description: "Post title",
11+
},
12+
content: {
13+
type: "string",
14+
label: "Content",
15+
description: "Main body content of the post",
16+
},
17+
slug: {
18+
type: "string",
19+
label: "Slug",
20+
description: "URL-friendly title for the post",
21+
optional: true,
22+
},
23+
excerpt: {
24+
type: "string",
25+
label: "Excerpt",
26+
description: "Short summary of the post",
27+
optional: true,
28+
},
29+
metatitle: {
30+
type: "string",
31+
label: "Meta Title",
32+
description: "SEO title of the post",
33+
optional: true,
34+
},
35+
metadescription: {
36+
type: "string",
37+
label: "Meta Description",
38+
description: "SEO description of the post",
39+
optional: true,
40+
},
41+
tocStatus: {
42+
type: "boolean",
43+
label: "TOC Status",
44+
description: "Enable or disable table of contents",
45+
optional: true,
46+
},
47+
scheduled: {
48+
type: "string",
49+
label: "Scheduled",
50+
description: "Scheduled publish date and time, i.e.: `28/08/2025 09:35 AM`",
51+
optional: true,
52+
},
53+
publishDate: {
54+
type: "string",
55+
label: "Publish Date",
56+
description: "Date when the post is published, i.e.: `01/01/2025`",
57+
optional: true,
58+
},
59+
isDraft: {
60+
type: "boolean",
61+
label: "Is Draft",
62+
description: "Whether the post is saved as draft",
63+
optional: true,
64+
},
65+
},
566
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
67+
_baseUrl() {
68+
return `${this.$auth.api_url}`;
69+
},
70+
async _makeRequest(opts = {}) {
71+
const {
72+
$ = this,
73+
path,
74+
headers,
75+
...otherOpts
76+
} = opts;
77+
return axios($, {
78+
...otherOpts,
79+
url: this._baseUrl() + path,
80+
headers: {
81+
...headers,
82+
},
83+
});
84+
},
85+
86+
async createPost(args = {}) {
87+
return this._makeRequest({
88+
path: "/api/headless/admin/posts",
89+
method: "POST",
90+
headers: {
91+
Authorization: `Bearer ${this.$auth.admin_api_key}`,
92+
},
93+
...args,
94+
});
995
},
1096
},
11-
};
97+
};

0 commit comments

Comments
 (0)