Skip to content

Commit cb3dbec

Browse files
committed
Add prefix
1 parent 0e10444 commit cb3dbec

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

apps/landing/src/app/(detail)/docs/LeftMenu.tsx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
11
import { VStack } from '@devup-ui/react'
22

3-
import { URL_PREFIX } from '../../../constants'
43
import { MenuItem } from './MenuItem'
54

65
export function LeftMenu() {
76
return (
87
<VStack gap="6px">
9-
<MenuItem to={URL_PREFIX + '/docs/overview'}>Overview</MenuItem>
10-
<MenuItem to={URL_PREFIX + '/docs/installation'}>Installation</MenuItem>
11-
<MenuItem to={URL_PREFIX + '/docs/features'}>Features</MenuItem>
8+
<MenuItem to="/docs/overview">Overview</MenuItem>
9+
<MenuItem to="/docs/installation">Installation</MenuItem>
10+
<MenuItem to="/docs/features">Features</MenuItem>
1211
<MenuItem
1312
subMenu={[
1413
{
15-
to: URL_PREFIX + '/docs/api/box',
14+
to: '/docs/api/box',
1615
children: 'Box',
1716
},
1817
{
19-
to: URL_PREFIX + '/docs/api/button',
18+
to: '/docs/api/button',
2019
children: 'Button',
2120
},
2221
{
23-
to: URL_PREFIX + '/docs/api/input',
22+
to: '/docs/api/input',
2423
children: 'Input',
2524
},
2625
{
27-
to: URL_PREFIX + '/docs/api/text',
26+
to: '/docs/api/text',
2827
children: 'Text',
2928
},
3029
{
31-
to: URL_PREFIX + '/docs/api/image',
30+
to: '/docs/api/image',
3231
children: 'Image',
3332
},
3433
{
35-
to: URL_PREFIX + '/docs/api/flex',
34+
to: '/docs/api/flex',
3635
children: 'Flex',
3736
},
3837
{
39-
to: URL_PREFIX + '/docs/api/v-stack',
38+
to: '/docs/api/v-stack',
4039
children: 'VStack',
4140
},
4241
{
43-
to: URL_PREFIX + '/docs/api/center',
42+
to: '/docs/api/center',
4443
children: 'Center',
4544
},
4645
{
47-
to: URL_PREFIX + '/docs/api/grid',
46+
to: '/docs/api/grid',
4847
children: 'Grid',
4948
},
5049
{
51-
to: URL_PREFIX + '/docs/api/css',
50+
to: '/docs/api/css',
5251
children: 'css',
5352
},
5453
{
55-
to: URL_PREFIX + '/docs/api/style-props',
54+
to: '/docs/api/style-props',
5655
children: 'Style Props',
5756
},
5857
{
59-
to: URL_PREFIX + '/docs/api/selector',
58+
to: '/docs/api/selector',
6059
children: 'Selector',
6160
},
6261
{
63-
to: URL_PREFIX + '/docs/api/group-selector',
62+
to: '/docs/api/group-selector',
6463
children: 'Group Selector',
6564
},
6665
]}
@@ -70,23 +69,23 @@ export function LeftMenu() {
7069
<MenuItem
7170
subMenu={[
7271
{
73-
to: URL_PREFIX + '/docs/devup/devup-json',
72+
to: '/docs/devup/devup-json',
7473
children: 'What is devup?',
7574
},
7675
{
77-
to: URL_PREFIX + '/docs/devup/colors',
76+
to: '/docs/devup/colors',
7877
children: 'Colors',
7978
},
8079
{
81-
to: URL_PREFIX + '/docs/devup/typography',
80+
to: '/docs/devup/typography',
8281
children: 'Typography',
8382
},
8483
{
85-
to: URL_PREFIX + '/docs/devup/breakpoints',
84+
to: '/docs/devup/breakpoints',
8685
children: 'Breakpoints',
8786
},
8887
{
89-
to: URL_PREFIX + '/docs/devup/figma-plugin',
88+
to: '/docs/devup/figma-plugin',
9089
children: 'Figma Plugin',
9190
},
9291
]}

apps/landing/src/app/(detail)/docs/MenuItem.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Box, css, Flex, Text } from '@devup-ui/react'
33
import Link from 'next/link'
44
import { usePathname } from 'next/navigation'
55

6+
import { URL_PREFIX } from '../../../constants'
67
import { OpenMenuItem } from './OpenMenuItem'
78

89
export interface MenuItemProps {
@@ -18,8 +19,12 @@ export function MenuItem(props: MenuItemProps) {
1819
const { children, to, subMenu } = props
1920
const path = usePathname()
2021
const selected = to
21-
? path.startsWith(to)
22-
: !!subMenu?.some((item) => (item.to ? path.startsWith(item.to) : false))
22+
? path.startsWith(to) || path.startsWith(URL_PREFIX + to)
23+
: !!subMenu?.some((item) =>
24+
item.to
25+
? path.startsWith(URL_PREFIX + item.to) || path.startsWith(item.to)
26+
: false,
27+
)
2328

2429
if (subMenu) return <OpenMenuItem {...props} subMenu={subMenu} />
2530
const inner = (

apps/landing/src/app/(detail)/docs/OpenMenuItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export function OpenMenuItem({
1414
Required<Pick<MenuItemProps, 'subMenu'>>) {
1515
const path = usePathname()
1616
const selected = subMenu.some((item) =>
17-
item.to ? path.startsWith(item.to) : false,
17+
item.to
18+
? path.startsWith(URL_PREFIX + item.to) || path.startsWith(item.to)
19+
: false,
1820
)
1921
const [open, handleOpen] = useReducer((state) => !state, selected)
2022
return (

0 commit comments

Comments
 (0)