File tree 4 files changed +26
-8
lines changed
4 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 49
49
margin-bottom : 10px ;
50
50
}
51
51
52
- .release-tag {
53
- font-size : 20 px ;
52
+ .docs-cn-github- release-tag {
53
+ font-size : 14 px ;
54
54
font-weight : bold;
55
- display : inline-block;
56
- position : absolute;
57
- top : 50% ;
58
- transform : translateY (-50% );
59
- padding : 6px ;
55
+ padding : 4px 6px ;
60
56
margin-left : 6px ;
61
57
background : var (--c-brand );
62
58
color : white;
Original file line number Diff line number Diff line change 1
1
import { h } from 'vue'
2
2
import Theme from 'vitepress/theme'
3
- import './styles/vars.css'
4
3
import HomeSponsors from './components/HomeSponsors.vue'
5
4
import AsideSponsors from './components/AsideSponsors.vue'
6
5
import SvgImage from './components/SvgImage.vue'
6
+ import './styles/vars.css'
7
+ import './custom.css'
7
8
8
9
export default {
9
10
...Theme ,
Original file line number Diff line number Diff line change
1
+ export function fetchReleaseTag ( ) {
2
+ return fetch ( 'https://api.github.com/repos/vitejs/docs-cn/releases/latest' )
3
+ . then ( ( res ) => res . json ( ) )
4
+ . then ( ( json ) => json . tag_name ?? '' )
5
+ . then ( releaseTag => {
6
+ const tagLineParagragh = document . querySelector ( 'div.VPHero.has-image.VPHomeHero > div > div.main > p.tagline' )
7
+ const docsReleaseTagSpan = document . createElement ( 'samp' )
8
+ docsReleaseTagSpan . classList . add ( 'docs-cn-github-release-tag' )
9
+ docsReleaseTagSpan . innerText = releaseTag
10
+ tagLineParagragh ?. appendChild ( docsReleaseTagSpan )
11
+ } )
12
+ }
Original file line number Diff line number Diff line change @@ -42,3 +42,12 @@ features:
42
42
title : 完全类型化的API
43
43
details : 灵活的 API 和完整的 TypeScript 类型。
44
44
---
45
+
46
+ <script setup >
47
+ import { onMounted } from ' vue'
48
+ import { fetchReleaseTag } from ' ./.vitepress/utils/fetchReleaseTag.js'
49
+
50
+ onMounted (() => {
51
+ fetchReleaseTag ()
52
+ })
53
+ </script >
You can’t perform that action at this time.
0 commit comments