mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
UI & OpenAPI: Optimize imports
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-ui': minor
|
||||
---
|
||||
|
||||
Rename `Layout` in `fumadocs-ui/layout` to `HomeLayout` in `fumadocs-ui/home-layout`
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Layout } from 'fumadocs-ui/layout';
|
||||
import type { ReactNode } from 'react';
|
||||
import { HomeLayout } from 'fumadocs-ui/home-layout';
|
||||
import { baseOptions } from '@/app/layout.config';
|
||||
|
||||
export default function HomeLayout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<Layout {...baseOptions}>
|
||||
<HomeLayout {...baseOptions}>
|
||||
{children}
|
||||
<Footer />
|
||||
</Layout>
|
||||
</HomeLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { type BaseLayoutProps, type DocsLayoutProps } from 'fumadocs-ui/layout';
|
||||
import { type DocsLayoutProps } from 'fumadocs-ui/layout';
|
||||
import { BookIcon, LayoutTemplateIcon } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
import { RootToggle } from 'fumadocs-ui/components/layout/root-toggle';
|
||||
import type { HomeLayoutProps } from 'fumadocs-ui/home-layout';
|
||||
import { FumadocsIcon, NavChildren } from '@/app/layout.client';
|
||||
import Logo from '@/public/logo.png';
|
||||
import { utils } from '@/utils/source';
|
||||
import { modes } from '@/utils/modes';
|
||||
|
||||
export const baseOptions: BaseLayoutProps = {
|
||||
export const baseOptions: HomeLayoutProps = {
|
||||
githubUrl: 'https://github.com/fuma-nama/fumadocs',
|
||||
nav: {
|
||||
title: (
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as Base from 'fumadocs-ui/components/codeblock';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { getHighlighter } from 'shiki';
|
||||
import { createHighlighter } from 'shiki';
|
||||
|
||||
const highlighter = await getHighlighter({
|
||||
const highlighter = await createHighlighter({
|
||||
langs: ['bash', 'ts', 'tsx'],
|
||||
themes: ['github-light', 'github-dark'],
|
||||
});
|
||||
|
||||
@@ -12,10 +12,10 @@ Add a navbar and search dialog across other pages.
|
||||
It doesn't contain a sidebar, a page tree is not required.
|
||||
|
||||
```jsx
|
||||
import { Layout } from 'fumadocs-ui/layout';
|
||||
import { HomeLayout } from 'fumadocs-ui/home-layout';
|
||||
|
||||
export default function HomeLayout({ children }) {
|
||||
return <Layout>{children}</Layout>;
|
||||
export default function Layout({ children }) {
|
||||
return <HomeLayout>{children}</HomeLayout>;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ const withMDX = createMDX({
|
||||
dark: 'catppuccin-mocha',
|
||||
},
|
||||
transformers: [
|
||||
...rehypeCodeDefaultOptions.transformers,
|
||||
...(rehypeCodeDefaultOptions.transformers ?? []),
|
||||
transformerTwoslash(),
|
||||
{
|
||||
name: 'fumadocs:remove-escape',
|
||||
|
||||
+10
-10
@@ -14,7 +14,7 @@
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@next/env": "^14.2.4",
|
||||
"@next/env": "^14.2.5",
|
||||
"@radix-ui/react-popover": "^1.1.1",
|
||||
"@radix-ui/react-tooltip": "^1.1.2",
|
||||
"algoliasearch": "^4.24.0",
|
||||
@@ -22,32 +22,32 @@
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-docgen": "workspace:^",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-openapi": "workspace:^",
|
||||
"fumadocs-twoslash": "workspace:^",
|
||||
"fumadocs-typescript": "workspace:^",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"geist": "^1.3.0",
|
||||
"geist": "^1.3.1",
|
||||
"katex": "^0.16.11",
|
||||
"lucide-react": "^0.400.0",
|
||||
"next": "^14.2.4",
|
||||
"lucide-react": "^0.408.0",
|
||||
"next": "^14.2.5",
|
||||
"phenomenon": "^1.6.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"rehype-katex": "^7.0.0",
|
||||
"remark-math": "^6.0.0",
|
||||
"shiki": "^1.10.1",
|
||||
"tailwind-merge": "^2.3.0",
|
||||
"shiki": "^1.10.3",
|
||||
"tailwind-merge": "^2.4.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "^14.2.4",
|
||||
"@next/eslint-plugin-next": "^14.2.4",
|
||||
"@next/bundle-analyzer": "^14.2.5",
|
||||
"@next/eslint-plugin-next": "^14.2.5",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-openapi": "workspace:^",
|
||||
"glslify": "^7.1.1",
|
||||
"glslx": "^0.3.0",
|
||||
"postcss": "^8.4.39",
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"**/*.ts",
|
||||
"**/*.mts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
".next/types/**/*.ts",
|
||||
"next.config.js"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
"@fumadocs/content-collections": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@content-collections/core": "^0.6.0",
|
||||
"@content-collections/core": "^0.6.2",
|
||||
"@content-collections/mdx": "^0.1.3",
|
||||
"@content-collections/next": "^0.2.0",
|
||||
"@types/mdx": "^2.0.13",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"@fumadocs/mdx-remote": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
|
||||
+3
-3
@@ -25,12 +25,12 @@
|
||||
"concurrently": "^8.2.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-tailwindcss": "^3.17.4",
|
||||
"prettier": "^3.3.2",
|
||||
"rimraf": "^6.0.0",
|
||||
"prettier": "^3.3.3",
|
||||
"rimraf": "^6.0.1",
|
||||
"tsup": "8.1.0",
|
||||
"turbo": "2.0.6",
|
||||
"typescript": "^5.5.3",
|
||||
"vitest": "^2.0.0"
|
||||
"vitest": "^2.0.2"
|
||||
},
|
||||
"packageManager": "[email protected]",
|
||||
"engines": {
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"rehype-img-size": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@content-collections/core": "^0.6.0",
|
||||
"@content-collections/core": "^0.6.2",
|
||||
"@content-collections/mdx": "^0.1.3",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
|
||||
@@ -127,8 +127,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@formatjs/intl-localematcher": "^0.5.4",
|
||||
"@shikijs/rehype": "^1.10.1",
|
||||
"@shikijs/transformers": "^1.10.1",
|
||||
"@shikijs/rehype": "^1.10.3",
|
||||
"@shikijs/transformers": "^1.10.3",
|
||||
"flexsearch": "0.7.21",
|
||||
"github-slugger": "^2.0.0",
|
||||
"negotiator": "^0.6.3",
|
||||
@@ -138,7 +138,7 @@
|
||||
"remark-gfm": "^4.0.0",
|
||||
"remark-mdx": "^3.0.1",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"shiki": "^1.10.1",
|
||||
"shiki": "^1.10.3",
|
||||
"swr": "^2.2.5",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
@@ -150,12 +150,12 @@
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/negotiator": "^0.6.3",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"algoliasearch": "^4.24.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"tsconfig": "workspace:*",
|
||||
"unified": "^11.0.5"
|
||||
},
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
"description": "Used to track dependency versions in create-fumadocs-app",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@content-collections/core": "^0.6.0",
|
||||
"@content-collections/core": "^0.6.2",
|
||||
"@content-collections/mdx": "^0.1.3",
|
||||
"@content-collections/next": "^0.2.0",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"postcss": "^8.4.39",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cross-spawn": "^6.0.6",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fast-glob": "^3.3.1",
|
||||
"tsconfig": "workspace:*"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { type BaseLayoutProps, type DocsLayoutProps } from 'fumadocs-ui/layout';
|
||||
import { type DocsLayoutProps } from 'fumadocs-ui/layout';
|
||||
import { type HomeLayoutProps } from 'fumadocs-ui/home-layout';
|
||||
import { pageTree } from '@/app/source';
|
||||
|
||||
// shared configuration
|
||||
export const baseOptions: BaseLayoutProps = {
|
||||
export const baseOptions: HomeLayoutProps = {
|
||||
nav: {
|
||||
title: 'My App',
|
||||
},
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"@types/estree": "^1.0.5",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"remark": "^15.0.0",
|
||||
"tsconfig": "workspace:*",
|
||||
|
||||
@@ -73,12 +73,12 @@
|
||||
"devDependencies": {
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/micromatch": "^4.0.9",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/ws": "^8.5.10",
|
||||
"@types/ws": "^8.5.11",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"tsconfig": "workspace:*",
|
||||
"unified": "^11.0.5",
|
||||
"vfile": "^6.0.1"
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
"@types/react": "^18.3.3",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"tsconfig": "workspace:*",
|
||||
"unified": "^11.0.5",
|
||||
"webpack": "^5.90.3"
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"js-yaml": "^4.1.0",
|
||||
"json-schema-to-typescript": "^14.1.0",
|
||||
"lucide-react": "^0.400.0",
|
||||
"lucide-react": "^0.408.0",
|
||||
"openapi-sampler": "^1.5.1",
|
||||
"react-hook-form": "^7.52.1",
|
||||
"shiki": "^1.10.3",
|
||||
@@ -60,11 +60,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "20.14.9",
|
||||
"@types/node": "20.14.10",
|
||||
"@types/openapi-sampler": "^1.0.3",
|
||||
"@types/react": "^18.3.3",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"openapi-types": "^12.1.3",
|
||||
"tsconfig": "workspace:*"
|
||||
},
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
export * from './components';
|
||||
export { APIPlayground } from './playground';
|
||||
|
||||
export const APIPlayground = dynamic(() =>
|
||||
import('./playground').then((mod) => mod.APIPlayground),
|
||||
);
|
||||
|
||||
export const Responses = Tabs;
|
||||
export const Response = Tab;
|
||||
|
||||
@@ -3,7 +3,6 @@ import { defineConfig } from 'tsup';
|
||||
export default defineConfig({
|
||||
entry: ['./src/index.ts', './src/ui/index.ts'],
|
||||
format: 'esm',
|
||||
external: ['shiki'],
|
||||
dts: true,
|
||||
target: 'es2022',
|
||||
});
|
||||
|
||||
@@ -28,15 +28,18 @@
|
||||
"@shikijs/twoslash": "1.10.3",
|
||||
"mdast-util-from-markdown": "^2.0.1",
|
||||
"mdast-util-gfm": "^3.0.0",
|
||||
"mdast-util-to-hast": "^13.2.0",
|
||||
"shiki": "1.10.3"
|
||||
"mdast-util-to-hast": "^13.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"shiki": "^1.10.3",
|
||||
"tsconfig": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"shiki": "1.x.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
"import": "./dist/layout.js",
|
||||
"types": "./dist/layout.d.ts"
|
||||
},
|
||||
"./home-layout": {
|
||||
"import": "./dist/home-layout.js",
|
||||
"types": "./dist/home-layout.d.ts"
|
||||
},
|
||||
"./page": {
|
||||
"import": "./dist/page.js",
|
||||
"types": "./dist/page.d.ts"
|
||||
@@ -66,6 +70,9 @@
|
||||
"layout": [
|
||||
"./dist/layout.d.ts"
|
||||
],
|
||||
"home-layout": [
|
||||
"./dist/home-layout.d.ts"
|
||||
],
|
||||
"page": [
|
||||
"./dist/page.d.ts"
|
||||
],
|
||||
@@ -103,20 +110,20 @@
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"cmdk": "^1.0.0",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"lucide-react": "^0.400.0",
|
||||
"lucide-react": "^0.408.0",
|
||||
"next-themes": "^0.3.0",
|
||||
"react-medium-image-zoom": "^5.2.5",
|
||||
"react-medium-image-zoom": "^5.2.7",
|
||||
"swr": "^2.2.5",
|
||||
"tailwind-merge": "^2.3.0"
|
||||
"tailwind-merge": "^2.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@algolia/client-search": "^4.24.0",
|
||||
"@next/eslint-plugin-next": "^14.2.4",
|
||||
"@next/eslint-plugin-next": "^14.2.5",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"algoliasearch": "^4.24.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"next": "^14.2.4",
|
||||
"next": "^14.2.5",
|
||||
"postcss": "^8.4.39",
|
||||
"postcss-cli": "^11.0.0",
|
||||
"postcss-lightningcss": "^1.0.0",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
'use client';
|
||||
import { type PointerEventHandler, useCallback, useRef, useState } from 'react';
|
||||
import { SidebarIcon } from 'lucide-react';
|
||||
import { Sidebar, type SidebarProps } from '@/components/layout/sidebar';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useSearchContext } from '@/contexts/search';
|
||||
import { SearchToggle } from '@/components/layout/search-toggle';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { buttonVariants } from '@/theme/variants';
|
||||
import type { SharedNavProps } from '@/layout';
|
||||
import type { SharedNavProps } from '@/layout.shared';
|
||||
import { NavBox, Title } from '@/components/layout/nav';
|
||||
|
||||
export function SubNav({
|
||||
@@ -46,6 +46,5 @@ export function SubNav({
|
||||
|
||||
export { LinksMenu } from '@/components/layout/link-item';
|
||||
export { Sidebar } from './components/layout/sidebar';
|
||||
export { DynamicSidebar } from './components/layout/dynamic-sidebar';
|
||||
export { TreeContextProvider } from './contexts/tree';
|
||||
export { ThemeToggle } from './components/layout/theme-toggle';
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { MoreVertical } from 'lucide-react';
|
||||
import type { SharedNavProps } from '@/layout';
|
||||
import { useSearchContext } from '@/contexts/search';
|
||||
import { useI18n } from '@/contexts/i18n';
|
||||
import {
|
||||
@@ -18,6 +17,7 @@ import { NavBox, Title } from '@/components/layout/nav';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { buttonVariants } from '@/theme/variants';
|
||||
import { isSecondary } from '@/utils/shared';
|
||||
import type { SharedNavProps } from '@/layout.shared';
|
||||
|
||||
export function Nav({
|
||||
title,
|
||||
@@ -0,0 +1,28 @@
|
||||
import { replaceOrDefault } from '@/utils/shared';
|
||||
import type { BaseLayoutProps } from '@/layout';
|
||||
import { getLinks } from '@/layout.shared';
|
||||
|
||||
declare const { Nav }: typeof import('./home-layout.client');
|
||||
|
||||
export type HomeLayoutProps = BaseLayoutProps;
|
||||
|
||||
export function HomeLayout({
|
||||
nav = {},
|
||||
links = [],
|
||||
githubUrl,
|
||||
children,
|
||||
}: BaseLayoutProps): React.ReactElement {
|
||||
const finalLinks = getLinks(links, githubUrl);
|
||||
|
||||
return (
|
||||
<>
|
||||
{replaceOrDefault(
|
||||
nav,
|
||||
<Nav items={finalLinks} {...nav}>
|
||||
{nav.children}
|
||||
</Nav>,
|
||||
)}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { LinkItemType } from '@/components/layout/link-item';
|
||||
import type { NavBoxProps, TitleProps } from '@/components/layout/nav';
|
||||
|
||||
interface NavOptions extends SharedNavProps {
|
||||
enabled: boolean;
|
||||
component: ReactNode;
|
||||
}
|
||||
|
||||
export interface SharedNavProps extends TitleProps, NavBoxProps {
|
||||
/**
|
||||
* Show/hide search toggle
|
||||
*
|
||||
* Note: Enable/disable search from root provider instead
|
||||
*/
|
||||
enableSearch?: boolean;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
export interface BaseLayoutProps {
|
||||
/**
|
||||
* GitHub url
|
||||
*/
|
||||
githubUrl?: string;
|
||||
|
||||
links?: LinkItemType[];
|
||||
/**
|
||||
* Replace or disable navbar
|
||||
*/
|
||||
nav?: Partial<NavOptions>;
|
||||
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
export function getLinks(
|
||||
links?: LinkItemType[],
|
||||
githubUrl?: string,
|
||||
): LinkItemType[] {
|
||||
let result = links ?? [];
|
||||
|
||||
if (githubUrl)
|
||||
result = [
|
||||
...result,
|
||||
{
|
||||
type: 'secondary',
|
||||
url: githubUrl,
|
||||
text: 'Github',
|
||||
icon: (
|
||||
<svg role="img" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
|
||||
</svg>
|
||||
),
|
||||
external: true,
|
||||
},
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
+26
-58
@@ -2,44 +2,45 @@ import type { PageTree } from 'fumadocs-core/server';
|
||||
import type { ReactNode, HTMLAttributes } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { MoreHorizontal } from 'lucide-react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { buttonVariants } from '@/theme/variants';
|
||||
import type { NavBoxProps, TitleProps } from './components/layout/nav';
|
||||
import type { SidebarProps } from '@/components/layout/sidebar';
|
||||
import { replaceOrDefault } from './utils/shared';
|
||||
import type { SidebarProps } from './components/layout/sidebar';
|
||||
import type { LinkItemType } from './components/layout/link-item';
|
||||
import { type BaseLayoutProps, getLinks } from './layout.shared';
|
||||
|
||||
declare const { Nav }: typeof import('./layout.client');
|
||||
declare const { Nav }: typeof import('./home-layout.client');
|
||||
|
||||
declare const {
|
||||
TreeContextProvider,
|
||||
DynamicSidebar,
|
||||
SubNav,
|
||||
LinksMenu,
|
||||
Sidebar,
|
||||
ThemeToggle,
|
||||
}: typeof import('./docs.client');
|
||||
}: typeof import('./docs-layout.client');
|
||||
|
||||
declare const {
|
||||
LanguageToggle,
|
||||
}: typeof import('./components/layout/language-toggle');
|
||||
// We can use dynamic imports to avoid loading a client component when they are not used
|
||||
const LanguageToggle = dynamic(() =>
|
||||
import('./components/layout/language-toggle').then(
|
||||
(mod) => mod.LanguageToggle,
|
||||
),
|
||||
);
|
||||
|
||||
export type { LinkItemType };
|
||||
const DynamicSidebar = dynamic(() =>
|
||||
import('./components/layout/dynamic-sidebar').then(
|
||||
(mod) => mod.DynamicSidebar,
|
||||
),
|
||||
);
|
||||
|
||||
interface NavOptions extends SharedNavProps {
|
||||
enabled: boolean;
|
||||
component: ReactNode;
|
||||
}
|
||||
|
||||
export interface SharedNavProps extends TitleProps, NavBoxProps {
|
||||
export type {
|
||||
LinkItemType,
|
||||
// TODO: Remove this (next major)
|
||||
/**
|
||||
* Show/hide search toggle
|
||||
*
|
||||
* Note: Enable/disable search from root provider instead
|
||||
* @deprecated Import `HomeLayoutProps` from `fumadocs-ui/home-layout` instead
|
||||
*/
|
||||
enableSearch?: boolean;
|
||||
children?: ReactNode;
|
||||
}
|
||||
BaseLayoutProps,
|
||||
};
|
||||
|
||||
interface SidebarOptions extends Omit<SidebarProps, 'items'> {
|
||||
enabled: boolean;
|
||||
@@ -47,21 +48,6 @@ interface SidebarOptions extends Omit<SidebarProps, 'items'> {
|
||||
collapsible: boolean;
|
||||
}
|
||||
|
||||
export interface BaseLayoutProps {
|
||||
/**
|
||||
* GitHub url
|
||||
*/
|
||||
githubUrl?: string;
|
||||
|
||||
links?: LinkItemType[];
|
||||
/**
|
||||
* Replace or disable navbar
|
||||
*/
|
||||
nav?: Partial<NavOptions>;
|
||||
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
export interface DocsLayoutProps extends BaseLayoutProps {
|
||||
tree: PageTree.Root;
|
||||
|
||||
@@ -77,6 +63,10 @@ export interface DocsLayoutProps extends BaseLayoutProps {
|
||||
i18n?: boolean;
|
||||
}
|
||||
|
||||
// TODO: Remove this (next major)
|
||||
/**
|
||||
* @deprecated Use `HomeLayout` from `fumadocs-ui/home-layout` instead
|
||||
*/
|
||||
export function Layout({
|
||||
nav = {},
|
||||
links = [],
|
||||
@@ -176,25 +166,3 @@ export function DocsLayout({
|
||||
</TreeContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function getLinks(links?: LinkItemType[], githubUrl?: string): LinkItemType[] {
|
||||
let result = links ?? [];
|
||||
|
||||
if (githubUrl)
|
||||
result = [
|
||||
...result,
|
||||
{
|
||||
type: 'secondary',
|
||||
url: githubUrl,
|
||||
text: 'Github',
|
||||
icon: (
|
||||
<svg role="img" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
|
||||
</svg>
|
||||
),
|
||||
external: true,
|
||||
},
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,12 @@ const exportedComponents = [
|
||||
'layout/language-toggle',
|
||||
];
|
||||
|
||||
const injectImports = ['./src/page.tsx', './src/mdx.tsx', './src/layout.tsx'];
|
||||
const injectImports = [
|
||||
'./src/page.tsx',
|
||||
'./src/mdx.tsx',
|
||||
'./src/layout.tsx',
|
||||
'./src/home-layout.tsx',
|
||||
];
|
||||
|
||||
function getOutPath(src: string): string {
|
||||
const replacedPath = src
|
||||
@@ -61,7 +66,7 @@ export default defineConfig([
|
||||
{
|
||||
entry: [
|
||||
`./src/components/{${exportedComponents.join(',')}}.tsx`,
|
||||
'./src/{i18n,layout,page,provider,mdx,tailwind-plugin}.{ts,tsx}',
|
||||
'./src/{i18n,home-layout,layout,page,provider,mdx,tailwind-plugin}.{ts,tsx}',
|
||||
'./src/twoslash/popup.tsx',
|
||||
'./src/*.client.tsx',
|
||||
],
|
||||
@@ -73,7 +78,7 @@ export default defineConfig([
|
||||
},
|
||||
format: 'esm',
|
||||
dts: true,
|
||||
target: 'es2022',
|
||||
target: 'esnext',
|
||||
},
|
||||
{
|
||||
// todo: Remove support for CommonJS in next major
|
||||
|
||||
Generated
+473
-556
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user