Skip to content

Commit

Permalink
docs: add GlobalLayout to fit dumi docs theme config
Browse files Browse the repository at this point in the history
  • Loading branch information
BBSQQ committed Nov 21, 2024
1 parent 11fa40d commit 4bea65b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ConfigProvider, theme } from 'antd';
// @ts-ignore dumi 实际上导出了
import { useOutlet, usePrefersColor } from 'dumi';
import React from 'react';

const GlobalLayout: React.FC = () => {
const outlet = useOutlet();
const [color] = usePrefersColor();

return (
<ConfigProvider
theme={{
algorithm: color === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm,
}}
>
{outlet}
</ConfigProvider>
);
};

export default GlobalLayout;
4 changes: 4 additions & 0 deletions .dumi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["**/*"]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ jspm_packages/
# Build
dist
docs-dist
.dumi
.dumi/tmp
3 changes: 2 additions & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"./*.?*.ts",
"src",
// test workspace lint
"__tests__"
"__tests__",
".dumi/theme"
],
"exclude": ["node_modules", "dist"]
}

0 comments on commit 4bea65b

Please sign in to comment.