docs/.vitepress/theme/components/SidebarCard.vue

0a2500d168b17e2d35e20da9ef519df785d5a70b
wotaku/docs/.vitepress/theme/components/SidebarCard.vue history · blame · raw

52 lines · 1361 bytes

 1<!--
 2  All Rights Reserved
 3
 4  Copyright (c) 2025 taskylizard
 5
 6  All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
 7-->
 8<script setup lang="ts">
 9import { computed } from 'vue'
10import { useData } from 'vitepress'
11import { useStorage } from '@vueuse/core'
12import { AccentColorStorageKey } from '../constants'
13
14const { isDark } = useData()
15const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
16
17const accentImageMap: Record<string, string> = {
18  ayanami: 'rei',
19  asuka: 'asuka',
20  miku: 'miku',
21  inanis: 'ina',
22  watson: 'ame',
23  baelz: 'bae',
24  irys: 'irys',
25  suisei: 'suisei',
26}
27
28const sidebarImage = computed(() => {
29  if (accentColor.value === 'fubuki') {
30    return isDark.value ? '/sidebar/fubuki.avif' : '/sidebar/kuro.avif'
31  }
32  const name = accentImageMap[accentColor.value] ?? 'rei'
33  return `/sidebar/${name}.avif`
34})
35</script>
36
37<template>
38  <div class="mt-2 overflow-hidden rounded-xl border-2 border-solid border-[#3d3d3d] relative z-0 max-md:border-2 max-md:border-[#3d3d3d]">
39    <img
40      :src="sidebarImage"
41      alt=""
42      class="w-full h-full object-cover block"
43      no-zoomable
44    />
45  </div>
46</template>
47
48<style scoped>
49img {
50  pointer-events: none;
51}
52</style>