|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { useTimeoutFn } from '@vueuse/core' |
3 | 3 |
|
4 | | -interface PluginSource { |
| 4 | +interface PluginSourceGitHub { |
5 | 5 | source: 'github' |
6 | 6 | repo: string |
7 | 7 | } |
8 | 8 |
|
| 9 | +interface PluginSourceGitSubdir { |
| 10 | + source: 'git-subdir' |
| 11 | + url: string |
| 12 | + path: string |
| 13 | + ref?: string |
| 14 | + sha?: string |
| 15 | +} |
| 16 | +
|
| 17 | +type PluginSource = PluginSourceGitHub | PluginSourceGitSubdir |
| 18 | +
|
9 | 19 | interface Plugin { |
10 | 20 | name: string |
11 | 21 | description: string |
@@ -50,6 +60,11 @@ async function fetchPluginMetadata() { |
50 | 60 | return |
51 | 61 | } |
52 | 62 |
|
| 63 | + // Only GitHub source plugins support metadata fetch |
| 64 | + if (props.plugin.source.source !== 'github') { |
| 65 | + return |
| 66 | + } |
| 67 | +
|
53 | 68 | // GitHub plugin - fetch from GitHub |
54 | 69 | loading.value = true |
55 | 70 | try { |
@@ -92,7 +107,7 @@ async function fetchPluginMetadata() { |
92 | 107 | // Network-level errors (connection failed, CORS, etc.) |
93 | 108 | console.error('Network error fetching plugin metadata:', { |
94 | 109 | plugin: props.plugin.name, |
95 | | - repo: props.plugin.source.repo, |
| 110 | + repo: props.plugin.source.source === 'github' ? props.plugin.source.repo : props.plugin.source.url, |
96 | 111 | error: err instanceof Error ? err.message : String(err), |
97 | 112 | }) |
98 | 113 | } |
@@ -169,6 +184,17 @@ const githubSourceUrl = computed(() => { |
169 | 184 |
|
170 | 185 | return url |
171 | 186 | } |
| 187 | + // git-subdir plugin |
| 188 | + if (props.plugin.source.source === 'git-subdir') { |
| 189 | + const url = props.plugin.source.url |
| 190 | + const path = props.plugin.source.path |
| 191 | + const ref = props.plugin.source.ref || 'main' |
| 192 | + // Handle both full URLs and owner/repo shorthand |
| 193 | + if (url.startsWith('http')) { |
| 194 | + return `${url.replace(/\.git$/, '')}/tree/${ref}/${path}` |
| 195 | + } |
| 196 | + return `https://github.com/${url}/tree/${ref}/${path}` |
| 197 | + } |
172 | 198 | // GitHub plugin |
173 | 199 | return `https://github.com/${props.plugin.source.repo}` |
174 | 200 | }) |
@@ -306,7 +332,7 @@ watch(() => props.autoOpenModal, (shouldOpen) => { |
306 | 332 | </div> |
307 | 333 | <div class="flex items-center gap-2 text-xs text-muted"> |
308 | 334 | <UIcon name="i-heroicons-code-bracket" class="shrink-0" /> |
309 | | - <span class="truncate">{{ typeof plugin.source === 'string' ? plugin.source : plugin.source.repo }}</span> |
| 335 | + <span class="truncate">{{ typeof plugin.source === 'string' ? plugin.source : plugin.source.source === 'github' ? plugin.source.repo : plugin.source.url }}</span> |
310 | 336 | </div> |
311 | 337 | </div> |
312 | 338 | <div class="shrink-0"> |
|
0 commit comments