feat: add pages resource (#14)

This commit is contained in:
paranarimasu authored and GitHub committed 2022-02-18 14:08:08 -06:00
1 parent 174b67df60
commit 2215e0f76a
6 files changed
+3004 -1546

No files matched your search

+14
View File
@@ -160,6 +160,20 @@ module.exports = {
}
]
},
'page': {
title: 'Resource',
to: '/page',
children: [
{
title: 'Show',
to: '/page/show/',
},
{
title: 'Index',
to: '/page/index/'
}
]
},
'resource': {
title: 'Resource',
to: '/resource',
+38
View File
@@ -0,0 +1,38 @@
---
title: Page
---
# Page
---
A page API resource represents a static markdown page used for guides and other documentation.
For example, the 'encoding/audio_normalization' page represents the documentation for audio normalization.
### Fields
| Name | Type | Nullable | Description |
| :--------: | :-----: | :------: | :--------------------------------------------|
| id | Integer | No | The primary key of the resource |
| name | String | No | The primary title of the page |
| slug | String | No | The URL slug & route key of the resource |
| created_at | Date | No | The date that the resource was created |
| updated_at | Date | No | The date that the resource was last modified |
| deleted_at | Date | Yes | The date that the resource was deleted |
**Note:** At the time of writing, the `body` field of the underlying page model is purposely excluded from the page API resource due to size constraints.
### Allowed Include Paths
None
### Endpoints
**[Page Show](/page/show/)**
The page show endpoint returns a page resource.
**[Page Index](/page/index/)**
The page index endpoint displays a listing of page resources.
+92
View File
@@ -0,0 +1,92 @@
---
title: Page Index
---
<Block>
# Page Index Endpoint
The page index endpoint returns a listing of page resources.
## URL
```sh
GET /api/page/
```
## Parameters
| Name | Required | Description |
| :----------: | :------: | :--------------------------------------------------------------------------- |
| fields | No | Sparse fieldsets for resource types |
| filter | No | Filters for page resources |
| sort | No | The list of fields to sort the resources |
| page[size] | No | The number of page resources to display for the current page |
| page[number] | No | The page of page resources to display |
## Allowed Sort Fields
| Name | Description |
| :--------: | :------------------------------------------------------------------ |
| id | Sort resources on the primary key |
| name | Sort resources on the title of the page |
| slug | Sort resources on the URL slug of the page |
| created_at | Sort resources on the resource creation date |
| updated_at | Sort resources on the resource last modified date |
| deleted_at | Sort resources on the resource deletion date |
| random | Sort resources randomly. Ignored if other sort fields are provided. |
## Filters
| Name | Description |
| :--------: | :----------------------------------------------------------------- |
| id | Filter resources on the primary key |
| name | Filter resources on the title of the page |
| slug | Filter resources on the URL slug of the page |
| created_at | Filter resources on the resource creation date |
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
## Response
```json
{
pages: [
{
id: id,
name: "name",
slug: "slug",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
},
...
],
links: {
first: "first",
last: "last",
prev: "prev",
next: "next"
},
meta: {
current_page: current_page,
from: from,
path: "path",
per_page: per_page,
to: to
}
}
```
<Example>
<CURL>
```bash
curl https://staging.animethemes.moe/api/page/
```
</CURL>
</Example>
</Block>
+48
View File
@@ -0,0 +1,48 @@
---
title: Page Show
---
<Block>
# Page Show Endpoint
The page show endpoint returns a page resource.
## URL
```sh
GET /api/page/{slug}
```
## Parameters
| Name | Required | Description |
| :-----: | :------: | :------------------------------------------------------ |
| fields | No | Sparse fieldsets for resource types |
## Response
```json
{
page: {
id: id,
name: "name",
slug: "slug",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl https://staging.animethemes.moe/api/page/encoding/audio_normalization
```
</CURL>
</Example>
</Block>
+2811 -1545
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -17,7 +17,7 @@
"vuepress": "^1.5.3"
},
"dependencies": {
"dotenv": "^10.0",
"dotenv": "^16.0",
"vuepress-theme-api": "^1.0.1"
}
}