UNPKG

vuepress-theme-hope

Version:

A light vuepress theme with tons of features

3 lines (2 loc) 13.5 kB
import{getDate as B,isLinkWithProtocol as W,isLinkAbsolute as G,isString as A}from"@vuepress/helper/client";import{useReadingTimeData as U,useReadingTimeLocale as J}from"@vuepress/plugin-reading-time/client";import{computed as l,inject as w,h as a,defineComponent as i,shallowRef as K,ref as Q,resolveComponent as X}from"vue";import{useData as Y,useFrontmatter as d,useRouter as Z,useRoute as e3,useLang as a3,useRoutePath as t3}from"vuepress/client";import{isArray as M,isString as g,isPlainObject as r3}from"@vuepress/helper/shared";import h from"@vuepress/helper/noopComponent";import{isSupported as n3}from"@vuepress/plugin-comment/pageview";import{IconBase as c,generateIndexFromHash as $}from"vuepress-shared/client";import{useThemeLocaleData as o3,useThemeData as s3}from"@vuepress/plugin-theme-data/client";import P from"./styles/variables.module.scss";import{useMutationObserver as l3}from"@vueuse/core";import"balloon-css/balloon.css";const f=()=>s3(),v=()=>o3(),I=()=>({...Y(),theme:f(),themeLocale:v()}),u=()=>{const e=f();return l(()=>!!e.value.pure)},V=()=>{const e=v();return l(()=>e.value.author)},z=e=>r3(e)&&g(e.name),y=(e,r=!1)=>e?M(e)?e.map(t=>g(t)?{name:t}:z(t)?t:null).filter(t=>t!==null):g(e)?[{name:e}]:z(e)?[e]:(console.error(`Expect "author" to be \`AuthorInfo[] | AuthorInfo | string[] | string ${r?"":"| false"} | undefined\`, but got`,e),[]):[],b=(e,r)=>{if(e){if(M(e)&&e.every(g))return e;if(g(e))return[e];console.error(`Expect ${r} to be \`string[] | string | undefined\`, but got`,e)}return[]},C=e=>b(e,"category"),L=e=>b(e,"tag"),N=()=>{const e=d(),r=V();return l(()=>{const{author:t}=e.value;return t?y(t):t===!1?[]:y(r.value,!1)})},i3=()=>{const e=d(),r=w(Symbol.for("categoryMap"),null);return l(()=>C(e.value.category??e.value.categories).map(t=>({name:t,path:r?.value.map[t]?.path??""})))},c3=()=>{const e=d(),r=w(Symbol.for("tagMap"),null);return l(()=>L(e.value.tag??e.value.tags).map(t=>({name:t,path:r?.value.map[t]?.path??""})))},u3=()=>{const{frontmatter:e,page:r}=I();return l(()=>{const t=B(e.value.date);if(t)return t;const{createdTime:n}=r.value.git??{};return n?new Date(n):null})},p3=()=>{const{frontmatter:e,themeLocale:r}=I(),t=N(),n=i3(),o=c3(),s=u3(),m=U(),x=J(),F=l(()=>({author:t.value,category:n.value,date:s.value,tag:o.value,isOriginal:e.value.isOriginal??!1,readingTime:m.value,readingTimeLocale:x.value,pageview:e.value.pageview??!0})),q=l(()=>e.value.pageInfo??r.value.pageInfo??null);return{info:F,items:q}},p=()=>{const e=v();return l(()=>e.value.metaLocales)},m3="http://.",T=()=>{const e=Z(),r=e3();return t=>{if(!t)return;if(W(t))return window.open(t);if(G(t))return r.fullPath===t?void 0:void e.push(t);const n=r.path.slice(0,r.path.lastIndexOf("/"));return void e.push(new URL(`${n}/${encodeURI(t)}`,m3).pathname)}},H=()=>a(c,{name:"author"},()=>a("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"}));H.displayName="AuthorIcon";const O=()=>a(c,{name:"calendar"},()=>a("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"}));O.displayName="CalendarIcon";const D=()=>a(c,{name:"category"},()=>a("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"}));D.displayName="CategoryIcon";const R=()=>a(c,{name:"eye"},()=>a("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"}));R.displayName="EyeIcon";const _=()=>a(c,{name:"fire"},()=>a("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"}));_.displayName="FireIcon";const j=()=>a(c,{name:"print"},()=>a("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"}));j.displayName="PrintIcon";const S=()=>a(c,{name:"tag"},()=>a("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"}));S.displayName="TagIcon";const k=()=>a(c,{name:"timer"},()=>a("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"}));k.displayName="TimerIcon";const E=()=>a(c,{name:"word"},()=>[a("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"}),a("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"})]);E.displayName="WordIcon";var g3=i({name:"AuthorInfo",inheritAttrs:!1,props:{author:{type:Array,required:!0}},setup(e){const r=p(),t=u();return()=>e.author.length?a("span",{class:"page-author-info","aria-label":`${r.value.author}${t.value?"":"🖊"}`,...t.value?{}:{"data-balloon-pos":"up"}},[a(H),a("span",e.author.map(n=>n.url?a("a",{class:"page-author-item",href:n.url,target:"_blank",rel:"noopener noreferrer"},n.name):a("span",{class:"page-author-item"},n.name))),a("span",{property:"author",content:e.author.map(n=>n.name).join(", ")})]):null}}),v3=i({name:"CategoryInfo",inheritAttrs:!1,props:{category:{type:Array,required:!0}},setup(e){const r=p(),t=T(),n=u();return()=>e.category.length?a("span",{class:"page-category-info","aria-label":`${r.value.category}${n.value?"":"🌈"}`,...n.value?{}:{"data-balloon-pos":"up"}},[a(D),e.category.map(({name:o,path:s})=>a("span",{class:["page-category-item",{[`color${$(o,Number(P.colorNumber))}`]:!n.value,clickable:s}],role:s?"navigation":"",onClick:()=>{s&&t(s)}},o)),a("meta",{property:"articleSection",content:e.category.map(({name:o})=>o).join(",")})]):null}}),d3=i({name:"DateInfo",inheritAttrs:!1,props:{date:Object},setup(e){const r=a3(),t=p(),n=u(),o=l(()=>new Intl.DateTimeFormat(r.value,{dateStyle:"short"})),s=l(()=>e.date?o.value.format(e.date):null);return()=>e.date?a("span",{class:"page-date-info","aria-label":`${t.value.date}${n.value?"":"📅"}`,...n.value?{}:{"data-balloon-pos":"up"}},[a(O),a("span",{"data-allow-mismatch":"text"},s.value),a("meta",{property:"datePublished",content:e.date.toISOString()||""})]):null}}),h3=i({name:"OriginalInfo",inheritAttrs:!1,props:{isOriginal:Boolean},setup(e){const r=p();return()=>e.isOriginal?a("span",{class:"page-original-info"},r.value.origin):null}}),f3=i({name:"PageViewInfo",inheritAttrs:!1,props:{pageview:[Boolean,String]},setup(e){const r=t3(),t=p(),n=u(),o=K(),s=Q(0);return l3(o,()=>{const m=o.value.textContent;m&&!isNaN(Number(m))&&(s.value=Number(m))},{childList:!0}),()=>e.pageview?a("span",{class:"page-pageview-info","aria-label":`${t.value.views}${n.value?"":"🔢"}`,...n.value?{}:{"data-balloon-pos":"up"}},[a(s.value<1e3?R:_),a("span",{ref:o,id:"ArtalkPV",class:"vp-pageview waline-pageview-count","data-path":A(e.pageview)?e.pageview:r.value,"data-page-key":A(e.pageview)?e.pageview:r.value},"...")]):null}}),I3=i({name:"ReadingTimeInfo",inheritAttrs:!1,props:{readingTime:Object,readingTimeLocale:Object},setup(e){const r=p(),t=u(),n=l(()=>{if(!e.readingTime)return null;const{minutes:o}=e.readingTime;return o<1?"PT1M":`PT${Math.round(o)}M`});return()=>e.readingTimeLocale?.time?a("span",{class:"page-reading-time-info","aria-label":`${r.value.readingTime}${t.value?"":"⌛"}`,...t.value?{}:{"data-balloon-pos":"up"}},[a(k),a("span",e.readingTimeLocale.time),a("meta",{property:"timeRequired",content:n.value})]):null}}),y3=i({name:"TagInfo",inheritAttrs:!1,props:{tag:Array},setup(e){const r=p(),t=T(),n=u();return()=>e.tag?.length?a("span",{class:"page-tag-info","aria-label":`${r.value.tag}${n.value?"":"🏷"}`,...n.value?{}:{"data-balloon-pos":"up"}},[a(S),e.tag.map(({name:o,path:s})=>a("span",{class:["page-tag-item",{[`color${$(o,Number(P.colorNumber))}`]:!n.value,clickable:s}],role:s?"navigation":"",onClick:()=>{s&&t(s)}},o)),a("meta",{property:"keywords",content:e.tag.map(({name:o})=>o).join(",")})]):null}}),b3=i({name:"ReadTimeInfo",inheritAttrs:!1,props:{readingTime:Object,readingTimeLocale:Object},setup(e){const r=p(),t=u();return()=>e.readingTimeLocale?.words?a("span",{class:"page-word-info","aria-label":`${r.value.words}${t.value?"":"🔠"}`,...t.value?{}:{"data-balloon-pos":"up"}},[a(E),a("span",e.readingTimeLocale.words),a("meta",{property:"wordCount",content:e.readingTime?.words})]):null}}),T3=i({name:"PageInfo",components:{AuthorInfo:g3,CategoryInfo:v3,DateInfo:d3,OriginalInfo:h3,PageViewInfo:n3?f3:h,ReadingTimeInfo:__VP_READING_TIME__?I3:h,TagInfo:y3,WordInfo:__VP_READING_TIME__?b3:h},props:{items:[Boolean,Array],info:{type:Object,required:!0}},setup(e){const r=u();return()=>{const t=e.items??["Author","Original","Date","PageView","ReadingTime","Category","Tag"];return t?a("div",{class:"page-info"},t.map(n=>a(X(`${n}Info`),{...e.info,isPure:r.value}))):null}}});export{j as P,T3 as T,I as a,T as b,p3 as c,u as d,f as e,b as f,y as g,C as h,L as i,p as j,v as k,N as l,V as u}; //# sourceMappingURL=PageInfo-CL1v9JCd.js.map