Skip to content

Commit 25b6e2d

Browse files
committed
fix: code highlight
1 parent b53e753 commit 25b6e2d

File tree

6 files changed

+37
-43
lines changed

6 files changed

+37
-43
lines changed
Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Container, Stack, Toolbar } from "@mui/material";
1+
import { Box, Container, Drawer, Stack, Toolbar } from "@mui/material";
22
import fs from "fs";
33
import { SidebarMenu, SidebarMenuItem } from "@/components/SidebarMenu";
44
import path from "path";
@@ -18,7 +18,6 @@ export default async function DocsLayout({
1818
children: React.ReactNode;
1919
params: Promise<MarkdownPageParams>;
2020
}>) {
21-
2221
const { locale, version, category } = await params;
2322
setStaticParamsLocale(locale);
2423

@@ -35,45 +34,35 @@ export default async function DocsLayout({
3534

3635
const versions = fs.readdirSync(path.join(DOCS_DIR, locale));
3736

37+
const width = 280;
38+
3839
return (
3940
<>
40-
{menu.length ? (
41-
<Stack
42-
component="aside"
43-
sx={{
44-
width: "300px",
45-
position: "fixed",
46-
left: 0,
47-
top: 0,
48-
bottom: 0,
49-
}}
50-
>
51-
<Toolbar />
52-
53-
<VersionList version={version} versions={versions} />
54-
<Box
55-
flex={1}
56-
sx={{
57-
overflow: "auto",
58-
borderRight: 1,
59-
borderColor: "var(--css-palette-divider)",
60-
}}
61-
pb={1}
62-
pt={1}
63-
>
64-
<SidebarMenu data={menu} />
65-
</Box>
66-
</Stack>
67-
) : null}
68-
<Box sx={{ marginLeft: menu.length ? "300px" : 0 }}>
41+
<Stack direction="row">
42+
{menu.length ? (
43+
<Drawer open={true} variant="permanent" sx={{ width }} PaperProps={{ sx: { width, background: 'var(--css-palette-background-default)' } }}>
44+
<Toolbar />
45+
<VersionList version={version} versions={versions} />
46+
<Box
47+
flex={1}
48+
sx={{
49+
overflow: "auto",
50+
}}
51+
pb={1}
52+
pt={1}
53+
>
54+
<SidebarMenu data={menu} />
55+
</Box>
56+
</Drawer>
57+
) : null}
6958
<Container
70-
sx={{ minHeight: "var(--container-min-height)", paddingBlock: 3}}
59+
sx={{ minHeight: "var(--container-min-height)", paddingBlock: 3 }}
7160
className="markdown-body with-sidebar"
7261
>
7362
{children}
63+
<Footer border={false} />
7464
</Container>
75-
<Footer border={false} />
76-
</Box>
65+
</Stack>
7766
</>
7867
);
7968
}

src/app/[locale]/docs/[version]/[category]/version.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ export default function VersionList({ version, versions }: Props) {
3636
trigger={
3737
<Box
3838
sx={{
39-
border: 1,
40-
borderColor: "divider",
41-
borderLeftWidth: 0,
42-
borderTopWidth: 0,
39+
borderBottomWidth: 1,
40+
borderBottomStyle: 'solid',
41+
borderBottomColor: "divider",
4342
paddingBlock: 1,
4443
}}
4544
>

src/app/[locale]/global.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
}
44

55
/* code hightlight */
6-
.hljs, pre code {
6+
code {
7+
background: var(--css-palette-divider);
8+
padding: 2px 8px;
9+
border-radius: var(--css-shape-borderRadius);
10+
}
11+
12+
.hljs, pre > code {
713
border-radius: var(--css-shape-borderRadius);
814
background: #1A1E22;
915
color: #FFF;

src/components/CodeWithCopyButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function CodeWithCopyButton(
3030
}
3131
};
3232

33-
if(navigator.clipboard === undefined) {
33+
if(typeof window !== "undefined" && window.navigator.clipboard === undefined) {
3434
return <StyledCode {...props}>{props.children}</StyledCode>
3535
};
3636

src/components/ElevationScrollAppBar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { AppBar, AppBarProps } from "@mui/material";
3+
import { AppBar, AppBarProps, useTheme } from "@mui/material";
44
import useScrollTrigger from "@mui/material/useScrollTrigger";
55
import { usePathname } from "next/navigation";
66
import { useEffect } from "react";
@@ -11,6 +11,7 @@ export const ElevationScrollAppBar = (props: AppBarProps) => {
1111
disableHysteresis: true,
1212
threshold: 100,
1313
});
14+
const theme = useTheme();
1415

1516
useEffect(() => {
1617
window.scrollTo({
@@ -24,6 +25,7 @@ export const ElevationScrollAppBar = (props: AppBarProps) => {
2425
{...props}
2526
sx={{
2627
boxShadow: trigger ? `0 10px 10px rgba(0,0,0, 0.1)` : "none",
28+
zIndex: theme.zIndex.drawer + 1
2729
}}
2830
position="fixed"
2931
/>

src/components/SidebarMenu.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ export function SidebarMenuItem({ level = 1, item }: SidebatMenuItemProps) {
5757
},
5858
};
5959

60-
console.log(item)
61-
6260
useEffect(() => {
6361
const isOpen = checkOpen(pathname, item);
6462
if (isOpen) {

0 commit comments

Comments
 (0)