Coder Social home page Coder Social logo

logicspark / vitepress-theme-api Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 1.0 30.6 MB

Simple Vitepress Theme for API Documentation

License: MIT License

HTML 3.48% Vue 13.96% TypeScript 29.74% CSS 52.82%
vite vitepress vitepress-blog vitepress-doc vitepress-theme vuejs3 vuepress vuepress-theme

vitepress-theme-api's Introduction

Vitepress Theme API

Developed by Logic Spark team

npm VueJS MIT License



😎 Video Demo

DividePage Component Demo

Demo.mov

Here is the link to the live demo. Have fun exploring!

🏗️ Built With

  1. Typescript
  2. Vue
  3. HTML
  4. CSS
  5. Vite

🚀 Getting Started

Learn what is required before using Vitepress API Document theme and how to install it quickly. Let's get started!

Prerequisite

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

Installation

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

Other options

  • yarn
  yarn add vitepress-theme-api
  • pnpm
  pnpm add vitepress-theme-api

🔥 Usage

You will need to import component tags and CSS. Without the CSS import, the API Document theme will not display correctly.

Import Component from Theme

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>

Import CSS from Theme

Per Vitepress's Setup Wizard, there are three options

  1. Default Theme
  2. Default Theme + Customization
  3. Custom Theme

Option 1: Default 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.

Option2: Default Theme + Customization

You must import the style in the CSS file from the theme directory.

@import "../../node_modules/vitepress-theme-api/theme/style.css";

Option 3: Custom Theme

Please follow Option 2's instruction

Implementation of Tags

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.

Component Attribute

Prop Type Required Description
top number Optional Set vertical position of <template #right> Default is 0

Implementation of Styled Ordered Number List

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

Implementation of Styled Container of Markdown Extension

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.

📚 License

Distributed under the MIT License. See LICENSE for more information.

Vitepress is licensed under MIT License. Click here for more information.

🙏 Acknowledgement

vitepress-theme-api's People

Contributors

ansonchieng avatar f4ngwt avatar kittisakls avatar ravut8 avatar wasinho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lubosmertak

vitepress-theme-api's Issues

Add styling to the number order list to make them standout

Description

At the moment, the number order list is based on standard md support. There is no CSS class to prettify it.

Why is this feature needed? Is there a problem that you faced?

It’s not really a problem but to make the number order list different and make the document easier to read

What is the solution you have in mind?

Add a CSS class to add a circular shape around each number

Add styling to default custom containers of Markdown Extensions

Description

Currently, the custom container does not have icon representations or border color.

Why is this feature needed? Is there a problem that you faced?

It’s not really a problem but to make each custom container standout more so that users can review API documents quickly and easily.

What is the solution you have in mind?

  1. Provide a selection of unicode representations for you to choose ( i , ⓘ , ⚠ ,❕ and ▶ )
  2. Add a css property to customize the container’s color, icon and border

Node engines seems unnecessarily restricted

Currently the package.json specifies that only Node 18 can be used:

	"engines": {
		"node": ">=18 <19"
	},

This seems unnecessarily restricting and prevents me from installing this theme as a dependency.

Update dependencies to ensure the they are up to date

Description

Some of the dependencies are not up to date.

Why is this feature needed? Is there a problem that you faced?

Older versions of some dependencies may have security concerns.

What is the solution you have in mind?

  • 1. Update dependencies so they are up to date
  • 2. Recheck that the theme api docs works as intended

Add better markdown support for response data, including scrollable frame

Description

Currently, on Vitepress, the way to provide response data, it either shows all at once or collapse so users need to open the section.

Show All

::: details Collapsed Section
This is a details block.
:::

Why is this feature needed? Is there a problem that you faced?

  1. For collapse frame: It can be non user-friendly to click
  2. For expand frame: For long samples, this can make the documentation looks weird.

What is the solution you have in mind?

Add an extension to the md support to provide a scrollable frame for response data.

Aside bar not functioning with DividePage

Aside bar not scrolling along with headings as soon as I used DividePage in the .md file.

Demo site

.md example:

---
layout: pon
aside: left
---

<script setup>import {DividePage} from 'vitepress-theme-api';</script>
<style>@import './node_modules/vitepress-theme-api/dist/style.css';</style>

# GraphQL API Guide

[GraphQL](https://graphql.org/) is a query language for APIs that offers an efficient and versatile alternative to REST APIs.


## Benefits of Using GraphQL Over REST:

1. **Single Endpoint:** GraphQL employs a single endpoint for all queries and mutations, contrasting with REST which necessitates multiple endpoints.

2. **Streamlined Data Retrieval:** With GraphQL, there's no need for intermediary datastores or additional layers when collating related data.

3. **Precise Data Retrieval:** Clients dictate the exact data they need, ensuring swift and succinct responses.

4. **HTTP-Based:** GraphQL, despite its unique query language, operates via standard HTTP, meaning any client capable of HTTP requests can interface with a GraphQL server. No GraphQL specific libraries are needed.

<DividePage>
<template #left>

## Authentication

Use the `Authorization` HTTP header with your personal access token.

</template>
<template #right>

**Header:**

Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN

</template>
</DividePage>

<DividePage>
<template #left>

### Obtaining a Personal Access Token

[PLACEHOLDER: Instructions or link for token.]

</template>
<template #right>

</template>
</DividePage>

<DividePage>
<template #left>

## Filters

Filters empower you to fine-tune your GraphQL queries, allowing you to retrieve data based on specific conditions. This guide will showcase the usage of `DeviceFilter`, `TagFilter`, and `StringConditional` filters when querying devices in the provided schema.

### DeviceFilter

The `DeviceFilter` is specifically crafted for querying devices based on specific attributes such as type, label, status, and tags.

</template>
<template #right>

#### Filtering by Connection Status

To filter devices by their connection status, use the `status` attribute of `DeviceFilter` and choose a value from the `ConnectionStatus` enum.

graphql [GraphQL]
{
  myDevices(filter: { status: "GOOD" }) {
	content {
	  id
	  label
	  type
	}
  }
}

This query retrieves devices with a connection status of "GOOD".

#### Filtering by Label

To query devices based on their label, employ the `label` attribute in conjunction with `StringConditional`.

graphql [GraphQL]
{
  myDevices(filter: { label: { eq: "MyVehicle" } }) {
	content {
	  id
	  label
	  type
	}
  }
}

In this example, devices labeled "MyVehicle" are fetched.

</template>
</DividePage>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.