1 | |
2 | type Gitbook = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update a site section |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Gitbook, |
11 | organizationId: string, |
12 | siteId: string, |
13 | siteSectionId: string, |
14 | body: { |
15 | title?: string; |
16 | path?: string; |
17 | defaultSiteSpace?: string; |
18 | condition?: string; |
19 | icon?: string; |
20 | description?: string; |
21 | }, |
22 | ) { |
23 | const url = new URL( |
24 | `https://api.gitbook.com/v1/orgs/${organizationId}/sites/${siteId}/sections/${siteSectionId}`, |
25 | ); |
26 |
|
27 | const response = await fetch(url, { |
28 | method: "PATCH", |
29 | headers: { |
30 | "Content-Type": "application/json", |
31 | Authorization: "Bearer " + auth.token, |
32 | }, |
33 | body: JSON.stringify(body), |
34 | }); |
35 | if (!response.ok) { |
36 | const text = await response.text(); |
37 | throw new Error(`${response.status} ${text}`); |
38 | } |
39 | return await response.json(); |
40 | } |
41 |
|