|
| 1 | +--- |
| 2 | +import InfoSection from "./InfoSection.astro"; |
| 3 | +import { Badge } from "@astrojs/starlight/components"; |
| 4 | +import { |
| 5 | + tryGetExtensionName, |
| 6 | + tagNames, |
| 7 | + ExtensionTag, |
| 8 | + DependencyType, |
| 9 | + type ExtensionManifest, |
| 10 | + type Dependency |
| 11 | +} from "./shared"; |
| 12 | +
|
| 13 | +interface Props { |
| 14 | + extensions: ExtensionManifest[]; |
| 15 | + ext: ExtensionManifest; |
| 16 | +} |
| 17 | +
|
| 18 | +const { extensions, ext } = Astro.props; |
| 19 | +
|
| 20 | +const authors = ext.meta?.authors; |
| 21 | +const tags = ext.meta?.tags; |
| 22 | +const version = ext.version; |
| 23 | +
|
| 24 | +const dependencies: Dependency[] = []; |
| 25 | +const incompatible: Dependency[] = []; |
| 26 | +
|
| 27 | +if (ext.dependencies != null) { |
| 28 | + dependencies.push( |
| 29 | + ...ext.dependencies.map((dep) => ({ |
| 30 | + id: dep, |
| 31 | + type: DependencyType.Dependency |
| 32 | + })) |
| 33 | + ); |
| 34 | +} |
| 35 | +
|
| 36 | +if (ext.suggested != null) { |
| 37 | + dependencies.push( |
| 38 | + ...ext.suggested.map((dep) => ({ |
| 39 | + id: dep, |
| 40 | + type: DependencyType.Optional |
| 41 | + })) |
| 42 | + ); |
| 43 | +} |
| 44 | +
|
| 45 | +if (ext.incompatible != null) { |
| 46 | + incompatible.push( |
| 47 | + ...ext.incompatible.map((dep) => ({ |
| 48 | + id: dep, |
| 49 | + type: DependencyType.Incompatible |
| 50 | + })) |
| 51 | + ); |
| 52 | +} |
| 53 | +--- |
| 54 | + |
| 55 | +<div class="extensionInfo"> |
| 56 | + { |
| 57 | + authors != null && ( |
| 58 | + <InfoSection title="Authors"> |
| 59 | + <span> |
| 60 | + {authors |
| 61 | + .map((author) => |
| 62 | + typeof author === "string" ? author : author.name |
| 63 | + ) |
| 64 | + .join(", ")} |
| 65 | + </span> |
| 66 | + </InfoSection> |
| 67 | + ) |
| 68 | + } |
| 69 | + |
| 70 | + { |
| 71 | + tags != null && ( |
| 72 | + <InfoSection title="Tags"> |
| 73 | + {tags.map((tag) => ( |
| 74 | + <Badge |
| 75 | + class="badge" |
| 76 | + text={tagNames[tag]} |
| 77 | + variant={tag === ExtensionTag.DangerZone ? "danger" : "note"} |
| 78 | + /> |
| 79 | + ))} |
| 80 | + </InfoSection> |
| 81 | + ) |
| 82 | + } |
| 83 | + |
| 84 | + { |
| 85 | + dependencies.length > 0 && ( |
| 86 | + <InfoSection title="Dependencies"> |
| 87 | + {dependencies.map((dep) => ( |
| 88 | + <Badge class="badge" text={tryGetExtensionName(extensions, dep.id)} /> |
| 89 | + ))} |
| 90 | + </InfoSection> |
| 91 | + ) |
| 92 | + } |
| 93 | + |
| 94 | + { |
| 95 | + incompatible.length > 0 && ( |
| 96 | + <InfoSection title="Incompatible"> |
| 97 | + {incompatible.map((dep) => ( |
| 98 | + <Badge class="badge" text={tryGetExtensionName(extensions, dep.id)} /> |
| 99 | + ))} |
| 100 | + </InfoSection> |
| 101 | + ) |
| 102 | + } |
| 103 | + |
| 104 | + { |
| 105 | + version != null && ( |
| 106 | + <InfoSection title="Version"> |
| 107 | + <span>{version}</span> |
| 108 | + </InfoSection> |
| 109 | + ) |
| 110 | + } |
| 111 | +</div> |
| 112 | + |
| 113 | +<style> |
| 114 | + .extensionInfo { |
| 115 | + display: flex; |
| 116 | + gap: 1rem; |
| 117 | + flex-wrap: wrap; |
| 118 | + } |
| 119 | + |
| 120 | + .badge { |
| 121 | + margin-right: 0.4em; |
| 122 | + } |
| 123 | +</style> |
0 commit comments