Skip to content

Commit 1cd1003

Browse files
committed
chore: update TocItem
1 parent c220c36 commit 1cd1003

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

packages/theme-default/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
],
3333
"scripts": {
3434
"build": "rslib build",
35-
"dev": "rslib build -w",
35+
"dev": "IS_DEV=1 rslib build -w",
3636
"reset": "rimraf ./**/node_modules"
3737
},
3838
"dependencies": {

packages/theme-default/rslib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default defineConfig({
5555
},
5656
},
5757
output: {
58+
cleanDistPath: process.env.IS_DEV === '1',
5859
target: 'web',
5960
externals: COMMON_EXTERNALS,
6061
cssModules: {

packages/theme-default/src/components/Aside/TocItem.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
.rp-aside__toc-item {
2-
display: flex;
3-
line-height: 24px;
2+
display: block;
43
justify-content: flex-start;
54
align-items: flex-start;
65
gap: 10px;
76
align-self: stretch;
87
border-radius: 6px;
98
position: relative;
109
color: var(--rp-c-text-2);
10+
1111
font-weight: 400;
1212
font-size: 14px;
13+
line-height: 24px;
14+
15+
&__text {
16+
overflow-wrap: break-word;
17+
}
1318

1419
&--active {
1520
color: var(--rp-c-link);

packages/theme-default/src/components/Aside/TocItem.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@ export const TocItem = ({
1717
active: boolean;
1818
}) => {
1919
return (
20-
<li>
21-
<Link
22-
href={`#${header.id}`}
23-
title={parseInlineMarkdownText(header.text)}
24-
className={clsx('rp-aside__toc-item', {
25-
'rp-aside__toc-item--active': active,
26-
})}
27-
style={{
28-
paddingLeft: (header.depth - baseHeaderLevel) * 12,
29-
}}
30-
>
31-
<span
32-
className="rp-aside__toc-text"
33-
{...renderInlineMarkdown(header.text)}
34-
></span>
35-
</Link>
36-
</li>
20+
<Link
21+
href={`#${header.id}`}
22+
title={parseInlineMarkdownText(header.text)}
23+
className={clsx('rp-aside__toc-item', {
24+
'rp-aside__toc-item--active': active,
25+
})}
26+
style={{
27+
paddingLeft: (header.depth - baseHeaderLevel) * 12,
28+
}}
29+
>
30+
<span
31+
className="rp-aside__toc-item__text"
32+
{...renderInlineMarkdown(header.text)}
33+
></span>
34+
</Link>
3735
);
3836
};

packages/theme-default/src/components/Aside/index.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,15 @@ export function Aside() {
6060
{outlineTitle}
6161
<ProgressCircle percent={readPercent} size={14} strokeWidth={2} />
6262
</div>
63-
<nav>
64-
<ul className="rp-aside__toc">
65-
{headers.map((header, index) => (
66-
<TocItem
67-
key={`${header.depth}_${header.text}_${header.id}_${index}`}
68-
baseHeaderLevel={baseHeaderLevel}
69-
header={header}
70-
active={activeAnchorId === header.id}
71-
/>
72-
))}
73-
</ul>
63+
<nav className="rp-aside__toc">
64+
{headers.map((header, index) => (
65+
<TocItem
66+
key={`${header.depth}_${header.text}_${header.id}_${index}`}
67+
baseHeaderLevel={baseHeaderLevel}
68+
header={header}
69+
active={activeAnchorId === header.id}
70+
/>
71+
))}
7472
</nav>
7573

7674
<div style={{ display: readPercent !== 0 ? '' : 'none' }}>

0 commit comments

Comments
 (0)