mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Fetch customization settings
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getSpace, getCurrentRevision } from '@/lib/api';
|
||||
import { getSpace, getCurrentRevision, getSpaceCustomization } from '@/lib/api';
|
||||
|
||||
import { resolvePagePath, resolvePageId } from '@/lib/pages';
|
||||
|
||||
@@ -20,7 +20,13 @@ export interface PageIdParams extends SpaceParams {
|
||||
export async function fetchPageData(params: PagePathParams | PageIdParams) {
|
||||
const { spaceId } = params;
|
||||
|
||||
const [space, revision] = await Promise.all([getSpace(spaceId), getCurrentRevision(spaceId)]);
|
||||
const [space, revision, customization] = await Promise.all([
|
||||
getSpace(spaceId),
|
||||
getCurrentRevision(spaceId),
|
||||
getSpaceCustomization(spaceId),
|
||||
]);
|
||||
|
||||
console.log(customization);
|
||||
|
||||
const page =
|
||||
'pageId' in params && params.pageId
|
||||
@@ -30,6 +36,7 @@ export async function fetchPageData(params: PagePathParams | PageIdParams) {
|
||||
return {
|
||||
space,
|
||||
revision,
|
||||
customization,
|
||||
ancestors: [],
|
||||
...page,
|
||||
};
|
||||
|
||||
@@ -61,3 +61,23 @@ export const getPageDocument = unstable_cache(
|
||||
tags: ['api', 'documents'],
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the customization settings for a space.
|
||||
*/
|
||||
export const getSpaceCustomization = unstable_cache(
|
||||
async (spaceId: string) => {
|
||||
// TODO: use function from API client once updated
|
||||
const { data } = await api().request({
|
||||
method: 'GET',
|
||||
path: `/spaces/${spaceId}/publishing/customization`,
|
||||
secure: true,
|
||||
format: 'json',
|
||||
});
|
||||
return data;
|
||||
},
|
||||
['api', 'customization'],
|
||||
{
|
||||
tags: ['api', 'customization'],
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user