vuepress-theme-hope
Version:
A light vuepress theme with tons of features
3 lines (2 loc) • 12.9 kB
JavaScript
import{isLinkWithProtocol as S,isLinkAbsolute as B,getDate as E,isString as f}from"@vuepress/helper/client";import{useReadingTimeData as x,useReadingTimeLocale as q}from"@vuepress/plugin-reading-time/client";import{computed as s,inject as I,h as e,defineComponent as i,shallowRef as F,ref as G,resolveComponent as W}from"vue";import{useRouter as U,useRoute as J,usePageFrontmatter as g,usePageData as y,usePageLang as K,useRoutePath as Q}from"vuepress/client";import{getAuthor as T,getCategory as X,getTag as Y,IconBase as c,generateIndexFromHash as b}from"vuepress-shared/client";import d from"@vuepress/helper/noopComponent";import{isSupported as Z}from"@vuepress/plugin-comment/pageview";import{useThemeData as a3,useThemeLocaleData as e3}from"@vuepress/plugin-theme-data/client";import w from"./styles/variables.module.scss";import{useMutationObserver as t3}from"@vueuse/core";import"balloon-css/balloon.css";const P=()=>{const a=v();return s(()=>a.value.author)},n3="http://.",h=()=>{const a=U(),n=J();return t=>{if(!t)return;if(S(t))return window.open(t);if(B(t))return n.fullPath===t?void 0:void a.push(t);const r=n.path.slice(0,n.path.lastIndexOf("/"));return void a.push(new URL(`${r}/${encodeURI(t)}`,n3).pathname)}},A=()=>a3(),v=()=>e3(),V=()=>{const a=g(),n=P();return s(()=>{const{author:t}=a.value;return t?T(t):t===!1?[]:T(n.value,!1)})},r3=()=>{const a=g(),n=__VP_BLOG__?I(Symbol.for("categoryMap")):null;return s(()=>X(a.value.category??a.value.categories).map(t=>({name:t,path:n?.value.map[t]?.path??""})))},o3=()=>{const a=g(),n=__VP_BLOG__?I(Symbol.for("tagMap")):null;return s(()=>Y(a.value.tag??a.value.tags).map(t=>({name:t,path:n?.value.map[t]?.path??""})))},l3=()=>{const a=g(),n=y();return s(()=>{const t=E(a.value.date);if(t)return t;const{createdTime:r}=n.value.git??{};return r?new Date(r):null})},s3=()=>{const a=v(),n=y(),t=g(),r=V(),o=r3(),l=o3(),m=l3(),O=x(),R=q(),k=s(()=>({author:r.value,category:o.value,date:m.value,localizedDate:n.value.localizedDate,tag:l.value,isOriginal:t.value.isOriginal??!1,readingTime:O.value,readingTimeLocale:R.value,pageview:t.value.pageview??!0})),j=s(()=>t.value.pageInfo??a.value.pageInfo??null);return{info:k,items:j}},u=()=>{const a=A();return s(()=>!!a.value.pure)},z=()=>e(c,{name:"author"},()=>e("path",{d:"M649.6 633.6c86.4-48 147.2-144 147.2-249.6 0-160-128-288-288-288s-288 128-288 288c0 108.8 57.6 201.6 147.2 249.6-121.6 48-214.4 153.6-240 288-3.2 9.6 0 19.2 6.4 25.6 3.2 9.6 12.8 12.8 22.4 12.8h704c9.6 0 19.2-3.2 25.6-12.8 6.4-6.4 9.6-16 6.4-25.6-25.6-134.4-121.6-240-243.2-288z"}));z.displayName="AuthorIcon";const M=()=>e(c,{name:"calendar"},()=>e("path",{d:"M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z"}));M.displayName="CalendarIcon";const L=()=>e(c,{name:"category"},()=>e("path",{d:"M148.41 106.992h282.176c22.263 0 40.31 18.048 40.31 40.31V429.48c0 22.263-18.047 40.31-40.31 40.31H148.41c-22.263 0-40.311-18.047-40.311-40.31V147.302c0-22.263 18.048-40.31 40.311-40.31zM147.556 553.478H429.73c22.263 0 40.311 18.048 40.311 40.31v282.176c0 22.263-18.048 40.312-40.31 40.312H147.555c-22.263 0-40.311-18.049-40.311-40.312V593.79c0-22.263 18.048-40.311 40.31-40.311zM593.927 106.992h282.176c22.263 0 40.31 18.048 40.31 40.31V429.48c0 22.263-18.047 40.31-40.31 40.31H593.927c-22.263 0-40.311-18.047-40.311-40.31V147.302c0-22.263 18.048-40.31 40.31-40.31zM730.22 920.502H623.926c-40.925 0-74.22-33.388-74.22-74.425V623.992c0-41.038 33.387-74.424 74.425-74.424h222.085c41.038 0 74.424 33.226 74.424 74.067v114.233c0 10.244-8.304 18.548-18.547 18.548s-18.548-8.304-18.548-18.548V623.635c0-20.388-16.746-36.974-37.33-36.974H624.13c-20.585 0-37.331 16.747-37.331 37.33v222.086c0 20.585 16.654 37.331 37.126 37.331H730.22c10.243 0 18.547 8.304 18.547 18.547 0 10.244-8.304 18.547-18.547 18.547z"}));L.displayName="CategoryIcon";const _=()=>e(c,{name:"eye"},()=>e("path",{d:"M992 512.096c0-5.76-.992-10.592-1.28-11.136-.192-2.88-1.152-8.064-2.08-10.816-.256-.672-.544-1.376-.832-2.08-.48-1.568-1.024-3.104-1.6-4.32C897.664 290.112 707.104 160 512 160c-195.072 0-385.632 130.016-473.76 322.592-1.056 2.112-1.792 4.096-2.272 5.856a55.512 55.512 0 00-.64 1.6c-1.76 5.088-1.792 8.64-1.632 7.744-.832 3.744-1.568 11.168-1.568 11.168-.224 2.272-.224 4.032.032 6.304 0 0 .736 6.464 1.088 7.808.128 1.824.576 4.512 1.12 6.976h-.032c.448 2.08 1.12 4.096 1.984 6.08.48 1.536.992 2.976 1.472 4.032C126.432 733.856 316.992 864 512 864c195.136 0 385.696-130.048 473.216-321.696 1.376-2.496 2.24-4.832 2.848-6.912.256-.608.48-1.184.672-1.728 1.536-4.48 1.856-8.32 1.728-8.32l-.032.032c.608-3.104 1.568-7.744 1.568-13.28zM512 672c-88.224 0-160-71.776-160-160s71.776-160 160-160 160 71.776 160 160-71.776 160-160 160z"}));_.displayName="EyeIcon";const C=()=>e(c,{name:"fire"},()=>e("path",{d:"M726.4 201.6c-12.8-9.6-28.8-6.4-38.4 0-9.6 9.6-16 25.6-9.6 38.4 6.4 12.8 9.6 28.8 12.8 44.8C604.8 83.2 460.8 38.4 454.4 35.2c-9.6-3.2-22.4 0-28.8 6.4-9.6 6.4-12.8 19.2-9.6 28.8 12.8 86.4-25.6 188.8-115.2 310.4-6.4-25.6-16-51.2-32-80-9.6-9.6-22.4-16-35.2-12.8-16 3.2-25.6 12.8-25.6 28.8-3.2 48-25.6 92.8-51.2 140.8C134.4 499.2 112 544 102.4 592c-32 150.4 99.2 329.6 233.6 380.8 9.6 3.2 19.2 6.4 32 9.6-25.6-19.2-41.6-51.2-48-96C294.4 691.2 505.6 640 515.2 460.8c153.6 105.6 224 336 137.6 505.6 3.2 0 6.4-3.2 9.6-3.2 0 0 3.2 0 3.2-3.2 163.2-89.6 252.8-208 259.2-345.6 16-211.2-163.2-390.4-198.4-412.8z"}));C.displayName="FireIcon";const D=()=>e(c,{name:"print"},()=>e("path",{d:"M819.2 364.8h-44.8V128c0-17.067-14.933-32-32-32H281.6c-17.067 0-32 14.933-32 32v236.8h-44.8C145.067 364.8 96 413.867 96 473.6v192c0 59.733 49.067 108.8 108.8 108.8h44.8V896c0 17.067 14.933 32 32 32h460.8c17.067 0 32-14.933 32-32V774.4h44.8c59.733 0 108.8-49.067 108.8-108.8v-192c0-59.733-49.067-108.8-108.8-108.8zM313.6 160h396.8v204.8H313.6V160zm396.8 704H313.6V620.8h396.8V864zM864 665.6c0 25.6-19.2 44.8-44.8 44.8h-44.8V588.8c0-17.067-14.933-32-32-32H281.6c-17.067 0-32 14.933-32 32v121.6h-44.8c-25.6 0-44.8-19.2-44.8-44.8v-192c0-25.6 19.2-44.8 44.8-44.8h614.4c25.6 0 44.8 19.2 44.8 44.8v192z"}));D.displayName="PrintIcon";const $=()=>e(c,{name:"tag"},()=>e("path",{d:"M939.902 458.563L910.17 144.567c-1.507-16.272-14.465-29.13-30.737-30.737L565.438 84.098h-.402c-3.215 0-5.726 1.005-7.634 2.913l-470.39 470.39a10.004 10.004 0 000 14.164l365.423 365.424c1.909 1.908 4.42 2.913 7.132 2.913s5.223-1.005 7.132-2.913l470.39-470.39c2.01-2.11 3.014-5.023 2.813-8.036zm-240.067-72.121c-35.458 0-64.286-28.828-64.286-64.286s28.828-64.285 64.286-64.285 64.286 28.828 64.286 64.285-28.829 64.286-64.286 64.286z"}));$.displayName="TagIcon";const N=()=>e(c,{name:"timer"},()=>e("path",{d:"M799.387 122.15c4.402-2.978 7.38-7.897 7.38-13.463v-1.165c0-8.933-7.38-16.312-16.312-16.312H256.33c-8.933 0-16.311 7.38-16.311 16.312v1.165c0 5.825 2.977 10.874 7.637 13.592 4.143 194.44 97.22 354.963 220.201 392.763-122.204 37.542-214.893 196.511-220.2 389.397-4.661 5.049-7.638 11.651-7.638 19.03v5.825h566.49v-5.825c0-7.379-2.849-13.981-7.509-18.9-5.049-193.016-97.867-351.985-220.2-389.527 123.24-37.67 216.446-198.453 220.588-392.892zM531.16 450.445v352.632c117.674 1.553 211.787 40.778 211.787 88.676H304.097c0-48.286 95.149-87.382 213.728-88.676V450.445c-93.077-3.107-167.901-81.297-167.901-177.093 0-8.803 6.99-15.793 15.793-15.793 8.803 0 15.794 6.99 15.794 15.793 0 80.261 63.69 145.635 142.01 145.635s142.011-65.374 142.011-145.635c0-8.803 6.99-15.793 15.794-15.793s15.793 6.99 15.793 15.793c0 95.019-73.789 172.82-165.96 177.093z"}));N.displayName="TimerIcon";const H=()=>e(c,{name:"word"},()=>[e("path",{d:"M518.217 432.64V73.143A73.143 73.143 0 01603.43 1.097a512 512 0 01419.474 419.474 73.143 73.143 0 01-72.046 85.212H591.36a73.143 73.143 0 01-73.143-73.143z"}),e("path",{d:"M493.714 566.857h340.297a73.143 73.143 0 0173.143 85.577A457.143 457.143 0 11371.566 117.76a73.143 73.143 0 0185.577 73.143v339.383a36.571 36.571 0 0036.571 36.571z"})]);H.displayName="WordIcon";const p=()=>{const a=v();return s(()=>a.value.metaLocales)};var i3=i({name:"AuthorInfo",inheritAttrs:!1,props:{author:{type:Array,required:!0}},setup(a){const n=p(),t=u();return()=>a.author.length?e("span",{class:"page-author-info","aria-label":`${n.value.author}${t.value?"":"🖊"}`,...t.value?{}:{"data-balloon-pos":"up"}},[e(z),e("span",a.author.map(r=>r.url?e("a",{class:"page-author-item",href:r.url,target:"_blank",rel:"noopener noreferrer"},r.name):e("span",{class:"page-author-item"},r.name))),e("span",{property:"author",content:a.author.map(r=>r.name).join(", ")})]):null}}),c3=i({name:"CategoryInfo",inheritAttrs:!1,props:{category:{type:Array,required:!0}},setup(a){const n=p(),t=h(),r=u();return()=>a.category.length?e("span",{class:"page-category-info","aria-label":`${n.value.category}${r.value?"":"🌈"}`,...r.value?{}:{"data-balloon-pos":"up"}},[e(L),a.category.map(({name:o,path:l})=>e("span",{class:["page-category-item",{[`color${b(o,Number(w.colorNumber))}`]:!r.value,clickable:l}],role:l?"navigation":"",onClick:()=>{l&&t(l)}},o)),e("meta",{property:"articleSection",content:a.category.map(({name:o})=>o).join(",")})]):null}}),u3=i({name:"DateInfo",inheritAttrs:!1,props:{date:Object,localizedDate:String},setup(a){const n=K(),t=p(),r=u();return()=>a.date?e("span",{class:"page-date-info","aria-label":`${t.value.date}${r.value?"":"📅"}`,...r.value?{}:{"data-balloon-pos":"up"}},[e(M),e("span",{"data-allow-mismatch":"text"},a.localizedDate??a.date.toLocaleDateString(n.value)),e("meta",{property:"datePublished",content:a.date.toISOString()||""})]):null}}),p3=i({name:"OriginalInfo",inheritAttrs:!1,props:{isOriginal:Boolean},setup(a){const n=p();return()=>a.isOriginal?e("span",{class:"page-original-info"},n.value.origin):null}}),m3=i({name:"PageViewInfo",inheritAttrs:!1,props:{pageview:[Boolean,String]},setup(a){const n=Q(),t=p(),r=u(),o=F(),l=G(0);return t3(o,()=>{const m=o.value.textContent;m&&!isNaN(Number(m))&&(l.value=Number(m))},{childList:!0}),()=>a.pageview?e("span",{class:"page-pageview-info","aria-label":`${t.value.views}${r.value?"":"🔢"}`,...r.value?{}:{"data-balloon-pos":"up"}},[e(l.value<1e3?_:C),e("span",{ref:o,id:"ArtalkPV",class:"vp-pageview waline-pageview-count","data-path":f(a.pageview)?a.pageview:n.value,"data-page-key":f(a.pageview)?a.pageview:n.value},"...")]):null}}),g3=i({name:"ReadingTimeInfo",inheritAttrs:!1,props:{readingTime:Object,readingTimeLocale:Object},setup(a){const n=p(),t=u(),r=s(()=>{if(!a.readingTime)return null;const{minutes:o}=a.readingTime;return o<1?"PT1M":`PT${Math.round(o)}M`});return()=>a.readingTimeLocale?.time?e("span",{class:"page-reading-time-info","aria-label":`${n.value.readingTime}${t.value?"":"⌛"}`,...t.value?{}:{"data-balloon-pos":"up"}},[e(N),e("span",a.readingTimeLocale.time),e("meta",{property:"timeRequired",content:r.value})]):null}}),v3=i({name:"TagInfo",inheritAttrs:!1,props:{tag:Array},setup(a){const n=p(),t=h(),r=u();return()=>a.tag?.length?e("span",{class:"page-tag-info","aria-label":`${n.value.tag}${r.value?"":"🏷"}`,...r.value?{}:{"data-balloon-pos":"up"}},[e($),a.tag.map(({name:o,path:l})=>e("span",{class:["page-tag-item",{[`color${b(o,Number(w.colorNumber))}`]:!r.value,clickable:l}],role:l?"navigation":"",onClick:()=>{l&&t(l)}},o)),e("meta",{property:"keywords",content:a.tag.map(({name:o})=>o).join(",")})]):null}}),d3=i({name:"ReadTimeInfo",inheritAttrs:!1,props:{readingTime:Object,readingTimeLocale:Object},setup(a){const n=p(),t=u();return()=>a.readingTimeLocale?.words?e("span",{class:"page-word-info","aria-label":`${n.value.words}${t.value?"":"🔠"}`,...t.value?{}:{"data-balloon-pos":"up"}},[e(H),e("span",a.readingTimeLocale.words),e("meta",{property:"wordCount",content:a.readingTime?.words})]):null}}),h3=i({name:"PageInfo",components:{AuthorInfo:i3,CategoryInfo:c3,DateInfo:u3,OriginalInfo:p3,PageViewInfo:Z?m3:d,ReadingTimeInfo:__VP_READING_TIME__?g3:d,TagInfo:v3,WordInfo:__VP_READING_TIME__?d3:d},props:{items:[Boolean,Array],info:{type:Object,required:!0}},setup(a){const n=u();return()=>{const t=a.items??["Author","Original","Date","PageView","ReadingTime","Category","Tag"];return t?e("div",{class:"page-info"},t.map(r=>e(W(`${r}Info`),{...a.info,isPure:n.value}))):null}}});export{D as P,h as a,P as b,A as c,u as d,V as e,p as f,s3 as g,h3 as k,v as u};
//# sourceMappingURL=PageInfo-Cb8wmvLH.js.map