forked from Mirrors/elk
fix: support /stars/user in GitHub cards
This commit is contained in:
parent
f8703fc1c1
commit
d353f38ac9
1 changed files with 8 additions and 4 deletions
|
@ -20,6 +20,8 @@ interface Meta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const specialRoutes = ['orgs', 'sponsors', 'stars']
|
||||||
|
|
||||||
const meta = $computed(() => {
|
const meta = $computed(() => {
|
||||||
const { url } = props.card
|
const { url } = props.card
|
||||||
const path = url.split('https://github.com/')[1]
|
const path = url.split('https://github.com/')[1]
|
||||||
|
@ -27,13 +29,15 @@ const meta = $computed(() => {
|
||||||
// Supported paths
|
// Supported paths
|
||||||
// /user
|
// /user
|
||||||
// /user/repo
|
// /user/repo
|
||||||
// /user/repo/issues/number.*
|
// /user/repo/issues/number
|
||||||
// /user/repo/pull/number.*
|
// /user/repo/pull/number
|
||||||
// /orgs/user.*
|
// /orgs/user
|
||||||
|
// /sponsors/user
|
||||||
|
// /stars/user
|
||||||
|
|
||||||
const firstName = path.match(/([\w-]+)(\/|$)/)?.[1]
|
const firstName = path.match(/([\w-]+)(\/|$)/)?.[1]
|
||||||
const secondName = path.match(/[\w-]+\/([\w-]+)/)?.[1]
|
const secondName = path.match(/[\w-]+\/([\w-]+)/)?.[1]
|
||||||
const firstIsUser = firstName !== 'orgs' && firstName !== 'sponsors'
|
const firstIsUser = firstName && !specialRoutes.includes(firstName)
|
||||||
const user = firstIsUser ? firstName : secondName
|
const user = firstIsUser ? firstName : secondName
|
||||||
const repo = firstIsUser ? secondName : undefined
|
const repo = firstIsUser ? secondName : undefined
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue