Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
feat: 面包屑和文章标签组件
Browse files Browse the repository at this point in the history
  • Loading branch information
zkz098 committed Nov 17, 2023
1 parent 8f101f9 commit 55a857f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions theme/components/ShokaxPostBreadcrumb.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import type { Post } from 'valaxy'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
defineProps<{
post: Post
}>()
const { t } = useI18n()
const blank = ref('')
</script>

<template v-if="typeof post.categories === 'object'">
<div class="breadcrumb" itemListElement itemscope itemtype="https://schema.org/BreadcrumbList">
<div class="i-ri-home-4-fill" />
<span>
<RouterLink to="/">
{{ t('menu.home') }}
</RouterLink>
</span>
</div>
<div class="i-ri-arrow-right-s-line" />
<span
v-for="(item, index) in post.categories" :key="item" :class="{ current: index === Number(post.categories?.length) - 1 }"
itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"
>
<RouterLink :to="blank">
<span itemprop="name">
{{ item }}
<meta itemprop="position" :content="String(index)">
</span>
</RouterLink>
<div v-if="index > 1 && index !== Number(post.categories?.length) - 1" class="i-ri-arrow-right-s-line" />
</span>
</template>
16 changes: 16 additions & 0 deletions theme/components/ShokaxPostFooterTags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import type { Post } from 'valaxy'
defineProps<{
post: Post
}>()
</script>

<template>
<div v-if="post.tags" class="tags text-left mt-3 text-sm">
<RouterLink v-for="tag in post.tags" :key="tag" :to="`/tags/${tag}/`">
<div class="i-ri-price-tag-3-line" />
{{ tag }}
</RouterLink>
</div>
</template>

0 comments on commit 55a857f

Please sign in to comment.