Skip to content

Commit

Permalink
docs: create preview service
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Jan 4, 2024
1 parent 64da8c6 commit 8913533
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions docs/.vitepress/components/preview-service.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<img :src="image" alt="" class="preview">
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useData, withBase } from 'vitepress'
const props = defineProps<{ name: string }>()
const { isDark } = useData()
const image = computed(() => withBase(`/services/${props.name}${isDark.value ? '-dark' : ''}.png`))
</script>

<style scoped>
.preview {
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
margin: 16px 0;
}
</style>
9 changes: 8 additions & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import './custom.css'
import PreviewService from '../components/preview-service.vue'

export default DefaultTheme
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('PreviewService', PreviewService)
},
} satisfies Theme

0 comments on commit 8913533

Please sign in to comment.