Skip to content

Commit

Permalink
feat(docs): add contributors & enhance AddonGallery components
Browse files Browse the repository at this point in the history
  • Loading branch information
WRXinYue committed Sep 19, 2024
1 parent 695c88c commit 81389a3
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 5 deletions.
18 changes: 14 additions & 4 deletions docs/components/AddonGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n'
export interface ValaxyAddon {
icon: string
name: string
author: string | string[]
repo: string
desc: string
desc_zh: string
Expand All @@ -20,10 +21,19 @@ const props = withDefaults(defineProps<{
const { t } = useI18n()
const keyword = ref('')
const filteredAddons = computed(() => {
return props.addons.filter((item) => {
return item.name.includes(keyword.value) || item.tags?.some(t => t.includes(keyword.value))
})
return props.addons
.filter(item => item.name.includes(keyword.value) || item.tags?.some(t => t.includes(keyword.value)))
.map((item) => {
if (typeof item.author === 'string')
return { ...item, author: [item.author] }
return item
})
})
function handleTagClick(tag: string) {
keyword.value = tag
}
</script>

<template>
Expand All @@ -42,7 +52,7 @@ const filteredAddons = computed(() => {
</div>
<ul class="m-0! p-0! sm:grid-cols-1 lg:grid-cols-2 grid" gap="4">
<li v-for="addon, i in filteredAddons" :key="i" class="w-full list-none m-0!">
<AddonGalleryCard :addon="addon" />
<AddonGalleryCard :addon="addon" @tag-click="handleTagClick" />
</li>
</ul>
</template>
15 changes: 14 additions & 1 deletion docs/components/AddonGalleryCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import type { ValaxyAddon } from './AddonGallery.vue'
defineProps<{
addon: ValaxyAddon
}>()
const emit = defineEmits(['tagClick'])
function handleTagClick(tag: string) {
emit('tagClick', tag)
}
</script>

<template>
Expand All @@ -18,6 +24,13 @@ defineProps<{
<span>{{ addon.name }}</span>
</h3>
</a>
<p v-if="addon.author" class="my-2! text-sm" op="70">
By
<span v-for="(author, index) in addon.author" :key="index">
<a class="text-dark-200!" :href="`https://github.com/${author}`" target="_blank">{{ author }}</a>
<span v-if="index < addon.author.length - 1">, </span>
</span>
</p>
<p class="my-1! text-xl!">
<a mr-2 class="text-red-600!" :href="`https://npmjs.com/package/${addon.name}`" target="_blank" alt="NPM Package">
<div i-ri-npmjs-line />
Expand All @@ -41,7 +54,7 @@ defineProps<{
<span inline-flex mr-1>
<div :class="addon.icon" />
</span>
<span v-for="tag, j in addon.tags" :key="j" class="break-all mr-1">
<span v-for="tag, j in addon.tags" :key="j" class="break-all mr-1 cursor-pointer" @click="handleTagClick(tag)">
#{{ tag }}
</span>
</ul>
Expand Down
23 changes: 23 additions & 0 deletions docs/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>

<template>
<Layout>
<RouterView v-slot="{ Component }">
<component :is="Component">
<template #default>
<div class="prose mx-auto w-full max-w-4xl">
<h2 :id="t('post.contributors')">
<a :href="`#${t('post.contributors')}`" class="header-anchor" />
{{ t('post.contributors') }}
</h2>
<GitLogContributor />
</div>
</template>
</component>
</RouterView>
</Layout>
</template>
3 changes: 3 additions & 0 deletions docs/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ toc:
base-config: Base Config
extend-config: Extend Config
unocss-options: UnoCSS Options

post:
contributors: Contributors
3 changes: 3 additions & 0 deletions docs/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ toc:
base-config: 基础配置
extend-config: 扩展配置
unocss-options: UnoCSS 配置

post:
contributors: 贡献者
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"valaxy": "link:../packages/valaxy",
"valaxy-addon-algolia": "link:../packages/valaxy-addon-algolia",
"valaxy-addon-components": "workspace:*",
"valaxy-addon-git-log": "^0.1.0",
"valaxy-theme-press": "link:../packages/valaxy-theme-press"
},
"devDependencies": {
Expand Down
37 changes: 37 additions & 0 deletions docs/pages/addons/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,98 @@ end: false

addons:
- name: valaxy-addon-algolia
author: YunYouJun
icon: i-ri-search-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-algolia
desc: Algolia Search.
desc_zh: Algolia 搜索
tags:
- search
- name: valaxy-addon-components
author: YunYouJun
icon: i-ri-apps-2-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-components
desc: Common Components for Valaxy.
desc_zh: Valaxy 的通用组件
tags:
- component
- name: valaxy-addon-lightgallery
author: YunYouJun
icon: i-ri-image-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-lightgallery
desc: LightGallery for Valaxy.
desc_zh: Valaxy 的 LightGallery
tags:
- image
- name: valaxy-addon-waline
author: YunYouJun
icon: i-ri-chat-3-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-waline
desc: Waline comment.
desc_zh: Waline 评论系统
tags:
- comment
- name: valaxy-addon-twikoo
author: YunYouJun
icon: i-ri-chat-3-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-twikoo
desc: Twikoo comment.
desc_zh: Twikoo 评论系统
tags:
- comment
- name: valaxy-addon-bangumi
author:
- yixiaojiu
- YunYouJun
icon: i-ri-film-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-bangumi
desc: Display bilibili or bangumi watching list.
desc_zh: 展示 bilibili 或 bangumi 追番列表
tags:
- video
- name: valaxy-addon-meting
author:
- YunYouJun
- yixiaojiu
icon: i-ri-music-2-line
repo: https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-meting
desc: Global music player based on APlayer and MetingJS.
desc_zh: 基于 APlayer 和 MetingJS 的全局音乐播放器
tags:
- music
- name: valaxy-addon-live2d
author: WRXinYue
icon: i-ri-magic-line
repo: https://github.com/valaxyjs/valaxy-addon-live2d
desc: Cute live2d mascot component.
desc_zh: 萌萌哒 live2d 看板娘组件
tags:
- magic
- name: valaxy-addon-git-log
author: WRXinYue
icon: i-ri-git-pull-request-line
repo: https://github.com/valaxyjs/valaxy-addon-git-log
desc: Integrates git logs into your page of Valaxy site.
desc_zh: 将 Git 日志集成到你的 Valaxy 网站页面中
tags:
- git-log
- name: valaxy-addon-hitokoto
author: WRXinYue
icon: i-ri-chat-quote-line
repo: https://github.com/valaxyjs/valaxy-addon-hitokoto
desc: Hitokoto Composition API for Valaxy.
desc_zh: 将一言(Hitokoto)API 集成于 Valaxy
tags:
- hitokoto
- name: valaxy-addon-vercount
author: WRXinYue
icon: i-ri-eye-line
repo: https://github.com/valaxyjs/valaxy-addon-vercount
desc: A Vercount API based counting plugin for Valaxy, serving as an alternative to Busuanzi counting.
desc_zh: 基于 Vercount API 实现的 Valaxy 计数插件, 用于不蒜子计数替代方案
tags:
- busuanzi
- vercount
---

<AddonGallery :addons="$frontmatter.addons" />
4 changes: 4 additions & 0 deletions docs/valaxy.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineValaxyConfig } from 'valaxy'
import type { PressTheme } from 'valaxy-theme-press'
import { addonAlgolia } from 'valaxy-addon-algolia'
import { addonComponents } from 'valaxy-addon-components'
import { addonGitLog } from 'valaxy-addon-git-log'

const COMMIT_ID = process.env.CF_PAGES_COMMIT_SHA || process.env.COMMIT_REF
const commitRef = COMMIT_ID?.slice(0, 8) || 'dev'
Expand Down Expand Up @@ -39,6 +40,9 @@ export default defineValaxyConfig<PressTheme.Config>({
indexName: 'valaxysite',
}),
addonComponents(),
addonGitLog({
repositoryUrl: 'https://github.com/YunYouJun/valaxy.git',
}),
],

theme: 'press',
Expand Down
28 changes: 28 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 81389a3

Please sign in to comment.