Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions components/notion/actions/retrieve-block/retrieve-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import notion from "../../notion.app.mjs";

export default {
key: "notion-retrieve-block",
name: "Retrieve Block",
description: "Get details of a block, which can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)",
version: "0.0.6",
name: "Retrieve Page Content",
description: "Get page content as block objects or markdown. Blocks can be text, lists, media, a page, among others. [See the documentation](https://developers.notion.com/reference/retrieve-a-block)",
version: "0.1.0",
type: "action",
props: {
notion,
Expand All @@ -13,18 +13,28 @@ export default {
notion,
"pageId",
],
label: "Block ID",
description: "Select a block or provide a block ID",
},
retrieveChildren: {
type: "boolean",
label: "Retrieve Children",
description: "Retrieve all the children (recursively) for the specified block. [See the documentation](https://developers.notion.com/reference/get-block-children) for more information",
label: "Retrieve Content (Child Blocks)",
description: "Retrieve all the children (recursively) for the specified page. [See the documentation](https://developers.notion.com/reference/get-block-children) for more information",
optional: true,
default: false,
},
retrieveMarkdown: {
type: "boolean",
label: "Retrieve as Markdown",
description: "Return the page content as markdown instead of block objects.",
optional: true,
},
},
async run({ $ }) {
if (this.retrieveMarkdown) {
const response = await this.notion.getPageAsMarkdown(this.blockId);
$.export("$summary", "Successfully retrieved page as markdown");
return response;
}

const block = await this.notion.retrieveBlock(this.blockId);
if (this.retrieveChildren) {
block.children = await this.notion.retrieveBlockChildren(block);
Expand Down
9 changes: 7 additions & 2 deletions components/notion/actions/retrieve-page/retrieve-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

export default {
key: "notion-retrieve-page",
name: "Retrieve Page",
name: "Retrieve Page Metadata",
description: "Get details of a page. [See the documentation](https://developers.notion.com/reference/retrieve-a-page)",
version: "0.0.6",
version: "0.0.7",
type: "action",
props: {
notion,
infoLabel: {

Check warning on line 11 in components/notion/actions/retrieve-page/retrieve-page.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoLabel must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 11 in components/notion/actions/retrieve-page/retrieve-page.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoLabel must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "If you need to retrieve page content or block objects, use the **Retrieve Page Content** action instead.",
},
pageId: {
propDefinition: [
notion,
Expand Down
16 changes: 16 additions & 0 deletions components/notion/notion.app.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import notion from "@notionhq/client";
import NOTION_META from "./common/notion-meta-selection.mjs";
import { ConfigurationError } from "@pipedream/platform";
import { NotionConverter } from "notion-to-md";
import { DefaultExporter } from "notion-to-md/plugins/exporter";

export default {
type: "app",
Expand Down Expand Up @@ -355,5 +357,19 @@ export default {

return response.results;
},
async getPageAsMarkdown(pageId) {
const client = this._getNotionClient();

const buffer = {};
const exporter = new DefaultExporter({
outputType: "buffer",
buffer,
});

const n2m = new NotionConverter(client).withExporter(exporter);
await n2m.convert(pageId);

return Object.values(buffer)[0];
},
},
};
5 changes: 3 additions & 2 deletions components/notion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/notion",
"version": "0.4.1",
"version": "0.5.0",
"description": "Pipedream Notion Components",
"main": "notion.app.mjs",
"keywords": [
Expand All @@ -13,7 +13,8 @@
"@notionhq/client": "^2.2.3",
"@pipedream/platform": "^3.0.3",
"@tryfabric/martian": "^1.2.4",
"lodash-es": "^4.17.21"
"lodash-es": "^4.17.21",
"notion-to-md": "^4.0.0-alpha.4"
},
"publishConfig": {
"access": "public"
Expand Down
Loading
Loading