Merge pull request #2 from EasyTier/fix/star-history-fit-theme

🐞 fix: follow theme switch
This commit is contained in:
m1m1sha
2024-05-10 00:07:33 +08:00
committed by GitHub
3 changed files with 35 additions and 14 deletions
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import { useData } from 'vitepress'
import { computed } from 'vue'
const props = defineProps<{
repo: string
type?: 'Date' | 'Timeline'
}>()
const { isDark } = useData()
const url = computed(() =>
`https://star-history.com/#${props.repo}&${props.type || 'Date'}`,
)
const imgUrl = computed(() =>
`https://api.star-history.com/svg?repos=${props.repo}&type=${props.type || 'Date'}${isDark.value ? '&theme=dark' : ''}`,
)
</script>
<template>
<a :href="url">
<img alt="Star History Chart" :src="imgUrl">
</a>
</template>