mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-02 03:55:58 +00:00
fix: 后端代码格式化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# OpenIsle Documentation
|
||||
|
||||
## 要求
|
||||
|
||||
使用 [bun](https://bun.com/) 作为工具链的运行时,版本 1.2+。
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { createRelativeLink } from 'fumadocs-ui/mdx';
|
||||
import { getMDXComponents } from '@/mdx-components';
|
||||
import { Card, Cards } from 'fumadocs-ui/components/card';
|
||||
import { getPageTreePeers } from 'fumadocs-core/server';
|
||||
import { source } from "@/lib/source";
|
||||
import {
|
||||
DocsBody,
|
||||
DocsDescription,
|
||||
DocsPage,
|
||||
DocsTitle,
|
||||
} from "fumadocs-ui/page";
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { createRelativeLink } from "fumadocs-ui/mdx";
|
||||
import { getMDXComponents } from "@/mdx-components";
|
||||
import { Card, Cards } from "fumadocs-ui/components/card";
|
||||
import { getPageTreePeers } from "fumadocs-core/server";
|
||||
|
||||
function DocsCategory({ url }: { url: string }) {
|
||||
return (
|
||||
@@ -19,7 +24,7 @@ function DocsCategory({ url }: { url: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
export default async function Page(props: PageProps<'/[[...slug]]'>) {
|
||||
export default async function Page(props: PageProps<"/[[...slug]]">) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound();
|
||||
@@ -48,7 +53,7 @@ export async function generateStaticParams() {
|
||||
}
|
||||
|
||||
export async function generateMetadata(
|
||||
props: PageProps<'/[[...slug]]'>
|
||||
props: PageProps<"/[[...slug]]">,
|
||||
): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import { source } from '@/lib/source';
|
||||
import { CodeXmlIcon, CompassIcon, ServerIcon } from 'lucide-react';
|
||||
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
||||
import { baseOptions } from "@/lib/layout.shared";
|
||||
import { source } from "@/lib/source";
|
||||
import { CodeXmlIcon, CompassIcon, ServerIcon } from "lucide-react";
|
||||
|
||||
function TabIcon({
|
||||
color = 'var(--color-fd-foreground)',
|
||||
color = "var(--color-fd-foreground)",
|
||||
children,
|
||||
}: {
|
||||
color?: string;
|
||||
@@ -15,7 +15,7 @@ function TabIcon({
|
||||
className="[&_svg]:size-full rounded-lg size-full text-(--tab-color) max-md:bg-(--tab-color)/10 max-md:border max-md:p-1.5"
|
||||
style={
|
||||
{
|
||||
'--tab-color': color,
|
||||
"--tab-color": color,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
@@ -28,7 +28,7 @@ function TabTitle({ children }: { children: React.ReactNode }) {
|
||||
return <span className="text-[11px]">{children}</span>;
|
||||
}
|
||||
|
||||
export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
export default function Layout({ children }: LayoutProps<"/">) {
|
||||
return (
|
||||
// @ts-ignore
|
||||
<DocsLayout
|
||||
@@ -38,9 +38,9 @@ export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
prefetch: true,
|
||||
tabs: [
|
||||
{
|
||||
title: 'OpenIsle 前端',
|
||||
title: "OpenIsle 前端",
|
||||
description: <TabTitle>前端开发文档</TabTitle>,
|
||||
url: '/frontend',
|
||||
url: "/frontend",
|
||||
icon: (
|
||||
<TabIcon color="#4ca154">
|
||||
<CompassIcon />
|
||||
@@ -48,9 +48,9 @@ export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'OpenIsle 后端',
|
||||
title: "OpenIsle 后端",
|
||||
description: <TabTitle>后端开发文档</TabTitle>,
|
||||
url: '/backend',
|
||||
url: "/backend",
|
||||
icon: (
|
||||
<TabIcon color="#1f66f4">
|
||||
<ServerIcon />
|
||||
@@ -58,9 +58,9 @@ export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'OpenIsle API',
|
||||
title: "OpenIsle API",
|
||||
description: <TabTitle>后端 API 文档</TabTitle>,
|
||||
url: '/openapi',
|
||||
url: "/openapi",
|
||||
icon: (
|
||||
<TabIcon color="#677489">
|
||||
<CodeXmlIcon />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import 'tailwindcss';
|
||||
@import 'fumadocs-ui/css/neutral.css';
|
||||
@import 'fumadocs-ui/css/preset.css';
|
||||
@import 'fumadocs-openapi/css/preset.css';
|
||||
@import "tailwindcss";
|
||||
@import "fumadocs-ui/css/neutral.css";
|
||||
@import "fumadocs-ui/css/preset.css";
|
||||
@import "fumadocs-openapi/css/preset.css";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import '@/app/global.css';
|
||||
import { Provider } from '@/app/provider';
|
||||
import { Inter } from 'next/font/google';
|
||||
import "@/app/global.css";
|
||||
import { Provider } from "@/app/provider";
|
||||
import { Inter } from "next/font/google";
|
||||
|
||||
const inter = Inter({
|
||||
subsets: ['latin'],
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
export default function Layout({ children }: LayoutProps<"/">) {
|
||||
return (
|
||||
<html lang="zh" className={inter.className} suppressHydrationWarning>
|
||||
<body className="flex flex-col min-h-screen">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import { RootProvider } from 'fumadocs-ui/provider';
|
||||
import type { ReactNode } from 'react';
|
||||
import { RootProvider } from "fumadocs-ui/provider";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export function Provider({ children }: { children: ReactNode }) {
|
||||
return <RootProvider>{children}</RootProvider>;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
|
||||
|
||||
/**
|
||||
* Shared layout configurations
|
||||
*/
|
||||
export function baseOptions(): BaseLayoutProps {
|
||||
return {
|
||||
githubUrl: 'https://github.com/nagisa77/OpenIsle',
|
||||
githubUrl: "https://github.com/nagisa77/OpenIsle",
|
||||
nav: {
|
||||
title: 'OpenIsle Docs',
|
||||
url: '/',
|
||||
title: "OpenIsle Docs",
|
||||
url: "/",
|
||||
},
|
||||
searchToggle: {
|
||||
enabled: false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
// forward them so that Fumadocs can also use your media adapter in a client component
|
||||
export { OpenIsleMediaAdapter } from './media-adapter';
|
||||
export { OpenIsleMediaAdapter } from "./media-adapter";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MediaAdapter } from 'fumadocs-openapi';
|
||||
import type { MediaAdapter } from "fumadocs-openapi";
|
||||
|
||||
export const OpenIsleMediaAdapter: MediaAdapter = {
|
||||
encode(data) {
|
||||
@@ -6,16 +6,16 @@ export const OpenIsleMediaAdapter: MediaAdapter = {
|
||||
},
|
||||
// returns code that inits a `body` variable, used for request body
|
||||
generateExample(data, ctx) {
|
||||
if (ctx.lang === 'js') {
|
||||
if (ctx.lang === "js") {
|
||||
return `const body = "hello world"`;
|
||||
}
|
||||
|
||||
if (ctx.lang === 'python') {
|
||||
if (ctx.lang === "python") {
|
||||
return `body = "hello world"`;
|
||||
}
|
||||
|
||||
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
||||
ctx.addImport('strings');
|
||||
if (ctx.lang === "go" && "addImport" in ctx) {
|
||||
ctx.addImport("strings");
|
||||
|
||||
return `body := strings.NewReader("hello world")`;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createOpenAPI } from 'fumadocs-openapi/server';
|
||||
import { createOpenAPI } from "fumadocs-openapi/server";
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
input: ['https://staging.open-isle.com/api/v3/api-docs'],
|
||||
input: ["https://staging.open-isle.com/api/v3/api-docs"],
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
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';
|
||||
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: '/',
|
||||
baseUrl: "/",
|
||||
source: docs.toFumadocsSource(),
|
||||
pageTree: {
|
||||
transformers: [transformerOpenAPI()],
|
||||
@@ -26,10 +26,10 @@ export const source = loader({
|
||||
});
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
proxyUrl: '/api/proxy',
|
||||
proxyUrl: "/api/proxy",
|
||||
mediaAdapters: {
|
||||
// override the default adapter of `application/json`
|
||||
'application/json': {
|
||||
"application/json": {
|
||||
...Adapters.OpenIsleMediaAdapter,
|
||||
client: ClientAdapters.OpenIsleMediaAdapter,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
||||
import type { MDXComponents } from 'mdx/types';
|
||||
import { APIPage } from 'fumadocs-openapi/ui';
|
||||
import { openapi } from '@/lib/openapi';
|
||||
import defaultMdxComponents from "fumadocs-ui/mdx";
|
||||
import type { MDXComponents } from "mdx/types";
|
||||
import { APIPage } from "fumadocs-openapi/ui";
|
||||
import { openapi } from "@/lib/openapi";
|
||||
|
||||
// use this function to get MDX components, you will need it for rendering MDX
|
||||
export function getMDXComponents(components?: MDXComponents): MDXComponents {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createMDX } from 'fumadocs-mdx/next';
|
||||
import { createMDX } from "fumadocs-mdx/next";
|
||||
|
||||
const withMDX = createMDX();
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
output: 'export',
|
||||
output: "export",
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -30,4 +30,4 @@
|
||||
"tailwindcss": "^4.1.12",
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {},
|
||||
"@tailwindcss/postcss": {},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { generateFiles } from 'fumadocs-openapi';
|
||||
import { openapi } from '@/lib/openapi';
|
||||
import { generateFiles } from "fumadocs-openapi";
|
||||
import { openapi } from "@/lib/openapi";
|
||||
|
||||
void generateFiles({
|
||||
input: openapi,
|
||||
output: './content/docs/openapi/(generated)',
|
||||
output: "./content/docs/openapi/(generated)",
|
||||
// we recommend to enable it
|
||||
// make sure your endpoint description doesn't break MDX syntax.
|
||||
includeDescription: true,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
defineDocs,
|
||||
frontmatterSchema,
|
||||
metaSchema,
|
||||
} from 'fumadocs-mdx/config';
|
||||
} from "fumadocs-mdx/config";
|
||||
|
||||
// You can customise Zod schemas for frontmatter and `meta.json` here
|
||||
// see https://fumadocs.dev/docs/mdx/collections#define-docs
|
||||
|
||||
Reference in New Issue
Block a user