UNPKG

vuepress-theme-hope

Version:

A light vuepress theme with tons of features

34 lines 1.53 kB
import { computed, defineComponent, h } from "vue"; import { RouteLink, resolveRoute } from "vuepress/client"; import { useArticles } from "@theme-hope/composables/blog/useArticles"; import { useBlogLocale } from "@theme-hope/composables/blog/useBlogLocale"; import { useStars } from "@theme-hope/composables/blog/useStars"; import { useData } from "@theme-hope/composables/useData"; import "../../styles/blog/article-type.scss"; export default defineComponent({ name: "ArticleType", setup() { const { page, routeLocale } = useData(); const articles = useArticles(); const stars = useStars(); const blogLocale = useBlogLocale(); const types = computed(() => [ { text: blogLocale.value.all, path: articles.value.path, }, { text: blogLocale.value.star, path: stars.value.path }, ...__VP_BLOG_TYPES__.map(({ key, path }) => { const routePath = path.replace(/^\//u, routeLocale.value); return { text: blogLocale.value[key] ?? resolveRoute(routePath).meta.title ?? key, path: routePath, }; }), ]); return () => h("ul", { class: "vp-article-type-wrapper" }, types.value.map((type) => h("li", { class: ["vp-article-type", { active: type.path === page.value.path }], }, h(RouteLink, { to: type.path }, () => type.text)))); }, }); //# sourceMappingURL=ArticleType.js.map