File tree Expand file tree Collapse file tree 4 files changed +26
-8
lines changed Expand file tree Collapse file tree 4 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 4949 margin-bottom : 10px ;
5050}
5151
52- .release-tag {
53- font-size : 20 px ;
52+ .docs-cn-github- release-tag {
53+ font-size : 14 px ;
5454 font-weight : bold;
55- display : inline-block;
56- position : absolute;
57- top : 50% ;
58- transform : translateY (-50% );
59- padding : 6px ;
55+ padding : 4px 6px ;
6056 margin-left : 6px ;
6157 background : var (--c-brand );
6258 color : white;
Original file line number Diff line number Diff line change 11import { h } from 'vue'
22import Theme from 'vitepress/theme'
3- import './styles/vars.css'
43import HomeSponsors from './components/HomeSponsors.vue'
54import AsideSponsors from './components/AsideSponsors.vue'
65import SvgImage from './components/SvgImage.vue'
6+ import './styles/vars.css'
7+ import './custom.css'
78
89export default {
910 ...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:
4242 title : 完全类型化的API
4343 details : 灵活的 API 和完整的 TypeScript 类型。
4444---
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