Skip to content

Commit

Permalink
update(ref): improving docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rooyca committed May 20, 2024
1 parent 133e6e4 commit 5a3f3bd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
24 changes: 14 additions & 10 deletions docs/docs/codeblock/flags.md → docs/docs/codeblocks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Code-block flags
# 👨🏻‍💻 Codeblocks

The `codeblock` is a versatile block that can be used to write code in different languages. In this case, we will use it to make requests.

## 🏳️ Flags

Flags are the way to specify the parameters of our request and also the format in which we want our response.

Expand All @@ -14,7 +18,7 @@ Flags are the way to specify the parameters of our request and also the format i
| req-id | req-general |
| disabled | |

## url
### url

Is the only **required** flag. It specifies the endpoint of the request. Variables defined in the `frontmatter` can be used.

Expand All @@ -27,7 +31,7 @@ url: https://jsonplaceholder.typicode.com/users/{{this.id}}
!!! info "Where `{{this.id}}` is a variable (`id`) defined in the frontmatter."


## method
### method

Specifies the request method. The default value is `GET` and the available values are:

Expand All @@ -43,7 +47,7 @@ method: post
```
~~~

## body
### body

Specifies the body of the request. The default value is an empty object. The data should be in JSON format with double quotes separating the keys and values with a colon and space. Variables defined in the `frontmatter` can be used.

Expand All @@ -57,7 +61,7 @@ body: {"title": {{this.title}}, "body": "bar", "userId": 1}

!!! info "Where `{{this.title}}` is a variable (`title`) defined in the frontmatter."

## headers
### headers

Specifies the headers of the request. The default value is an empty object. The data should be in JSON format with double quotes separating the keys and values with a colon and space. Variables defined in the `frontmatter` can be used.

Expand All @@ -69,7 +73,7 @@ headers: {"Content-type": "application/json; charset=UTF-8"}
```
~~~

## show
### show

Specifies the response data to display. Accessing nested objects is done using a right arrow `->`. The default value is `ALL`.

Expand Down Expand Up @@ -117,7 +121,7 @@ show: {0-2-1} -> address -> city
```
~~~

## format
### format

Specifies the format in which the response should be displayed. The default value is `{}`. It can be any string (including `markdown` and `html`). If more than one output is specified, more then one format should be specified, otherwise, the same format will be applied to all outputs.

Expand All @@ -132,7 +136,7 @@ format: <h1>{}</h1> <p>{}</p>
!!! info "In this example, first `{}` will be replaced by the title, and second `{}` will be replaced by the body."


## res-type
### res-type

Specifies the type of response we are getting. The default value is `json`. The available values are:

Expand All @@ -149,7 +153,7 @@ res-type: md
```
~~~

## req-id
### req-id

Specifies the id of the request. The default value is `req-general`. This is useful when we want to store the response in `localStorage` and use it in other blocks or notes.

Expand Down Expand Up @@ -192,7 +196,7 @@ localStorage.removeItem("req-name")

To remove all responses, go to settings and click on the `Clear ID's` button.

## disabled
### disabled

Disables the request. If a `req-id` is specified, APIR will check for the response in `localStorage`. If it's not found, it will make a new request and store it. After that, APIR will use the stored response.

Expand Down
13 changes: 8 additions & 5 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Overview
# 🔎 Overview

APIR (shorthand for api-request) is an [Obsidian](https://obsidian.md/) plugin that allows you to make requests and show the responses in your notes. This aims to be an easy way to integrate APIs into your notes.

## How to use
## How to use

### Code-block
### 👨🏻‍💻 Code-block

To use it, create a code-block with the language set to `req`. Inside the code-block, you can specify `url`, `method`, `body`, `headers`, `format`, etc. See the [available flags](codeblock/flags.md) for more information.
To use it, create a code-block with the language set to `req`. Inside the code-block, you can specify `url`, `method`, `body`, `headers`, `format`, etc. See the [available flags](codeblocks.md#flags) for more information.

~~~markdown
```req
Expand All @@ -21,11 +21,14 @@ disabled
```
~~~

### Configuration (don't have all functionalities yet)
### 🛠️ Settings (don't have all functionalities yet)

!!! info "All parameters can be defined in settings."

Press `Ctrl+P` and search for `APIR`. There are two options:

1. Show response in modal
2. Paste response in current document (at current line)

[More information](settings.md)

26 changes: 17 additions & 9 deletions docs/docs/settings.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
# Settings
# 🛠️ Settings

Using the plugin with this method is not recommended. It is better to use code blocks. This method is very limited and does not support all the features of the code block method.

## name
## ❓ Why use this method

This method is useful when you want to make a quick request or you need to reuse the same request multiple times. You just need to fill the fields, press `Ctrl+P`, search for `APIR` and select the way you want to display the response (Show a modal or paste it into the document).

Another advantage is that you can save the request and assign a `shortcut` to it. This way you can make the request just by pressing the keys you assigned.

## 🏳️ Flags

### name

Specifies the name of the request.

## url (required)
### url (required)

Specifies the URL of the request.

## method
### method

- GET
- POST
- PUT
- DELETE

## body
### body

Specifies the body of the request.

## headers
### headers

Specifies the headers of the request.

## what to display
### what to display

Specifies the output you want.

## Add this APIR
### Add this APIR

Save the above fields into a new APIR (you can access all APIRs by pressing `Ctrl+P` and searching for `APIR`).

## Clear ID's
### Clear ID's

Remove all IDs stored in `localStorage`.
3 changes: 1 addition & 2 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ theme:

nav:
- Getting started: 'index.md'
- codeblock:
- flags: 'codeblock/flags.md'
- codeblocks: 'codeblocks.md'
- settings: 'settings.md'

0 comments on commit 5a3f3bd

Please sign in to comment.