Skip to content

Commit

Permalink
Merge pull request #209 from xen0n/fix-asmdb-take2
Browse files Browse the repository at this point in the history
Fix asmdb routing (take 2)
  • Loading branch information
xen0n authored Oct 25, 2024
2 parents c618868 + 0a971dd commit e683b73
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@types/node": "^22.7.5",
"@types/prismjs": "^1.26.4",
"@types/react": "^18.3.11",
"@types/react-router-dom": "^5.3.3",
"typescript": "^5.6.3",
"update-browserslist-db": "^1.1.1"
},
Expand Down
40 changes: 24 additions & 16 deletions src/components/AsmDB/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Layout as AntdLayout, Menu } from 'antd'
import { Layout as AntdLayout, Menu, MenuProps } from 'antd'
import { Link, Route, Switch, useRouteMatch } from 'react-router-dom'
import { Redirect } from '@docusaurus/router'

Expand All @@ -11,7 +11,27 @@ import type { AsmDBData } from './types'
import VldiHelperPage from './vldiHelperPage'

export default function AsmDBPage({ data }: { data: AsmDBData }): JSX.Element {
let { path, url } = useRouteMatch()
const { path, url } = useRouteMatch()
const sideNavItems: MenuProps['items'] = [
{
key: "encodingSpaceOverview",
label: <Link to={`${url}/encodingSpaceOverview`}>编码空间总览</Link>,
},
{
key: "insnList",
disabled: true,
label: '指令列表(开发中)',
},
{
key: "insnExplainer",
disabled: true,
label: '解读指令字(开发中)',
},
{
key: "vldiHelper",
label: <Link to={`${url}/vldiHelper`}>VLDI 辅助</Link>,
},
]

return (
<Layout title={'LoongArch 汇编指令速查'}>
Expand All @@ -23,20 +43,8 @@ export default function AsmDBPage({ data }: { data: AsmDBData }): JSX.Element {
mode="inline"
defaultSelectedKeys={['encodingSpaceOverview']}
style={{ height: '100%' }}
>
<Menu.Item key="encodingSpaceOverview">
<Link to={`${url}/encodingSpaceOverview`}>编码空间总览</Link>
</Menu.Item>
<Menu.Item key="insnList" disabled>
指令列表(开发中)
</Menu.Item>
<Menu.Item key="insnExplainer" disabled>
解读指令字(开发中)
</Menu.Item>
<Menu.Item key="vldiHelper">
<Link to={`${url}/vldiHelper`}>VLDI 辅助</Link>
</Menu.Item>
</Menu>
items={sideNavItems}
/>
</AntdLayout.Sider>
<AntdLayout.Content style={{ padding: '1rem' }}>
<Switch>
Expand Down
4 changes: 2 additions & 2 deletions src/components/HomepageFeatures/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Project({val}: {val: IProject}) {

return (
<li>
<span>{statusesToShow.map((x) => (<SupportStatusIcon val={x} />))}</span>
<span>{statusesToShow.map((x, idx) => (<SupportStatusIcon key={idx} val={x} />))}</span>
<Link to={`/project/${val.code}`} className={styles.project__name}>{val.name}</Link>
{lowestGoodVersion != '' ? <span className={styles.project__goodSince}>{lowestGoodVersion}</span> : ''}
</li>
Expand All @@ -29,7 +29,7 @@ function ProjectList({projects}: {projects: IProject[]}) {
sortedProjects.sort((a, b) => a.name.toLowerCase() > b.name.toLowerCase())
return (
<ul className={styles.projects}>
{sortedProjects.map((x) => (<Project val={x} />))}
{sortedProjects.map((x, idx) => (<Project key={idx} val={x} />))}
</ul>
)
}
Expand Down
60 changes: 27 additions & 33 deletions src/plugins/awly-asmdb-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,39 +55,33 @@ export default async function awlyAsmdbPlugin(
modules: {
data: dataPath,
},
exact: true,
})
actions.addRoute({
path: `/asmdb/encodingSpaceOverview`,
component: '@site/src/components/AsmDB',
modules: {
data: dataPath,
},
exact: true,
})
actions.addRoute({
path: `/asmdb/insnList`,
component: '@site/src/components/AsmDB',
modules: {
data: dataPath,
},
exact: true,
})
actions.addRoute({
path: `/asmdb/insnExplainer`,
component: '@site/src/components/AsmDB',
modules: {
data: dataPath,
},
exact: true,
})
actions.addRoute({
path: `/asmdb/vldiHelper`,
component: '@site/src/components/AsmDB',
modules: {
data: dataPath,
},
exact: true,
routes: [
{
path: '/asmdb',
component: '@site/src/components/AsmDB',
exact: true,
},
{
path: '/asmdb/encodingSpaceOverview',
component: '@site/src/components/AsmDB',
exact: true,
},
{
path: '/asmdb/insnExplainer',
component: '@site/src/components/AsmDB',
exact: true,
},
{
path: '/asmdb/insnList',
component: '@site/src/components/AsmDB',
exact: true,
},
{
path: '/asmdb/vldiHelper',
component: '@site/src/components/AsmDB',
exact: true,
},
],
})
},
getPathsToWatch() {
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3425,7 +3425,7 @@ __metadata:
languageName: node
linkType: hard

"@types/react-router-dom@npm:*":
"@types/react-router-dom@npm:*, @types/react-router-dom@npm:^5.3.3":
version: 5.3.3
resolution: "@types/react-router-dom@npm:5.3.3"
dependencies:
Expand Down Expand Up @@ -4045,6 +4045,7 @@ __metadata:
"@types/node": "npm:^22.7.5"
"@types/prismjs": "npm:^1.26.4"
"@types/react": "npm:^18.3.11"
"@types/react-router-dom": "npm:^5.3.3"
antd: "npm:^5.21.3"
browserslist: "npm:^4.24.0"
clsx: "npm:^2.1.1"
Expand Down

0 comments on commit e683b73

Please sign in to comment.