1 | |
2 | |
3 | * Update a custom page |
4 | * Update an existing custom page in your ReadMe project. |
5 |
|
6 | >📘 |
7 | > This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored). |
8 | */ |
9 | export async function main(auth: RT.Readme, branch: string, slug: string, body: Body) { |
10 | const url = new URL(`https://api.readme.com/v2/branches/${branch}/custom_pages/${slug}`) |
11 |
|
12 | const response = await fetch(url, { |
13 | method: 'PATCH', |
14 | headers: { |
15 | 'Content-Type': 'application/json', |
16 | Authorization: 'Bearer ' + auth.apiKey |
17 | }, |
18 | body: JSON.stringify(body) |
19 | }) |
20 | if (!response.ok) { |
21 | const text = await response.text() |
22 | throw new Error(`${response.status} ${text}`) |
23 | } |
24 | return await response.json() |
25 | } |
26 |
|
27 | |
28 | |
29 | * This file was automatically generated by json-schema-to-typescript. |
30 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
31 | * and run json-schema-to-typescript to regenerate this file. |
32 | */ |
33 |
|
34 | export interface Body { |
35 | appearance?: { |
36 | |
37 | * Whether a html custom page is fullscreen or not. |
38 | */ |
39 | fullscreen?: boolean |
40 | } |
41 | content?: { |
42 | body?: string |
43 | |
44 | * The type of content contained in this custom page. |
45 | */ |
46 | type?: 'markdown' | 'html' |
47 | } |
48 | metadata?: { |
49 | description?: string |
50 | image?: { |
51 | uri?: string |
52 | url?: string |
53 | } |
54 | keywords?: string |
55 | title?: string |
56 | } |
57 | privacy?: { |
58 | |
59 | * The visibility of this custom page. |
60 | */ |
61 | view?: 'public' | 'anyone_with_link' |
62 | } |
63 | slug?: string |
64 | title?: string |
65 | } |
66 |
|