Skip to content

Commit

Permalink
Add support for integration inject script for sites (#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorelli authored Apr 11, 2024
1 parent 76cbc3c commit bfb2342
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"dependencies": {
"@geist-ui/icons": "^1.0.2",
"@gitbook/api": "^0.41.0",
"@gitbook/api": "^0.43.0",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-popover": "^1.0.7",
"@sentry/nextjs": "^7.94.1",
Expand Down
19 changes: 18 additions & 1 deletion src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,23 @@ export const getSiteSpaces = cache(
},
);

/**
* List the scripts to load for the site.
*/
export const getSiteIntegrationScripts = cache(
'api.getSiteIntegrationScripts',
async (organizationId: string, siteId: string, options: CacheFunctionOptions) => {
const response = await api().orgs.listSiteIntegrationScripts(organizationId, siteId, {
...noCacheFetchOptions,
signal: options.signal,
});
return cacheResponse(response, {
revalidateBefore: 60 * 60,
tags: [getAPICacheTag({ tag: 'site', organization: organizationId, site: siteId })],
});
},
);

/**
* Fetch all the data to render a site-space at once.
*/
Expand Down Expand Up @@ -728,7 +745,7 @@ export async function getSiteSpaceLayoutData(args: {
siteId: args.siteId,
siteSpaceId: args.siteSpaceId,
}),
getSpaceIntegrationScripts(args.spaceId),
getSiteIntegrationScripts(args.organizationId, args.siteId),
]);

return {
Expand Down

0 comments on commit bfb2342

Please sign in to comment.