diff --git a/frontend/routes/package/dependencies.tsx b/frontend/routes/package/dependencies.tsx index e0b8219a..a8f7ea8d 100644 --- a/frontend/routes/package/dependencies.tsx +++ b/frontend/routes/package/dependencies.tsx @@ -28,15 +28,32 @@ export default define.page(function Deps( ) { const iam = scopeIAM(state, data.member); - const deps: Record }> = {}; + const deps: Record< + string, + { + link: string; + constraints: Set; + modules: Record; + defaultModule: boolean; + } + > = {}; for (const dep of data.deps) { const key = `${dep.kind}:${dep.name}`; deps[key] ??= { link: getDependencyLink(dep), constraints: new Set(), + modules: {}, + defaultModule: false, }; deps[key].constraints.add(dep.constraint); + if (dep.path) { + deps[key].modules[dep.path] = dep.kind === "jsr" + ? `/${dep.name}/doc/${dep.path}/~` + : undefined; + } else { + deps[key].defaultModule = true; + } } const list = Object.entries(deps); @@ -67,8 +84,9 @@ export default define.page(function Deps( : ( @@ -77,6 +95,8 @@ export default define.page(function Deps( name={name} link={info.link} constraints={[...info.constraints]} + modules={Object.entries(info.modules)} + defaultModule={info.defaultModule} /> ))}
@@ -87,10 +107,12 @@ export default define.page(function Deps( }); function Dependency( - { name, link, constraints }: { + { name, link, constraints, modules, defaultModule }: { name: string; link: string; constraints: string[]; + modules: [path: string, link?: string][]; + defaultModule: boolean; }, ) { return ( @@ -103,6 +125,28 @@ function Dependency( {constraints.map((constraint) => {constraint})} + + {modules.length > 0 && ( +
    + {defaultModule &&
  • (default)
  • } + {modules.map(([path, link]) => ( +
  • + {link + ? ( + + {path} + + ) + : ( + + {path} + + )} +
  • + ))} +
+ )} +
); }