Core: Sort folders to bottom on Page Tree Builder

This commit is contained in:
fuma-nama
2024-08-06 00:16:10 +08:00
parent 4bf9851a43
commit f2801911db
18 changed files with 6212 additions and 131 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
Page Tree Builder: Sort folders to bottom
+4 -1
View File
@@ -11,7 +11,10 @@ apps/docs/shaders/*
**/test/fixtures/*.output.*
apps/docs/content/docs/ui/museum/*.mdx
apps/docs/content/docs/ui/museum/!index.mdx
!apps/docs/content/docs/ui/museum/index.mdx
apps/docs/content/docs/unkey/**/*.mdx
!apps/docs/content/docs/unkey/index.mdx
apps/docs/content/docs/ui/typescript.mdx
+4
View File
@@ -1,4 +1,8 @@
out
content/docs/ui/museum/*.mdx
!content/docs/ui/museum/index.mdx
content/docs/unkey/**/*.mdx
!content/docs/unkey/index.mdx
content/docs/ui/(integrations)/typescript.mdx
+5
View File
@@ -0,0 +1,5 @@
---
title: Unkey
description: Experimenting OpenAPI
index: true
---
+4
View File
@@ -0,0 +1,4 @@
{
"title": "Unkey",
"root": true
}
+15 -2
View File
@@ -3,18 +3,31 @@ import * as Typescript from 'fumadocs-typescript';
import * as path from 'node:path';
import { rimrafSync } from 'rimraf';
rimrafSync('./content/docs/ui/unkey', {
filter(v) {
return !v.endsWith('index.mdx') && !v.endsWith('meta.json');
},
});
rimrafSync('./content/docs/ui/museum', {
filter(v) {
return !v.endsWith('index.mdx');
return !v.endsWith('index.mdx') && !v.endsWith('meta.json');
},
});
void OpenAPI.generateFiles({
input: ['./*.yaml'],
input: ['./museum.yaml'],
output: './content/docs/ui',
per: 'operation',
});
void OpenAPI.generateFiles({
input: ['./unkey.json'],
output: './content/docs',
per: 'operation',
groupBy: 'tag',
});
const demoRegex = /^---type-table-demo---\r?\n(?<content>.+)\r?\n---end---$/gm;
void Typescript.generateFiles({
input: ['./content/docs/**/*.model.mdx'],
+6019
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -4,6 +4,7 @@ import {
LibraryIcon,
PaperclipIcon,
type LucideIcon,
KeyIcon,
} from 'lucide-react';
import mdx from '../../../packages/mdx/package.json';
import ui from '../../../packages/ui/package.json';
@@ -43,4 +44,12 @@ export const modes: Mode[] = [
version: mdx.version,
icon: PaperclipIcon,
},
{
param: 'unkey',
name: 'Unkey',
package: 'test',
description: 'Experimental OpenAPI',
version: '0',
icon: KeyIcon,
},
];
@@ -74,6 +74,7 @@ function buildAll(
skipIndex: boolean,
): PageTree.Node[] {
const output: PageTree.Node[] = [];
const folders: PageTree.Folder[] = [];
for (const node of [...nodes].sort((a, b) =>
a.file.name.localeCompare(b.file.name),
@@ -90,10 +91,11 @@ function buildAll(
}
if ('children' in node) {
output.push(buildFolderNode(node, false, ctx));
folders.push(buildFolderNode(node, false, ctx));
}
}
output.push(...folders);
return output;
}
+5 -5
View File
@@ -114,6 +114,11 @@ test('Page Tree: Nested Directories', async () => {
expect(result.pageTree, 'Page Tree').toMatchInlineSnapshot(`
{
"children": [
{
"name": "Hello",
"type": "page",
"url": "/test",
},
{
"children": [
{
@@ -125,11 +130,6 @@ test('Page Tree: Nested Directories', async () => {
"name": "Nested",
"type": "folder",
},
{
"name": "Hello",
"type": "page",
"url": "/test",
},
{
"children": [
{
+1 -1
View File
@@ -98,7 +98,7 @@ export async function generateFiles({
outPath = join(
outputDir,
filename,
result.method.tags[0],
getFilename(result.method.tags[0]),
`${getFilename(id)}.mdx`,
);
} else if (groupBy === 'route') {
+1 -1
View File
@@ -123,7 +123,7 @@ function render(
if (isObject(schema) && !ctx.parseObject) {
child.push(
renderer.ObjectCollapsible({ name }, [
renderer.ObjectCollapsible({ name: 'Attributes' }, [
render(name, schema, {
...ctx,
parseObject: true,
+30 -24
View File
@@ -208,40 +208,46 @@ export function APIPlayground({
>
{path.length > 0 ? (
<Accordion title="Path">
{path.map((field) =>
renderCustomField(
`path.${field.name}`,
field,
fields.path,
field.name,
),
)}
<div className="flex flex-col gap-4">
{path.map((field) =>
renderCustomField(
`path.${field.name}`,
field,
fields.path,
field.name,
),
)}
</div>
</Accordion>
) : null}
{query.length > 0 ? (
<Accordion title="Query">
{query.map((field) =>
renderCustomField(
`query.${field.name}`,
field,
fields.query,
field.name,
),
)}
<div className="flex flex-col gap-4">
{query.map((field) =>
renderCustomField(
`query.${field.name}`,
field,
fields.query,
field.name,
),
)}
</div>
</Accordion>
) : null}
{header.length > 0 ? (
<Accordion title="Headers">
{header.map((field) =>
renderCustomField(
`header.${field.name}`,
field,
fields.header,
field.name,
),
)}
<div className="flex flex-col gap-4">
{header.map((field) =>
renderCustomField(
`header.${field.name}`,
field,
fields.header,
field.name,
),
)}
</div>
</Accordion>
) : null}
+18 -16
View File
@@ -255,15 +255,16 @@ Price of a ticket for the special event
```bash
curl -X POST "https://api.fake-museum-example.com/v1/special-events" \
-H "Content-Type: application/json" \
-d '{
"name": "Pirate Coding Workshop",
"location": "Computer Room",
"eventDescription": "Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R lang).",
"dates": [
"2023-10-29"
],
"price": 25
}'
"name": "Pirate Coding Workshop",
"location": "Computer Room",
"eventDescription": "Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R lang).",
"dates": [
"2023-10-29"
],
"price": 25
}'
```
</Request>
@@ -585,15 +586,16 @@ An identifier for a special event.
```bash
curl -X PATCH "https://api.fake-museum-example.com/v1/special-events/dad4bce8-f5cb-4078-a211-995864315e39" \
-H "Content-Type: application/json" \
-d '{
"name": "Pirate Coding Workshop",
"location": "Computer Room",
"eventDescription": "Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R lang).",
"dates": [
"2023-10-29"
],
"price": 25
}'
"name": "Pirate Coding Workshop",
"location": "Computer Room",
"eventDescription": "Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R lang).",
"dates": [
"2023-10-29"
],
"price": 25
}'
```
</Request>
+7 -6
View File
@@ -94,13 +94,14 @@ Phone number for the ticket purchaser (optional).
```bash
curl -X POST "https://api.fake-museum-example.com/v1/tickets" \
-H "Content-Type: application/json" \
-d '{
"ticketType": "event",
"eventId": "3be6453c-03eb-4357-ae5a-984a0e574a54",
"ticketDate": "2023-10-29",
"email": "[email protected]",
"phone": "+1(234)-567-8910"
}'
"ticketType": "event",
"eventId": "3be6453c-03eb-4357-ae5a-984a0e574a54",
"ticketDate": "2023-10-29",
"email": "[email protected]",
"phone": "+1(234)-567-8910"
}'
```
</Request>
+5 -4
View File
@@ -176,11 +176,12 @@ export interface Response {
```bash
curl -X POST "http://petstore.swagger.io/v1/pets" \
-H "Content-Type: application/json" \
-d '{
"id": 0,
"name": "string",
"tag": "string"
}'
"id": 0,
"name": "string",
"tag": "string"
}'
```
</Request>
+6 -4
View File
@@ -524,9 +524,10 @@ The name for your API. This is not customer facing.
```bash
curl -X POST "https://api.unkey.dev/v1/apis.createApi" \
-H "Content-Type: application/json" \
-d '{
"name": "my-api"
}'
"name": "my-api"
}'
```
</Request>
@@ -1607,9 +1608,10 @@ The id of the api to delete
```bash
curl -X POST "https://api.unkey.dev/v1/apis.deleteApi" \
-H "Content-Type: application/json" \
-d '{
"apiId": "api_1234"
}'
"apiId": "api_1234"
}'
```
</Request>
+71 -66
View File
@@ -635,9 +635,10 @@ The id of the key to revoke
```bash
curl -X POST "https://api.unkey.dev/v1/keys.deleteKey" \
-H "Content-Type: application/json" \
-d '{
"keyId": "key_1234"
}'
"keyId": "key_1234"
}'
```
</Request>
@@ -1115,7 +1116,7 @@ This is a place for dynamic meta data, anything that feels useful for you should
<span>Example: `{"billingTier":"PRO","trialEnds":"2023-06-16T17:16:37.161Z"}`</span>
<ObjectCollapsible name={"meta"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"[key: string]"} type={"null"} required={false} deprecated={undefined}>
@@ -1155,7 +1156,7 @@ Unkey enables you to refill verifications for each key at regular intervals.
<span>Example: `{"interval":"daily","amount":100}`</span>
<ObjectCollapsible name={"refill"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"interval"} type={"string"} required={true} deprecated={undefined}>
@@ -1183,7 +1184,7 @@ Unkey comes with per-key ratelimiting out of the box.
<span>Example: `{"type":"fast","limit":10,"refillRate":1,"refillInterval":60}`</span>
<ObjectCollapsible name={"ratelimit"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"type"} type={"string"} required={true} deprecated={undefined}>
@@ -1254,34 +1255,35 @@ Sets if key is enabled or disabled. Disabled keys are not valid.
```bash
curl -X POST "https://api.unkey.dev/v1/keys.createKey" \
-H "Content-Type: application/json" \
-d '{
"apiId": "api_123",
"prefix": "string",
"name": "my key",
"byteLength": 16,
"ownerId": "team_123",
"meta": {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
},
"roles": [
"admin",
"finance"
],
"expires": 1623869797161,
"remaining": 1000,
"refill": {
"interval": "daily",
"amount": 100
},
"ratelimit": {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
},
"enabled": false
}'
"apiId": "api_123",
"prefix": "string",
"name": "my key",
"byteLength": 16,
"ownerId": "team_123",
"meta": {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
},
"roles": [
"admin",
"finance"
],
"expires": 1623869797161,
"remaining": 1000,
"refill": {
"interval": "daily",
"amount": 100
},
"ratelimit": {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
},
"enabled": false
}'
```
</Request>
@@ -1772,10 +1774,11 @@ The key to verify
```bash
curl -X POST "https://api.unkey.dev/v1/keys.verifyKey" \
-H "Content-Type: application/json" \
-d '{
"apiId": "api_1234",
"key": "sk_1234"
}'
"apiId": "api_1234",
"key": "sk_1234"
}'
```
</Request>
@@ -2324,7 +2327,7 @@ Any additional metadata you want to store with the key
<span>Example: `{"roles":["admin","user"],"stripeCustomerId":"cus_1234"}`</span>
<ObjectCollapsible name={"meta"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"[key: string]"} type={"null"} required={false} deprecated={undefined}>
@@ -2348,7 +2351,7 @@ Unkey comes with per-key ratelimiting out of the box. Set `null` to disable.
<span>Example: `{"type":"fast","limit":10,"refillRate":1,"refillInterval":60}`</span>
<ObjectCollapsible name={"ratelimit"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"type"} type={"string"} required={true} deprecated={undefined}>
@@ -2400,7 +2403,7 @@ Unkey enables you to refill verifications for each key at regular intervals.
<span>Example: `{"interval":"daily","amount":100}`</span>
<ObjectCollapsible name={"refill"}>
<ObjectCollapsible name={"Attributes"}>
<Property name={"interval"} type={"string"} required={true} deprecated={undefined}>
@@ -2451,31 +2454,32 @@ Set if key is enabled or disabled. If disabled, the key cannot be used to verify
```bash
curl -X POST "https://api.unkey.dev/v1/keys.updateKey" \
-H "Content-Type: application/json" \
-d '{
"keyId": "key_123",
"name": "Customer X",
"ownerId": "user_123",
"meta": {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
},
"expires": 0,
"ratelimit": {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
},
"remaining": 1000,
"refill": {
"interval": "daily",
"amount": 100
},
"enabled": true
}'
"keyId": "key_123",
"name": "Customer X",
"ownerId": "user_123",
"meta": {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
},
"expires": 0,
"ratelimit": {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
},
"remaining": 1000,
"refill": {
"interval": "daily",
"amount": 100
},
"enabled": true
}'
```
</Request>
@@ -2964,11 +2968,12 @@ The value you want to set, add or subtract the remaining count by
```bash
curl -X POST "https://api.unkey.dev/v1/keys.updateRemaining" \
-H "Content-Type: application/json" \
-d '{
"keyId": "key_123",
"op": "increment",
"value": 1
}'
"keyId": "key_123",
"op": "increment",
"value": 1
}'
```
</Request>