File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 7
7
<a v-if =" item.author.url" :href =" item.author.url" >{{ item.author.name }}</a >
8
8
<template v-else >{{ item.author.name }}</template >
9
9
</span >
10
+ <a v-if =" githubBadgeUrl" :href =" item.url" class =" github-badge" >
11
+ <img :src =" githubBadgeUrl" >
12
+ </a >
10
13
</h1 >
11
14
<div class =" thin" v-if =" item.description" v-html =" item.description" ></div >
12
15
<footer class =" thin" v-if =" item.tags" >
@@ -24,7 +27,18 @@ import { filterByTag } from '../mixins'
24
27
25
28
export default {
26
29
props: [' item' ],
27
- mixins: [filterByTag]
30
+ mixins: [filterByTag],
31
+ computed: {
32
+ githubBadgeUrl () {
33
+ const re = / https? :\/\/ github\. com\/ ([A-Za-z0-9 -_] * )\/ ([A-Za-z0-9 -_] * )\/ ? $ / i
34
+ const matches = re .exec (this .item .url )
35
+ if (! matches) {
36
+ return null
37
+ }
38
+
39
+ return ` https://img.shields.io/github/stars/${ matches[1 ]} /${ matches[2 ]} .svg?style=social&label=★`
40
+ }
41
+ }
28
42
}
29
43
</script >
30
44
@@ -45,6 +59,13 @@ article {
45
59
& :only-child {
46
60
margin-bottom : 0 ;
47
61
}
62
+
63
+ .github-badge {
64
+ padding-top : .3rem ;
65
+ display : inline-block ;
66
+ vertical-align : middle ;
67
+ margin-left : 6px ;
68
+ }
48
69
}
49
70
50
71
footer {
You can’t perform that action at this time.
0 commit comments