UNPKG

vuepress-theme-hope

Version:

A light vuepress theme with tons of features

47 lines 1.6 kB
import { computed, defineComponent, h } from "vue"; import { usePure } from "@theme-hope/composables/index"; 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: Object, /** * Reading time locale * * 阅读时间语言环境 */ readingTimeLocale: Object, }, setup(props) { const metaLocale = useMetaLocale(); const isPure = usePure(); 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}${isPure.value ? "" : "⌛"}`, ...(isPure.value ? {} : { "data-balloon-pos": "up" }), }, [ h(TimerIcon), h("span", props.readingTimeLocale.time), h("meta", { property: "timeRequired", content: readingTimeMeta.value, }), ]) : null; }, }); //# sourceMappingURL=ReadingTimeInfo.js.map