|
| 1 | +--- |
| 2 | +title: Built-in Components |
| 3 | +--- |
| 4 | + |
| 5 | +<Block> |
| 6 | + |
| 7 | +# Built-in Components |
| 8 | + |
| 9 | +Thanks to [Using Vue in Markdown](https://vuepress.vuejs.org/guide/using-vue.html) feature of `VuePress`, we can directly use Vue components in Markdown files. |
| 10 | + |
| 11 | +In order to better display the content of the document, the theme has built-in several useful components, which you can use directly in any Markdown file. |
| 12 | + |
| 13 | +Built-in components are available out of the box, and you can still write Markdown syntax content in the components. |
| 14 | + |
| 15 | +Currently, the following components are mainly built-in: |
| 16 | + |
| 17 | +[[toc]] |
| 18 | + |
| 19 | +</Block> |
| 20 | + |
| 21 | +<Block> |
| 22 | + |
| 23 | +## Block Component |
| 24 | + |
| 25 | + |
| 26 | +The `Block` component is mainly used to divide the page structure. Each `Block` component is a content group. It is convenient for you to control the page structure freely and flexibly. |
| 27 | + |
| 28 | +<Example> |
| 29 | + |
| 30 | +Usage: |
| 31 | + |
| 32 | +```vue |
| 33 | +<Block> |
| 34 | +
|
| 35 | +Contents... |
| 36 | +
|
| 37 | +</Block> |
| 38 | +``` |
| 39 | + |
| 40 | +</Example> |
| 41 | + |
| 42 | +</Block> |
| 43 | + |
| 44 | +<Block> |
| 45 | + |
| 46 | +## Example Component |
| 47 | + |
| 48 | +The `Example` component is used to specify the content of the dark area on the right in the `<Block>` component. It can clearly identify the current part of the content as a use case. |
| 49 | + |
| 50 | +<Example> |
| 51 | + |
| 52 | +Usage: |
| 53 | + |
| 54 | +```vue |
| 55 | +<Block> |
| 56 | +
|
| 57 | +Contents... |
| 58 | +
|
| 59 | +<Example> |
| 60 | +
|
| 61 | +Some examples... |
| 62 | +
|
| 63 | +</Example> |
| 64 | +
|
| 65 | +</Block> |
| 66 | +``` |
| 67 | + |
| 68 | +</Example> |
| 69 | + |
| 70 | +</Block> |
| 71 | + |
| 72 | +<Block> |
| 73 | + |
| 74 | +## CURL Component |
| 75 | + |
| 76 | +The `CURL` component is a very useful component for better displaying `curl` commands when writing APIs. |
| 77 | + |
| 78 | +For example, the following content will be rendered into the form on the right: |
| 79 | + |
| 80 | +````vue |
| 81 | +<CURL> |
| 82 | +```bash |
| 83 | +curl -X POST https://api.example.com/v1/auth/login \ |
| 84 | + -H 'Content-Type: application/json' \ |
| 85 | + -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \ |
| 86 | + --data '{ |
| 87 | + "username": "my-username", |
| 88 | + "password": "my-password" |
| 89 | + }' |
| 90 | +``` |
| 91 | +</CURL> |
| 92 | +```` |
| 93 | + |
| 94 | +The `CURL` component will automatically generate a button below the component. When the button is clicked, it will analyze the parameters in the `curl` command and send a request via `Ajax` to the corresponding url. And output its request information to the `console` panel. Convenient for quick test and preview. |
| 95 | + |
| 96 | +<Example> |
| 97 | + |
| 98 | +<CURL> |
| 99 | + |
| 100 | +```bash |
| 101 | +curl -X POST http://api.example.com/api/auth/login \ |
| 102 | + -H 'Content-Type: application/json' \ |
| 103 | + -H 'Authorization: Bearer <const name="MOCK_TOKEN" />' \ |
| 104 | + --data '{ |
| 105 | + "username": "my-username", |
| 106 | + "password": "my-password" |
| 107 | + }' |
| 108 | +``` |
| 109 | +</CURL> |
| 110 | + |
| 111 | +</Example> |
| 112 | + |
| 113 | +e.g.: |
| 114 | + |
| 115 | +````vue |
| 116 | +<CURL> |
| 117 | +```bash |
| 118 | +curl -X GET https://api.github.com/users/sqrthree |
| 119 | +``` |
| 120 | +</CURL> |
| 121 | +```` |
| 122 | + |
| 123 | +<Example> |
| 124 | + |
| 125 | +<Blank height="148px" /> |
| 126 | + |
| 127 | +<CURL> |
| 128 | +```bash |
| 129 | +curl -X GET https://api.github.com/users/sqrthree |
| 130 | +``` |
| 131 | +</CURL> |
| 132 | + |
| 133 | +</Example> |
| 134 | + |
| 135 | +In addition, the content of `curl` on the right can be directly edited and then sent the request with changes. The modification will take effect immediately. This is very useful when you want to modify some parameters temporarily. |
| 136 | + |
| 137 | +</Block> |
| 138 | + |
| 139 | +<Block> |
| 140 | + |
| 141 | +## Button Component |
| 142 | + |
| 143 | +The `Button` component can be used anywhere on any page. You can use it to point to a link or some special content. |
| 144 | + |
| 145 | +The supported parameters are as follows: |
| 146 | + |
| 147 | +| Name | Type | Description | Default | |
| 148 | +| :---: | :-----: | :------------------------------------: | :-----: | :--: | |
| 149 | +| to | String | page link | `""` | |
| 150 | +| size | String | Set the size of button, values: `small | large` | `""` | |
| 151 | +| light | Boolean | Whether to use light theme | `false` | |
| 152 | + |
| 153 | +Use the following code to render a button: |
| 154 | + |
| 155 | +```vue |
| 156 | +<Button>Default state</Button> |
| 157 | +``` |
| 158 | + |
| 159 | +Rendered: |
| 160 | + |
| 161 | +<Button>Default state</Button> |
| 162 | + |
| 163 | +<br> |
| 164 | +<br> |
| 165 | + |
| 166 | +Page link: |
| 167 | + |
| 168 | +```vue |
| 169 | +<Button to="/">Homepage</Button> |
| 170 | +``` |
| 171 | + |
| 172 | +Rendered: |
| 173 | + |
| 174 | +<Button to="/">Homepage</Button> |
| 175 | + |
| 176 | +<Example> |
| 177 | + |
| 178 | +More use cases: |
| 179 | + |
| 180 | +```vue |
| 181 | +<Button light>Light theme</Button> |
| 182 | +``` |
| 183 | + |
| 184 | +<Button light>Light theme</Button> |
| 185 | + |
| 186 | +```vue |
| 187 | +<Button to="https://github.com/sqrthree/vuepress-theme-api" light>Page link</Button> |
| 188 | +``` |
| 189 | + |
| 190 | +<Button to="https://github.com/sqrthree/vuepress-theme-api" light>Page Link</Button> |
| 191 | + |
| 192 | +```vue |
| 193 | +<Button size="small" light>Other size</Button> |
| 194 | +``` |
| 195 | + |
| 196 | +<Button size="small" light>Other size</Button> |
| 197 | + |
| 198 | +</Example> |
| 199 | + |
| 200 | +</Block> |
| 201 | + |
| 202 | +<Block> |
| 203 | + |
| 204 | +## Section Component |
| 205 | + |
| 206 | +The `Section` component is a special layout form, mainly used in [Homepage Layout](/#build-for-restful-api). Refer to [Homepage | Build for RESTful API](/#build-for-restful-api) to preview. |
| 207 | + |
| 208 | +| Name | Type | Description | Default | |
| 209 | +| :---------: | :-----: | :------------------------------------------: | :------: | |
| 210 | +| theme | String | Set the theme `dark \| light` | `"dark"` | |
| 211 | +| center | Boolean | The specify which way that content is aligned | `true` | |
| 212 | +| enhanceMode | Boolean | Whether to enable enhanced mode | `true` | |
| 213 | + |
| 214 | +::: tip Enhanced mode |
| 215 | +Enhanced mode means that the `Section` component breaks through the limit of the parent element width and achieves the same effect as the width of the browser window. |
| 216 | +::: |
| 217 | + |
| 218 | +<Example> |
| 219 | + |
| 220 | +The configuration used in the homepage: |
| 221 | + |
| 222 | +```vue |
| 223 | +<Section> |
| 224 | +
|
| 225 | +## Build for RESTful API |
| 226 | +
|
| 227 | +A easy-to-use, minimalist theme for VuePress. |
| 228 | +
|
| 229 | +With out-of-the-box feature, all you need to do is install it and write something. |
| 230 | +
|
| 231 | +<br> |
| 232 | +
|
| 233 | +<Button type="light" to="/getting-started/">Getting Started</Button> |
| 234 | +
|
| 235 | +</Section> |
| 236 | +``` |
| 237 | + |
| 238 | +</Example> |
| 239 | + |
| 240 | +</Block> |
0 commit comments