diff --git a/.dumirc.ts b/.dumirc.ts
index 4e57597d..e370ca83 100644
--- a/.dumirc.ts
+++ b/.dumirc.ts
@@ -2,84 +2,67 @@ import { defineConfig } from 'dumi';
import { homepage, name } from './package.json';
-const isProd = process.env.NODE_ENV === 'production';
+const isProduction = process.env.NODE_ENV === 'production';
const isWin = process.platform === 'win32';
const themeConfig = {
- title: 'Lobe UI',
- name: 'UI',
- description: 'Lobe UI is an open-source UI component library for building chatbot web apps',
- footer: 'Made with 🤯 by LobeHub',
- socialLinks: {
- github: homepage,
- },
- apiHeader: {
- // 组件库包名,可以从 package.json 中引入名称
- pkg: name,
- // 匹配路由,默认为 /api 或 /components
- match: ['/components'],
- // github 会匹配 themeConfig.github 字段
- sourceUrl: `{github}/tree/master/src/{atomId}/index.tsx`,
- docUrl: `{github}/tree/master/src/{atomId}/index.md`,
- },
actions: [
{
- text: 'Github',
icon: 'Github',
link: homepage,
openExternal: true,
+ text: 'Github',
},
{
- text: 'Get Started',
link: '/components/action-icon',
+ text: 'Get Started',
type: 'primary',
},
],
+ apiHeader: {
+ docUrl: `{github}/tree/master/src/{atomId}/index.md`,
+
+ // 匹配路由,默认为 /api 或 /components
+ match: ['/components'],
+
+ // 组件库包名,可以从 package.json 中引入名称
+ pkg: name,
+ // github 会匹配 themeConfig.github 字段
+ sourceUrl: `{github}/tree/master/src/{atomId}/index.tsx`,
+ },
+ description: 'Lobe UI is an open-source UI component library for building chatbot web apps',
+
features: [
{
- icon: 'Palette',
- title: 'Themeable',
description:
'Provides a simple way to customize default themes, you can change the colors, fonts, breakpoints and everything you need.',
+ icon: 'Palette',
+ title: 'Themeable',
},
{
- icon: 'Zap',
- title: 'Fast',
description:
'voids unnecessary styles props at runtime, making it more performant than other UI libraries.',
+ icon: 'Zap',
+ title: 'Fast',
},
{
- icon: 'MoonStar',
- title: 'Light & Dark UI',
description:
'Automatic dark mode recognition, NextUI automatically changes the theme when detects HTML theme prop changes.',
+ icon: 'MoonStar',
+ title: 'Light & Dark UI',
},
],
+ footer: 'Made with 🤯 by LobeHub',
+ name: 'UI',
+ socialLinks: {
+ github: homepage,
+ },
+ title: 'Lobe UI',
};
export default defineConfig({
- themeConfig,
- locales: [{ id: 'en-US', name: 'English' }],
- title: 'Lobe UI',
- favicons: ['https://raw.githubusercontent.com/lobehub/favicon/main/dist/favicon.ico'],
- npmClient: 'pnpm',
+ apiParser: isProduction ? {} : false,
base: '/',
- publicPath: '/',
- ssr: isProd ? {} : false,
- apiParser: !isProd ? false : {},
- resolve: !isProd
- ? undefined
- : {
- entryFile: './src/index.ts',
- },
- define: {
- 'process.env': process.env,
- },
- mfsu: isWin
- ? undefined
- : {
- exclude: ['@dqbd/tiktoken'],
- },
chainWebpack(config: any) {
config.set('experiments', {
...config.get('experiments'),
@@ -99,15 +82,36 @@ export default defineConfig({
.type('webassembly/async')
.end();
},
+ define: {
+ 'process.env': process.env,
+ },
extraBabelPlugins: [
[
'babel-plugin-styled-components',
{
- minify: true,
- transpileTemplateLiterals: true,
displayName: process.env.NODE_ENV === 'development',
+ minify: true,
pure: true,
+ transpileTemplateLiterals: true,
},
],
],
+ favicons: ['https://raw.githubusercontent.com/lobehub/favicon/main/dist/favicon.ico'],
+ locales: [{ id: 'en-US', name: 'English' }],
+ mfsu: isWin
+ ? undefined
+ : {
+ exclude: ['@dqbd/tiktoken'],
+ },
+ npmClient: 'pnpm',
+ publicPath: '/',
+ resolve: isProduction
+ ? {
+ entryFile: './src/index.ts',
+ }
+ : undefined,
+
+ ssr: isProduction ? {} : false,
+ themeConfig,
+ title: 'Lobe UI',
});
diff --git a/packages/dumi-theme-lobehub/src/components/Burger/index.tsx b/packages/dumi-theme-lobehub/src/components/Burger/index.tsx
deleted file mode 100644
index fce373e2..00000000
--- a/packages/dumi-theme-lobehub/src/components/Burger/index.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { Drawer, Menu } from 'antd';
-import { Link } from 'dumi';
-import isEqual from 'fast-deep-equal';
-import { uniq } from 'lodash-es';
-import { memo, useState } from 'react';
-import { Center } from 'react-layout-kit';
-
-import { activePathSel, useSiteStore } from '@/store';
-
-import { useStyles } from './style';
-
-const Burger = memo(() => {
- const [opened, setOpened] = useState(false);
- const { styles, cx } = useStyles();
-
- const nav = useSiteStore((s) => s.navData, isEqual);
- const sidebar = useSiteStore((s) => s.sidebar, isEqual);
- const activePath = useSiteStore(activePathSel);
- const pathname = useSiteStore((s) => s.location.pathname);
-
- return (
-
{
- setOpened(!opened);
- }}
- >
-
-
-
-
-
- );
-});
-
-export default Burger;
diff --git a/packages/dumi-theme-lobehub/src/components/Burger/style.ts b/packages/dumi-theme-lobehub/src/components/Burger/style.ts
deleted file mode 100644
index 61de5a21..00000000
--- a/packages/dumi-theme-lobehub/src/components/Burger/style.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import { createStyles } from 'antd-style';
-import { rgba } from 'polished';
-
-export const useStyles = createStyles(({ token, prefixCls, cx, css, stylish }) => {
- const offset = 6;
-
- return {
- active: css`
- &::before,
- &::after {
- background: ${token.colorText};
- }
-
- & {
- background: transparent;
- }
-
- &::before {
- top: 0;
- transform: rotate(-135deg);
- }
-
- &::after {
- top: 0;
- transform: rotate(135deg);
- }
- `,
- container: css`
- cursor: pointer;
- width: ${token.controlHeight}px;
- height: ${token.controlHeight}px;
- border-radius: ${token.borderRadius}px;
- `,
- drawer: css`
- &.${prefixCls}-drawer-content {
- background: transparent;
- }
-
- .${prefixCls}-drawer-body {
- display: flex;
- flex-direction: column;
- }
- `,
- drawerRoot: css`
- top: ${token.headerHeight + 1}px;
-
- :focus-visible {
- outline: none;
- }
-
- .${prefixCls}-drawer {
- &-mask {
- ${stylish.blur};
- background-color: ${rgba(token.colorBgLayout, 0.5)};
- }
-
- &-content-wrapper {
- box-shadow: none;
- }
- }
- `,
-
- fillRect: css`
- flex: 1;
- width: 100%;
- border-top: 1px solid ${token.colorBorderSecondary};
- `,
- icon: cx(
- 'site-burger-icon',
- css`
- position: relative;
-
- &::before,
- &::after {
- content: '';
- position: absolute;
- left: 0;
- }
-
- &::before {
- top: ${offset}px;
- }
-
- &::after {
- top: -${offset}px;
- }
-
- &,
- &::before,
- &::after {
- display: inline-block;
-
- width: 16px;
- height: 2px;
-
- background: ${token.colorTextSecondary};
-
- transition: all 150ms ease;
- }
- `,
- ),
-
- menu: css`
- background: transparent;
- border-inline-end: transparent !important;
-
- .${prefixCls}-menu-item-only-child:first-child {
- border-top: none;
- }
-
- > .${prefixCls}-menu-item-only-child,.${prefixCls}-menu-submenu-title {
- width: 100%;
- margin: 0 !important;
- border-top: 1px solid ${token.colorBorderSecondary};
- border-radius: 0;
-
- &:active {
- color: ${token.colorText};
- background-color: ${token.colorFill};
- }
- }
-
- .ant-menu-item-group-title {
- overflow: hidden;
-
- padding: 0;
-
- font-size: 12px;
- font-weight: 500;
- text-overflow: ellipsis;
- text-transform: uppercase;
- white-space: nowrap;
- }
-
- .ant-menu-item-selected {
- width: 100%;
- margin: 0;
-
- color: ${token.colorText};
-
- background: ${token.colorFillSecondary};
- border-radius: 0;
- }
-
- .ant-menu-item,
- a::before {
- width: 100% !important;
- margin: 0 !important;
- border-radius: 0 !important;
- }
- `,
- };
-});
diff --git a/packages/dumi-theme-lobehub/src/index.ts b/packages/dumi-theme-lobehub/src/index.ts
index 39c010e6..a7a31828 100644
--- a/packages/dumi-theme-lobehub/src/index.ts
+++ b/packages/dumi-theme-lobehub/src/index.ts
@@ -1,6 +1,4 @@
export { ApiHeader, type ApiTitleProps } from './components/ApiHeader';
export { defineThemeConfig } from './config';
-// 导出所有需要消费的 store
export { siteSelectors, type SiteStore, useSiteStore } from './store';
-// 导出所有需要消费的类型
export * from './types';
diff --git a/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts b/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts
index bff6dd6c..1efa8504 100644
--- a/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts
+++ b/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts
@@ -4,13 +4,11 @@ const GlobalStyle = createGlobalStyle`
#nprogress {
.bar {
- z-index: 9999;
background: ${({ theme }) => theme.colorText};
}
-
-
+
.peg {
- box-shadow: none;
+ display: none !important;
}
.spinner {
diff --git a/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx b/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx
index 0eeb7e76..6cc9b699 100644
--- a/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx
+++ b/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx
@@ -28,19 +28,29 @@ const DocumentLayout = memo(() => {
const theme = useTheme();
const { mobile, laptop } = useResponsive();
- const { fm, noToc, siteTitle, isHomePage, loading, isChanlogPage } = useSiteStore(
- (s) => ({
+ const { fm, noToc, siteTitle, page, loading } = useSiteStore((s) => {
+ const isChanlogPage = s.location.pathname === '/changelog';
+ const isHomePage = isHeroPageSel(s);
+ let page;
+
+ if (isHomePage) {
+ page = 'home';
+ } else if (isChanlogPage) {
+ page = 'changelog';
+ } else {
+ page = 'docs';
+ }
+
+ return {
fm: s.routeMeta.frontmatter,
- isChanlogPage: s.location.pathname === '/changelog',
- isHomePage: isHeroPageSel(s),
loading: s.siteData.loading,
noToc: tocAnchorItemSel(s).length === 0,
+ page: page,
siteTitle: siteTitleSel(s),
- }),
- shallow,
- );
+ };
+ }, shallow);
- const hideSidebar = isHomePage || isChanlogPage || mobile || fm.sidebar === false;
+ const hideSidebar = page !== 'docs' || mobile || fm.sidebar === false;
const shouldHideToc = fm.toc === false || noToc;
const hideToc = mobile ? shouldHideToc : !laptop || shouldHideToc;
@@ -53,7 +63,7 @@ const DocumentLayout = memo(() => {
{fm.description && }
{fm.keywords && }
{fm.keywords && }
- {!fm.title || isHomePage ? (
+ {!fm.title || page === 'home' ? (
{siteTitle}
) : (
@@ -62,7 +72,7 @@ const DocumentLayout = memo(() => {
)}
),
- [intl, fm, siteTitle, isHomePage],
+ [intl, fm, siteTitle, page === 'home'],
);
// handle hash change or visit page hash after async chunk loaded
@@ -83,28 +93,20 @@ const DocumentLayout = memo(() => {
document.body.scrollTo(0, 0);
}, [window.location.pathname]);
- let Page;
-
- if (isHomePage) {
- Page = Home;
- } else if (isChanlogPage) {
- Page = Changelog;
- } else {
- Page = Docs;
- }
-
return (
}
header={}
- headerHeight={mobile && !isHomePage ? theme.headerHeight + 36 : theme.headerHeight}
+ headerHeight={mobile && page !== 'home' ? theme.headerHeight + 36 : theme.headerHeight}
helmet={}
sidebar={hideSidebar ? undefined : }
toc={hideToc ? undefined : }
tocWidth={hideToc ? 0 : theme.tocWidth}
>
-
+ {page === 'home' && }
+ {page === 'changelog' && }
+ {page === 'docs' && }
);
});
diff --git a/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx b/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx
new file mode 100644
index 00000000..21844927
--- /dev/null
+++ b/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx
@@ -0,0 +1,54 @@
+import { Burger as Menu } from '@lobehub/ui';
+import { Link } from 'dumi';
+import isEqual from 'fast-deep-equal';
+import { uniq } from 'lodash-es';
+import { memo, useState } from 'react';
+
+import { activePathSel, useSiteStore } from '@/store';
+
+const Burger = memo(() => {
+ const [opened, setOpened] = useState(false);
+
+ const nav = useSiteStore((s) => s.navData, isEqual);
+ const sidebar = useSiteStore((s) => s.sidebar, isEqual);
+ const activePath = useSiteStore(activePathSel);
+ const pathname = useSiteStore((s) => s.location.pathname);
+
+ return (
+