UNPKG

hirsun-vuepress-theme-hope-plus

Version:
57 lines 1.77 kB
import { computed, defineComponent, h } from "vue"; import { TimerIcon } from "@theme-hope/modules/info/components/icons"; import { useMetaLocale } from "@theme-hope/modules/info/composables/index"; export default defineComponent({ name: "ReadingTimeInfo", inheritAttrs: false, props: { /** * Reading time information * * 阅读时间信息 */ readingTime: { type: Object, default: () => null, }, /** * Reading time locale * * 阅读时间语言环境 */ readingTimeLocale: { type: Object, default: () => null, }, /** * Whether in pure mode * * 是否处于纯净模式 */ pure: Boolean, }, setup(props) { const metaLocale = useMetaLocale(); const readingTimeMeta = computed(() => { if (!props.readingTime) return null; const { minutes } = props.readingTime; return minutes < 1 ? "PT1M" : `PT${Math.round(minutes)}M`; }); return () => props.readingTimeLocale?.time ? h("span", { class: "page-reading-time-info", "aria-label": `${metaLocale.value.readingTime}${props.pure ? "" : "⌛"}`, ...(props.pure ? {} : { "data-balloon-pos": "down" }), }, [ h(TimerIcon), h("span", props.readingTimeLocale?.time), h("meta", { property: "timeRequired", content: readingTimeMeta.value, }), ]) : null; }, }); //# sourceMappingURL=ReadingTimeInfo.js.map