diff --git a/bun.lock b/bun.lock index 64d632d61..3c27da78d 100644 --- a/bun.lock +++ b/bun.lock @@ -246,7 +246,7 @@ "react-dom": "^19.0.0", }, "catalog": { - "@gitbook/api": "^0.131.0", + "@gitbook/api": "^0.132.0", }, "packages": { "@ai-sdk/provider": ["@ai-sdk/provider@1.1.0", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-0M+qjp+clUD0R1E5eWQFhxEvWLNaOtGQRUaBn8CUABnSKredagq92hUS9VjOzGsTm37xLfpaxl97AVtbeOsHew=="], @@ -611,7 +611,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="], - "@gitbook/api": ["@gitbook/api@0.131.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-xFxdeZTEO0rXRbsnleH3RRvJROuqKArLMz3WtmBurzOGOWsutfOye2aW+6q5UNzJDf4iKiXAylvmyOYrMypYBg=="], + "@gitbook/api": ["@gitbook/api@0.132.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-1kuYIHiQIFzcSbKZ0JkzfSKujWFHyM4OAT3P0JENekBffwEinUMqblkJZNQmWA4QhBYi0QT8bJA6OCda4Xx0oA=="], "@gitbook/cache-tags": ["@gitbook/cache-tags@workspace:packages/cache-tags"], diff --git a/package.json b/package.json index 72158c1af..df2e60ef0 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "workspaces": { "packages": ["packages/*"], "catalog": { - "@gitbook/api": "^0.131.0" + "@gitbook/api": "^0.132.0" } }, "patchedDependencies": { diff --git a/packages/gitbook/src/components/DocumentView/ReusableContent.tsx b/packages/gitbook/src/components/DocumentView/ReusableContent.tsx index 05b42936c..5ef0b1000 100644 --- a/packages/gitbook/src/components/DocumentView/ReusableContent.tsx +++ b/packages/gitbook/src/components/DocumentView/ReusableContent.tsx @@ -26,18 +26,15 @@ export async function ReusableContent(props: BlockProps { + 'use cache'; + return wrapCacheDataFetcherError(async () => { + return trace( + `getRevisionReusableContentDocument(${params.spaceId}, ${params.revisionId}, ${params.reusableContentId})`, + async () => { + const api = apiClient(input); + const res = await api.spaces.getReusableContentDocumentInRevisionById( + params.spaceId, + params.revisionId, + params.reusableContentId, + { + evaluated: true, + }, + { + ...noCacheFetchOptions, + } + ); + + cacheTag(...getCacheTagsFromResponse(res)); + cacheLifeFromResponse(res, 'max'); + + return res.data; + } + ); + }); + } +); + const getRevisionPageByPath = cache( async ( input: DataFetcherInput, diff --git a/packages/gitbook/src/lib/data/types.ts b/packages/gitbook/src/lib/data/types.ts index 7cfa616f1..a80759e6a 100644 --- a/packages/gitbook/src/lib/data/types.ts +++ b/packages/gitbook/src/lib/data/types.ts @@ -100,6 +100,15 @@ export interface GitBookDataFetcher { pageId: string; }): Promise>; + /** + * Get the document of a reusable content by its space ID and reusable content ID. + */ + getRevisionReusableContentDocument(params: { + spaceId: string; + revisionId: string; + reusableContentId: string; + }): Promise>; + /** * Get a document by its space ID and document ID. */