File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 16
16
display : none;
17
17
}
18
18
19
-
20
19
: root {
21
20
--c-brand : # 646cff ;
22
21
--c-brand-light : # 747bff ;
38
37
display : block;
39
38
margin-bottom : 10px ;
40
39
}
40
+
41
+ .release-tag {
42
+ font-size : 20px ;
43
+ font-weight : bold;
44
+ font-family : monospace;
45
+ display : inline-block;
46
+ position : absolute;
47
+ top : 50% ;
48
+ transform : translateY (-50% );
49
+ padding : 6px ;
50
+ margin-left : 6px ;
51
+ background : var (--c-brand );
52
+ color : white;
53
+ border-radius : 10px ;
54
+ }
Original file line number Diff line number Diff line change
1
+ import { onMounted } from 'vue'
2
+
3
+ export default function fetchReleaseTag ( ) {
4
+ onMounted ( ( ) => {
5
+ fetch ( 'https://api.github.com/repos/vitejs/docs-cn/releases/latest' )
6
+ . then ( ( res ) => res . json ( ) )
7
+ . then ( ( json ) => {
8
+ const mainTitle = document . getElementById ( 'main-title' )
9
+ mainTitle . style . position = 'relative'
10
+
11
+ const docsReleaseTag = document . createElement ( 'span' )
12
+ docsReleaseTag . classList . add ( 'release-tag' )
13
+ const releaseTagName = json . tag_name
14
+ docsReleaseTag . innerText = releaseTagName
15
+
16
+
17
+ mainTitle . appendChild ( docsReleaseTag )
18
+ } )
19
+ } )
20
+ }
Original file line number Diff line number Diff line change @@ -34,4 +34,7 @@ footer: MIT Licensed | Copyright © 2019-present Evan You & Vite Contributors
34
34
35
35
<script setup >
36
36
import sponsors from ' ./.vitepress/theme/sponsors.json'
37
+ import fetchReleaseTag from ' ./.vitepress/theme/fetchReleaseTag.js'
38
+
39
+ fetchReleaseTag ()
37
40
</script >
You can’t perform that action at this time.
0 commit comments