mirror of
https://github.com/bspeice/speice.io
synced 2024-11-14 22:18:10 -05:00
1 line
6.2 KiB
JavaScript
1 line
6.2 KiB
JavaScript
|
"use strict";(self.webpackChunkspeice_io=self.webpackChunkspeice_io||[]).push([["9555"],{3549:function(e,t,n){n.r(t),n.d(t,{default:()=>I});var r=n("5893"),i=n("7294"),l=n("7026"),s=n("2743"),a=n("4681"),o=n("4183"),c=n("979"),d=n("2553"),u=n("8127");function m(){let{assets:e,metadata:t}=(0,o.nO)(),{title:n,description:i,date:l,tags:a,authors:c,frontMatter:d}=t,{keywords:u}=d,m=e.image??d.image;return(0,r.jsxs)(s.d,{title:d.title_meta??n,description:i,keywords:u,image:m,children:[(0,r.jsx)("meta",{property:"og:type",content:"article"}),(0,r.jsx)("meta",{property:"article:published_time",content:l}),c.some(e=>e.url)&&(0,r.jsx)("meta",{property:"article:author",content:c.map(e=>e.url).filter(Boolean).join(",")}),a.length>0&&(0,r.jsx)("meta",{property:"article:tag",content:a.map(e=>e.label).join(",")})]})}var f=n("4819");function h(){let e=(0,o.iZ)();return(0,r.jsx)(f.Z,{children:(0,r.jsx)("script",{type:"application/ld+json",children:JSON.stringify(e)})})}var x=n("140");function p(e){let t=e.getBoundingClientRect();return t.top===t.bottom?p(e.parentNode):t}var j=n("3012");let g=i.memo(function e(t){let{toc:n,className:i,linkClassName:l,isChild:s}=t;return n.length?(0,r.jsx)("ul",{className:s?void 0:i,children:n.map(t=>(0,r.jsxs)("li",{children:[(0,r.jsx)(j.Z,{to:`#${t.id}`,className:l??void 0,dangerouslySetInnerHTML:{__html:t.value}}),(0,r.jsx)(e,{isChild:!0,toc:t.children,className:i,linkClassName:l})]},t.id))}):null});function v(e){let{toc:t,className:n="table-of-contents table-of-contents__left-border",linkClassName:l="table-of-contents__link",linkActiveClassName:s,minHeadingLevel:a,maxHeadingLevel:o,...c}=e,d=(0,x.L)(),u=a??d.tableOfContents.minHeadingLevel,m=o??d.tableOfContents.maxHeadingLevel,f=function(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:r}=e;return(0,i.useMemo)(()=>(function e(t){let{toc:n,minHeadingLevel:r,maxHeadingLevel:i}=t;return n.flatMap(t=>{var n;let l=e({toc:t.children,minHeadingLevel:r,maxHeadingLevel:i});return(n=t).level>=r&&n.level<=i?[{...t,children:l}]:l})})({toc:function(e){let t=e.map(e=>({...e,parentIndex:-1,children:[]})),n=Array(7).fill(-1);t.forEach((e,t)=>{let r=n.slice(2,e.level);e.parentIndex=Math.max(...r),n[e.level]=t});let r=[];return t.forEach(e=>{let{parentIndex:n,...i}=e;n>=0?t[n].children.push(i):r.push(i)}),r}(t),minHeadingLevel:n,maxHeadingLevel:r}),[t,n,r])}({toc:t,minHeadingLevel:u,maxHeadingLevel:m});return!function(e){let t=(0,i.useRef)(void 0),n=function(){let e=(0,i.useRef)(0),{navbar:{hideOnScroll:t}}=(0,x.L)();return(0,i.useEffect)(()=>{e.current=t?0:document.querySelector(".navbar").clientHeight},[t]),e}();(0,i.useEffect)(()=>{if(!e)return()=>{};let{linkClassName:r,linkActiveClassName:i,minHeadingLevel:l,maxHeadingLevel:s}=e;function a(){var e;let a=(e=r,Array.from(document.getElementsByClassName(e))),o=function(e,t){let{anchorTopOffset:n}=t,r=e.find(e=>p(e).top>=n);if(r){var i;return(i=p(r)).top>0&&i.bottom<window.innerHeight/2?r:e[e.indexOf(r)-1]??null}return e[e.length-1]??null}(function(e){let{minHeadingLevel:t,maxHeadingLevel:n}=e,r=[];for(let e=t;e<=n;e+=1)r.push(`h${e}.anchor`);return Array.from(document.querySelectorAll(r.join()))}({minHeadingLevel:l,maxHeadingLevel:s}),{anchorTopOffset:n.current}),c=a.find(e=>{var t;return o&&o.id===decodeURIComponent((t=e).href.substring(t.href.indexOf("#")+1))});a.forEach(e=>{var n;n=e,e===c?(t.current&&t.current!==n&&t.current.classList.remove(i),n.classList.add(i),t.current=n):n.classList.remove(i)})}return document.addEventListener("scroll",a),document.addEventListener("resize",a),a(),()=>{document.removeEventListener("scroll",a),document.removeEventListener("resize",a)}},[e,n])}((0,i.useMemo)(()=>{if(l&&s)return{linkClassName:l,linkActiveClassName:s,minHeadingLevel:u,maxHeadingLevel:m}},[l,s,u,m])),(0,r.jsx)(g,{toc:f,className:n,linkClassName:l,...c})}let b="tableOfContents_bqdL";function _(e){let{className:t,...n}=e;return(0,r.jsx)("div",{className:(0,l.Z)(b,"thin-scrollbar",t),children:(0,r.jsx)(v,{...n,linkClassName:"table-of-contents__link toc-highlight",linkActiveClassName:"table-of-contents__link--active"})
|