chore: add helix-api and workspace config to monorepo
This commit is contained in:
40 files changed
+7145
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import type { Route } from './+types/api-reference';
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';
|
||||
import { source } from '@/lib/source';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import { APIPage } from '@/components/api-page';
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [
|
||||
{ title: 'API Reference' },
|
||||
{ name: 'description', content: 'OpenAPI reference for Helix API.' },
|
||||
];
|
||||
}
|
||||
|
||||
export default function ApiReference() {
|
||||
return (
|
||||
<DocsLayout {...baseOptions()} tree={source.getPageTree()}>
|
||||
<DocsPage full>
|
||||
<DocsTitle>API Reference</DocsTitle>
|
||||
<DocsDescription>
|
||||
Edit openapi/openapi.yaml to maintain this API documentation.
|
||||
</DocsDescription>
|
||||
<DocsBody>
|
||||
<APIPage document="helix" />
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
</DocsLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { Route } from './+types/docs';
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import {
|
||||
DocsBody,
|
||||
DocsDescription,
|
||||
DocsPage,
|
||||
DocsTitle,
|
||||
MarkdownCopyButton,
|
||||
ViewOptionsPopover,
|
||||
} from 'fumadocs-ui/layouts/docs/page';
|
||||
import { source } from '@/lib/source';
|
||||
import browserCollections from 'collections/browser';
|
||||
import { baseOptions, gitConfig } from '@/lib/layout.shared';
|
||||
import { useFumadocsLoader } from 'fumadocs-core/source/client';
|
||||
import { useMDXComponents } from '@/components/mdx';
|
||||
|
||||
export async function loader({ params }: Route.LoaderArgs) {
|
||||
const slugs = params['*'].split('/').filter((v) => v.length > 0);
|
||||
const page = source.getPage(slugs);
|
||||
if (!page) throw new Response('Not found', { status: 404 });
|
||||
|
||||
return {
|
||||
slugs: page.slugs,
|
||||
path: page.path,
|
||||
pageTree: await source.serializePageTree(source.getPageTree()),
|
||||
};
|
||||
}
|
||||
|
||||
const clientLoader = browserCollections.docs.createClientLoader({
|
||||
component(
|
||||
{ toc, frontmatter, default: Mdx },
|
||||
// you can define props for the component
|
||||
{
|
||||
markdownUrl,
|
||||
path,
|
||||
}: {
|
||||
markdownUrl: string;
|
||||
path: string;
|
||||
},
|
||||
) {
|
||||
return (
|
||||
<DocsPage toc={toc}>
|
||||
<title>{frontmatter.title}</title>
|
||||
<meta name="description" content={frontmatter.description} />
|
||||
<DocsTitle>{frontmatter.title}</DocsTitle>
|
||||
<DocsDescription>{frontmatter.description}</DocsDescription>
|
||||
<div className="flex flex-row gap-2 items-center border-b -mt-4 pb-6">
|
||||
<MarkdownCopyButton markdownUrl={markdownUrl} />
|
||||
<ViewOptionsPopover
|
||||
markdownUrl={markdownUrl}
|
||||
githubUrl={`https://github.com/${gitConfig.user}/${gitConfig.repo}/blob/${gitConfig.branch}/content/docs/${path}`}
|
||||
/>
|
||||
</div>
|
||||
<DocsBody>
|
||||
<Mdx components={useMDXComponents()} />
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export default function Page({ loaderData }: Route.ComponentProps) {
|
||||
const { pageTree, slugs, path } = useFumadocsLoader(loaderData);
|
||||
const markdownUrl = `/llms.mdx/docs/${[...slugs, 'index.mdx'].join('/')}`;
|
||||
|
||||
return (
|
||||
<DocsLayout {...baseOptions()} tree={pageTree}>
|
||||
{clientLoader.useContent(loaderData.path, {
|
||||
markdownUrl,
|
||||
path,
|
||||
})}
|
||||
</DocsLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Route } from './+types/home';
|
||||
import { HomeLayout } from 'fumadocs-ui/layouts/home';
|
||||
import { Link } from 'react-router';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [
|
||||
{ title: 'New React Router App' },
|
||||
{ name: 'description', content: 'Welcome to React Router!' },
|
||||
];
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<HomeLayout {...baseOptions()}>
|
||||
<div className="p-4 flex flex-col items-center justify-center text-center flex-1">
|
||||
<h1 className="text-xl font-bold mb-2">Helix API Documentation</h1>
|
||||
<p className="text-fd-muted-foreground mb-4">
|
||||
Powered by Vite, React Router and Fumadocs OpenAPI.
|
||||
</p>
|
||||
<div className="flex items-center gap-3">
|
||||
<Link
|
||||
className="text-sm bg-fd-primary text-fd-primary-foreground rounded-full font-medium px-4 py-2.5"
|
||||
to="/api-reference"
|
||||
>
|
||||
Open API Reference
|
||||
</Link>
|
||||
<Link className="text-sm rounded-full font-medium px-4 py-2.5 border" to="/docs">
|
||||
Open MDX Docs
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</HomeLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { Route } from './+types/not-found';
|
||||
import { HomeLayout } from 'fumadocs-ui/layouts/home';
|
||||
import { Link } from 'react-router';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Not Found' }];
|
||||
}
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<HomeLayout {...baseOptions()}>
|
||||
<div className="p-4 flex flex-col items-center justify-center text-center flex-1">
|
||||
<h1 className="text-xl font-bold mb-2">Not Found</h1>
|
||||
<p className="text-fd-muted-foreground mb-4">This page could not be found.</p>
|
||||
<Link
|
||||
className="text-sm bg-fd-primary text-fd-primary-foreground rounded-full font-medium px-4 py-2.5"
|
||||
to="/docs"
|
||||
>
|
||||
Back to Docs
|
||||
</Link>
|
||||
</div>
|
||||
</HomeLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { createFromSource } from 'fumadocs-core/search/server';
|
||||
import { source } from '@/lib/source';
|
||||
|
||||
const server = createFromSource(source, {
|
||||
language: 'english',
|
||||
});
|
||||
|
||||
export async function loader() {
|
||||
return server.staticGET();
|
||||
}
|
||||
Reference in new issue
Block a user