Skip to content

Commit a0d2b7f

Browse files
committed
Pull in connection docs if they exist
1 parent b0e4a35 commit a0d2b7f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/plugins/connectors/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ handlebars.registerPartial(
2424
}),
2525
);
2626

27+
// We skip importing certain connectors' connection docs because they are too Prismatic-specific
28+
const IGNORED_CONNECTOR_CONNECTION_DOCS = ["pipedrive"];
29+
2730
const writeConnectorDocsFile = (
2831
connector: Component,
2932
connectorTemplate: HandlebarsTemplateDelegate<unknown>,
@@ -58,6 +61,33 @@ async function generateConnectorDocs({
5861
JSON.stringify(connectors, null, 2),
5962
);
6063
for (const connector of connectors) {
64+
for (const connection of connector.connections.nodes) {
65+
const docsPath = path.join(
66+
__dirname,
67+
"..",
68+
"..",
69+
"..",
70+
"..",
71+
"components",
72+
"components",
73+
connector.key,
74+
"documentation",
75+
"connections",
76+
`${connection.key}.mdx`,
77+
);
78+
if (
79+
fs.existsSync(docsPath) &&
80+
!IGNORED_CONNECTOR_CONNECTION_DOCS.includes(connector.key)
81+
) {
82+
connection.connectionDocs = fs
83+
.readFileSync(docsPath, { encoding: "utf-8" })
84+
.replaceAll(
85+
/<OauthCallbackUrl \/>/g,
86+
"`https://oauth2.%WHITE_LABEL_BASE_URL%/callback`",
87+
);
88+
}
89+
}
90+
6191
fetchConnectorIcon(connector);
6292
writeConnectorDocsFile(connector, connectorTemplate);
6393
}

src/plugins/connectors/queries.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface Component {
44
description: string;
55
category: string;
66
iconUrl: string;
7-
connections: { nodes: Connection };
7+
connections: { nodes: Connection[] };
88
triggers: { nodes: Trigger[] };
99
dataSources: { nodes: DataSource[] };
1010
actions: { nodes: Action[] };
@@ -16,6 +16,7 @@ interface Connection {
1616
type: string;
1717
default: string;
1818
comments: string;
19+
connectionDocs?: string;
1920
}
2021

2122
interface Trigger {

src/plugins/connectors/templates/connector.md.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ description: {{{description}}}
1717

1818
{{{comments}}}
1919

20+
{{#if connectionDocs}}
21+
22+
{{{connectionDocs}}}
23+
24+
{{/if}}
25+
2026
{{#if oauth2Type}}
2127

2228
This connection uses OAuth 2.0, a common authentication mechanism for integrations.

0 commit comments

Comments
 (0)