DividePage Component Demo
Demo.mov
Here is the link to the live demo. Have fun exploring!
Learn what is required before using Vitepress API Document theme and how to install it quickly. Let's get started!
This library is created with Vite + Vue3 + TypeScript. To start using this library, please make sure to install the following external libraries first:
Support Node.js 18.12.0 (LTS) and above
There are a few ways you can install Vitepress API Document theme, namely npm, yarn and pnpm. If you install via npm, here is a single cmd to install this library
npm install vitepress-theme-api
- yarn
yarn add vitepress-theme-api
- pnpm
pnpm add vitepress-theme-api
You will need to import component tags and CSS. Without the CSS import, the API Document theme will not display correctly.
You will need to import DividePage
component to divide the main content into left and right so that the API document theme can be rendered.
<script setup>import {DividePage} from 'vitepress-theme-api';</script>
Per Vitepress's Setup Wizard, there are three options
- Default Theme
- Default Theme + Customization
- Custom Theme
You can import the file within <style>
of each .md file that you plan to use the imported component.
<style>@import './node_modules/vitepress-theme-api/dist/style.css';</style>
Note: Do not add scoped
in <style>
because the css will not work.
You must import the style in the CSS file from the theme directory.
@import "../../node_modules/vitepress-theme-api/theme/style.css";
Please follow Option 2's instruction
There are two tags, namely:
<template #left>
- For the left side of the main content, you can write API descriptions like query parameters or return properties.<template #right>
- For the right side of the main content, you can add sample codes like API request and response.
<DividePage>
<template #left>
// Add content here. Both html and markdown are supported.
</template>
<template #right>
// Add content here. Both html and markdown are supported.
</template>
</DividePage>
Note: When writing markdown, please leave a line so that it displays a markdown instead of text like the example above.
Prop | Type | Required | Description |
---|---|---|---|
top |
number |
Optional | Set vertical position of <template #right> Default is 0 |
If you would like to style ordered number list to make your document easier to read, here is a code example:
Class name is order-list-I.
1. First Item
1. First Item
1. First Item
{.order-list-I} // if you omit this, it will display default md style
If you would like to style custom containers so that users can review your document quickly and easily, here is the selection of unicode representations
i , ⓘ , ⚠ ,❕ and ▶
Add an attribute to customize the container’s color, icon and border
::: warning {icon-type=warning} //add an icon
test
:::
::: warning {icon-type=warning-bordered} //add an icon, color and border
test
:::
Note: If you want to adjust these class, you can can change it in Import css from theme.
For the full sample .md file in accordance with the live demo, please see our example directory.
Distributed under the MIT License. See LICENSE
for more information.
Vitepress is licensed under MIT License. Click here for more information.