mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-30 14:37:35 +08:00
docs: 引入 Fumadocs
ci: set up github actions
This commit is contained in:
19
docs/lib/layout.shared.tsx
Normal file
19
docs/lib/layout.shared.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
|
||||
/**
|
||||
* Shared layout configurations
|
||||
*/
|
||||
export function baseOptions(): BaseLayoutProps {
|
||||
return {
|
||||
githubUrl: 'https://github.com/nagisa77/OpenIsle',
|
||||
nav: {
|
||||
title: 'OpenIsle Docs',
|
||||
url: '/docs',
|
||||
},
|
||||
searchToggle: {
|
||||
enabled: false,
|
||||
},
|
||||
// see https://fumadocs.dev/docs/ui/navigation/links
|
||||
links: [],
|
||||
};
|
||||
}
|
||||
4
docs/lib/media-adapter.client.ts
Normal file
4
docs/lib/media-adapter.client.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
'use client';
|
||||
|
||||
// forward them so that Fumadocs can also use your media adapter in a client component
|
||||
export { OpenIsleMediaAdapter } from './media-adapter';
|
||||
23
docs/lib/media-adapter.ts
Normal file
23
docs/lib/media-adapter.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { MediaAdapter } from 'fumadocs-openapi';
|
||||
|
||||
export const OpenIsleMediaAdapter: MediaAdapter = {
|
||||
encode(data) {
|
||||
return JSON.stringify(data.body);
|
||||
},
|
||||
// returns code that inits a `body` variable, used for request body
|
||||
generateExample(data, ctx) {
|
||||
if (ctx.lang === 'js') {
|
||||
return `const body = "hello world"`;
|
||||
}
|
||||
|
||||
if (ctx.lang === 'python') {
|
||||
return `body = "hello world"`;
|
||||
}
|
||||
|
||||
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
||||
ctx.addImport('strings');
|
||||
|
||||
return `body := strings.NewReader("hello world")`;
|
||||
}
|
||||
},
|
||||
};
|
||||
5
docs/lib/openapi.ts
Normal file
5
docs/lib/openapi.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createOpenAPI } from 'fumadocs-openapi/server';
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
input: ['https://staging.open-isle.com/api/v3/api-docs'],
|
||||
});
|
||||
37
docs/lib/source.ts
Normal file
37
docs/lib/source.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { createElement } from 'react';
|
||||
import { icons } from 'lucide-react';
|
||||
import { loader } from 'fumadocs-core/source';
|
||||
import { transformerOpenAPI } from 'fumadocs-openapi/server';
|
||||
import { createOpenAPI } from 'fumadocs-openapi/server';
|
||||
import { docs } from '@/.source';
|
||||
import * as Adapters from './media-adapter';
|
||||
import * as ClientAdapters from './media-adapter.client';
|
||||
|
||||
// See https://fumadocs.vercel.app/docs/headless/source-api for more info
|
||||
export const source = loader({
|
||||
// it assigns a URL to your pages
|
||||
baseUrl: '/docs',
|
||||
source: docs.toFumadocsSource(),
|
||||
pageTree: {
|
||||
transformers: [transformerOpenAPI()],
|
||||
},
|
||||
icon(icon) {
|
||||
if (!icon) {
|
||||
return;
|
||||
}
|
||||
if (icon in icons) {
|
||||
return createElement(icons[icon as keyof typeof icons]);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
proxyUrl: '/api/proxy',
|
||||
mediaAdapters: {
|
||||
// override the default adapter of `application/json`
|
||||
'application/json': {
|
||||
...Adapters.OpenIsleMediaAdapter,
|
||||
client: ClientAdapters.OpenIsleMediaAdapter,
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user