docstra 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.d.mts +1 -17
- package/dist/client/index.d.ts +1 -17
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/package.json +2 -2
package/dist/client/index.d.mts
CHANGED
|
@@ -21,8 +21,8 @@ interface DocstraConfig {
|
|
|
21
21
|
owner: string;
|
|
22
22
|
repo: string;
|
|
23
23
|
path: string;
|
|
24
|
+
branch: string;
|
|
24
25
|
};
|
|
25
|
-
contentDir?: string;
|
|
26
26
|
feedback?: {
|
|
27
27
|
enabled?: boolean;
|
|
28
28
|
formSyncFormID?: string;
|
|
@@ -40,22 +40,6 @@ interface DocstraConfig {
|
|
|
40
40
|
href: string;
|
|
41
41
|
}[];
|
|
42
42
|
};
|
|
43
|
-
sidebar?: {
|
|
44
|
-
links?: DocsLinkGroup[];
|
|
45
|
-
items?: SidebarItem[];
|
|
46
|
-
basePath?: string;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
interface DocsLinkItem {
|
|
50
|
-
name: string;
|
|
51
|
-
href: string;
|
|
52
|
-
icon?: string;
|
|
53
|
-
}
|
|
54
|
-
interface DocsLinkGroup {
|
|
55
|
-
section: string;
|
|
56
|
-
items: DocsLinkItem[];
|
|
57
|
-
collapsible?: boolean;
|
|
58
|
-
defaultOpen?: boolean;
|
|
59
43
|
}
|
|
60
44
|
type SidebarItem = {
|
|
61
45
|
type: 'page';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ interface DocstraConfig {
|
|
|
21
21
|
owner: string;
|
|
22
22
|
repo: string;
|
|
23
23
|
path: string;
|
|
24
|
+
branch: string;
|
|
24
25
|
};
|
|
25
|
-
contentDir?: string;
|
|
26
26
|
feedback?: {
|
|
27
27
|
enabled?: boolean;
|
|
28
28
|
formSyncFormID?: string;
|
|
@@ -40,22 +40,6 @@ interface DocstraConfig {
|
|
|
40
40
|
href: string;
|
|
41
41
|
}[];
|
|
42
42
|
};
|
|
43
|
-
sidebar?: {
|
|
44
|
-
links?: DocsLinkGroup[];
|
|
45
|
-
items?: SidebarItem[];
|
|
46
|
-
basePath?: string;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
interface DocsLinkItem {
|
|
50
|
-
name: string;
|
|
51
|
-
href: string;
|
|
52
|
-
icon?: string;
|
|
53
|
-
}
|
|
54
|
-
interface DocsLinkGroup {
|
|
55
|
-
section: string;
|
|
56
|
-
items: DocsLinkItem[];
|
|
57
|
-
collapsible?: boolean;
|
|
58
|
-
defaultOpen?: boolean;
|
|
59
43
|
}
|
|
60
44
|
type SidebarItem = {
|
|
61
45
|
type: 'page';
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Ke=Object.create;var U=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Xe=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},ie=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ye(t))!We.call(e,a)&&a!==r&&U(e,a,{get:()=>t[a],enumerable:!(o=Ve(t,a))||o.enumerable});return e};var D=(e,t,r)=>(r=e!=null?Ke(Qe(e)):{},ie(t||!e||!e.__esModule?U(r,"default",{value:e,enumerable:!0}):r,e)),Ze=e=>ie(U({},"__esModule",{value:!0}),e);var nt={};Xe(nt,{DocstraBody:()=>ot,DocstraCodeBlock:()=>at,DocstraHeader:()=>X,DocstraLayout:()=>rt,DocstraProvider:()=>Je,useDocstra:()=>u});module.exports=Ze(nt);var P=require("react"),he=require("react-toast-msg");var ue=require("lucide-react");var le=require("tailwind-merge"),ce=D(require("clsx"));function p(...e){return(0,le.twMerge)((0,ce.default)(e))}var I=require("react"),fe=D(require("fuse.js")),be=D(require("next/link")),ge=require("next/navigation");var L=require("react"),pe=require("react/jsx-runtime"),de=(0,L.createContext)(null);function me({children:e,initialSidebarItems:t}){let[r,o]=(0,L.useState)(t),[a,s]=(0,L.useState)(!1),[n,c]=(0,L.useState)(!1);return(0,pe.jsx)(de.Provider,{value:{openSidebar:a,setOpenSidebar:s,openSearchBox:n,setOpenSearchBox:c,sidebarItems:r,setSiderbarItems:o},children:e})}function O(){let e=(0,L.useContext)(de);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}var b=require("react/jsx-runtime");function xe(){let{openSearchBox:e,setOpenSearchBox:t}=O(),{page:r}=u(),[o,a]=(0,I.useState)(""),[s,n]=(0,I.useState)([]),c=(0,ge.useRouter)();(0,I.useEffect)(()=>{let i=h=>{h.ctrlKey&&h.key==="k"&&(h.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,I.useMemo)(()=>!r||r.length===0?null:new fe.default(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);(0,I.useEffect)(()=>{if(o&&m){let i=m.search(o);n(i.map(h=>h.item))}else o||n([])},[o,m]);let N=i=>{if(i.preventDefault(),o){let h=s[0];h&&(c.push(`/docs/${h.slug}`),a(""),t(!1))}};return(0,I.useEffect)(()=>{let i=h=>{h.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,b.jsx)("div",{onClick:()=>{t(!1),a("")},className:p("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,b.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,b.jsx)("form",{onSubmit:N,className:p("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ue.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,b.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,b.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,b.jsxs)("div",{className:p("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[s.map(i=>(0,b.jsxs)(be.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,b.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,b.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&s.length===0&&(0,b.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var $=require("react/jsx-runtime"),ye=(0,P.createContext)(null);function Je({children:e,docstraConfig:t,page:r}){let[o,a]=(0,P.useState)(!1),[s,n]=(0,P.useState)(!1),[c,m]=(0,P.useState)("npm");return(0,$.jsxs)(ye.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:c,setPackageManager:m,page:r},children:[(0,$.jsx)(he.ToastContainer,{}),(0,$.jsx)(xe,{}),e]})}function u(){let e=(0,P.useContext)(ye);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var q=require("lucide-react"),ve=require("react");var H=D(require("next/link"));var w=require("react/jsx-runtime");function X(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=O(),{docstraConfig:a}=u(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return(0,ve.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,w.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,w.jsx)(H.default,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,w.jsx)("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:p("h-9.5 w-auto",a.navbar?.logo?.className)})}),(0,w.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>(0,w.jsx)(H.default,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),(0,w.jsx)(H.default,{href:s||"https://github.com/sudhucodes/docstra",children:(0,w.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,w.jsx)("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,w.jsx)(q.XIcon,{className:"size-6.5"}):(0,w.jsx)(q.TextAlignEnd,{className:"size-6.5"})})]})}var _=require("lucide-react"),we=require("next/navigation");var je=D(require("lucide-react"));function Z(e){if(e)return je[e]}var J=D(require("next/link")),Se=require("react");var l=require("react/jsx-runtime");function et({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,s]=(0,Se.useState)(e.defaultOpen??!0),n=e.collapsible??!0,c=Z(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(J.default,{href:e.href,className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&(0,l.jsx)("div",{onClick:()=>n&&s(m=>!m),className:"pl-3",children:(0,l.jsx)(_.ChevronDownIcon,{className:p("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})})]}),(!n||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,N)=>(0,l.jsx)(Ne,{item:m,pathname:t,openSidebar:r,setOpenSidebar:o},`${m.type}-${N}`))})]})}function tt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=Z(e.icon);return(0,l.jsxs)(J.default,{href:e.href,onClick:()=>r&&o(!1),className:p("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.nav_title?e.nav_title:e.title})]})}function Ne({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(tt,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});case"section":return(0,l.jsx)(et,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});default:return null}}function ke(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=O(),a=(0,we.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:p("fixed inset-0 z-20 bg-black/50 md:hidden opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,l.jsxs)("aside",{className:p("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(e&&!1),o(!0)},children:[(0,l.jsx)(_.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),r.map((s,n)=>(0,l.jsx)(Ne,{item:s,pathname:a,openSidebar:e,setOpenSidebar:t},`${s.type}-${n}`))]})]})}var G=require("react/jsx-runtime");function rt({children:e,tree:t}){return(0,G.jsx)(me,{initialSidebarItems:t,children:(0,G.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,G.jsx)(ke,{}),e]})})}var Ce=require("next/navigation"),Ie=require("lucide-react"),j=D(require("next/link")),k=require("react/jsx-runtime");function De(){let t=(0,Ce.usePathname)().split("/").filter(Boolean),r=t.map((o,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:s,title:n}});return(0,k.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,k.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,k.jsx)("li",{children:(0,k.jsx)(j.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let s=a===r.length-1;return(0,k.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,k.jsx)(Ie.ChevronRight,{className:"w-4 h-4 text-gray-400"}),s?(0,k.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,k.jsx)(j.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var M=require("lucide-react"),Oe=require("next/navigation"),v=require("react");var x=require("react/jsx-runtime");function Pe(){let[e,t]=(0,v.useState)(null),[r,o]=(0,v.useState)("down"),[a,s]=(0,v.useState)(!1),[n,c]=(0,v.useState)(!1),{docstraConfig:m,page:N}=u(),i=N?.path,h=N?.tableOfContents||[],ne=(0,v.useRef)(0),Ue=(0,v.useRef)(null),He=(0,Oe.usePathname)(),qe=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,v.useEffect)(()=>{let f=()=>{let y=window.scrollY;o(y>ne.current?"down":"up"),s(y>100),ne.current=y};return window.addEventListener("scroll",f),()=>window.removeEventListener("scroll",f)},[]),(0,v.useEffect)(()=>{let f=document.querySelectorAll("h2[id], h3[id]"),y=new IntersectionObserver(E=>{if(n)return;let B=E.filter(z=>z.isIntersecting).sort((z,_e)=>z.boundingClientRect.top-_e.boundingClientRect.top);if(B.length>0){let z=r==="down"?B[0].target.id:B[B.length-1].target.id;t(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return f.forEach(E=>y.observe(E)),Ue.current=y,()=>y.disconnect()},[He,r,n]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&t(h[0]?.id)},[h]),(0,v.useEffect)(()=>{if(!e)return;let f=document.querySelector(".toc-scroll-container");if(!f)return;let y=f.querySelector(`a[href="#${e}"]`);if(!y)return;let E=f.getBoundingClientRect(),B=y.getBoundingClientRect();(B.top<E.top||B.bottom>E.bottom)&&y.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,v.useEffect)(()=>{if(!n)return;let f=setTimeout(()=>c(!1),800);return()=>clearTimeout(f)},[n]);let se=f=>{t(f),c(!0)};return(0,x.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,x.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,x.jsx)(M.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,x.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:h.map(f=>(0,x.jsxs)("li",{children:[(0,x.jsx)(Le,{heading:f,activeId:e,handleClick:se}),f.children.map(y=>(0,x.jsx)(Le,{heading:y,activeId:e,handleClick:se,className:"pl-8"},y.id))]},f.id))}),(0,x.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,x.jsxs)("a",{href:qe,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,x.jsx)(M.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,x.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,x.jsx)(M.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Le({heading:e,activeId:t,handleClick:r,className:o}){return(0,x.jsx)("a",{href:`#${e.id}`,className:p("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>r(e.id),children:e.text})}var A=require("react"),K=require("lucide-react");var R=require("react/jsx-runtime");function ee({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:s,value:n,readOnly:c=!1,className:m="",optional:N=!1}){return(0,R.jsxs)("div",{className:p("flex flex-col mt-4 w-full",m),children:[e&&(0,R.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,N&&(0,R.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?(0,R.jsx)("textarea",{id:o,name:o,className:p("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:r,required:a,onChange:s,rows:4,value:n,readOnly:c,maxLength:500}):(0,R.jsx)("input",{type:t,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:r,required:a,onChange:s,value:n,readOnly:c,maxLength:500})]})}var Be=require("lucide-react");var te=require("react/jsx-runtime");function re({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:s}){return(0,te.jsx)("button",{type:r,disabled:a,className:p("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:s,children:t?(0,te.jsx)(Be.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var V=require("formsync"),d=require("react/jsx-runtime");function Re(){let[e,t]=(0,A.useState)(null),{docstraConfig:r}=u(),[o,a]=(0,A.useState)(""),[s,n]=(0,A.useState)(!1),[c,m]=(0,A.useState)(null),N="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(re,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(K.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(K.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(V.FormSyncForm,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(ee,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(V.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),r?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${N}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function Te(){let{page:e}=u();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}var Y=require("lucide-react"),F=require("react");var T=require("react/jsx-runtime");function ze(){let{pageData:e}=u(),[t,r]=(0,F.useState)(!1),[o,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${o} and explain it to me.`;return(0,T.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,T.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),r(!0),setTimeout(()=>r(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?(0,T.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,T.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,T.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var Me=require("next/navigation"),oe=D(require("next/link")),Q=require("lucide-react");var S=require("react/jsx-runtime");function $e(e){let t=[];for(let r of e)r.type==="page"?t.push({name:r.title,href:r.href,icon:r.icon}):r.type==="section"&&t.push(...$e(r.children));return t}function Ge(){let e=(0,Me.usePathname)(),{docstraConfig:t}=u(),{sidebarItems:r}=O(),o=[];r&&r.length>0?o=$e(r):t?.sidebar?.links&&(o=t.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),s=a>0?o[a-1]:null,n=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?(0,S.jsxs)(oe.default,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(Q.ArrowLeftIcon,{className:"size-5 mr-2"}),s.name]})]}):(0,S.jsx)("div",{}),n?(0,S.jsxs)(oe.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,S.jsx)(Q.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var g=require("react/jsx-runtime");function ot({children:e}){let{docstraConfig:t,page:r}=u();return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(X,{}),(0,g.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,g.jsx)(De,{}),(0,g.jsx)("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),(0,g.jsx)("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),(0,g.jsx)(ze,{}),(0,g.jsx)("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&(0,g.jsx)(Re,{}),(0,g.jsx)(Te,{}),(0,g.jsx)(Ge,{})]}),(0,g.jsx)(Pe,{})]})}var W=require("lucide-react"),Ae=require("react");var Fe=require("react-toast-msg");var C=require("react/jsx-runtime");function ae(e){return typeof e=="string"?e:Array.isArray(e)?e.map(ae).join(""):e?.props?.children?ae(e.props.children):""}function at(e){let{title:t,copy:r,children:o}=e;if(typeof o=="string")return(0,C.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:o});let{packageManager:s,setPackageManager:n}=u(),[c,m]=(0,Ae.useState)(!1),N=()=>{if(!r)return;let i=ae(o);navigator.clipboard.writeText(i),m(!0),Fe.toast.success("Code copied to clipboard"),setTimeout(()=>m(!1),2e3)};return(0,C.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[(0,C.jsx)("span",{className:p("text-xs text-gray-400 px-4 py-3",!r&&"py-4"),children:t}),r&&(0,C.jsx)("button",{onClick:N,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:c?(0,C.jsx)(W.CheckIcon,{className:"size-4 text-green-600"}):(0,C.jsx)(W.CopyIcon,{className:"size-4"})})]}),(0,C.jsx)("div",{className:"p-4 scrollbar-x max-md:max-w-[calc(100vw-34px)] whitespace-pre overflow-x-auto text-sm leading-relaxed",children:o})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
|
|
1
|
+
"use strict";"use client";var Ke=Object.create;var M=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Xe=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},ie=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ye(t))!We.call(e,a)&&a!==r&&M(e,a,{get:()=>t[a],enumerable:!(o=Ve(t,a))||o.enumerable});return e};var D=(e,t,r)=>(r=e!=null?Ke(Qe(e)):{},ie(t||!e||!e.__esModule?M(r,"default",{value:e,enumerable:!0}):r,e)),Ze=e=>ie(M({},"__esModule",{value:!0}),e);var nt={};Xe(nt,{DocstraBody:()=>ot,DocstraCodeBlock:()=>at,DocstraHeader:()=>X,DocstraLayout:()=>rt,DocstraProvider:()=>Je,useDocstra:()=>f});module.exports=Ze(nt);var P=require("react"),he=require("react-toast-msg");var ue=require("lucide-react");var le=require("tailwind-merge"),ce=D(require("clsx"));function p(...e){return(0,le.twMerge)((0,ce.default)(e))}var I=require("react"),fe=D(require("fuse.js")),ge=D(require("next/link")),be=require("next/navigation");var L=require("react"),pe=require("react/jsx-runtime"),de=(0,L.createContext)(null);function me({children:e,initialSidebarItems:t}){let[r,o]=(0,L.useState)(t),[a,s]=(0,L.useState)(!1),[n,c]=(0,L.useState)(!1);return(0,pe.jsx)(de.Provider,{value:{openSidebar:a,setOpenSidebar:s,openSearchBox:n,setOpenSearchBox:c,sidebarItems:r,setSiderbarItems:o},children:e})}function O(){let e=(0,L.useContext)(de);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}var g=require("react/jsx-runtime");function xe(){let{openSearchBox:e,setOpenSearchBox:t}=O(),{page:r}=f(),[o,a]=(0,I.useState)(""),[s,n]=(0,I.useState)([]),c=(0,be.useRouter)();(0,I.useEffect)(()=>{let i=h=>{h.ctrlKey&&h.key==="k"&&(h.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,I.useMemo)(()=>!r||r.length===0?null:new fe.default(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);(0,I.useEffect)(()=>{if(o&&m){let i=m.search(o);n(i.map(h=>h.item))}else o||n([])},[o,m]);let N=i=>{if(i.preventDefault(),o){let h=s[0];h&&(c.push(`/docs/${h.slug}`),a(""),t(!1))}};return(0,I.useEffect)(()=>{let i=h=>{h.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,g.jsx)("div",{onClick:()=>{t(!1),a("")},className:p("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,g.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,g.jsx)("form",{onSubmit:N,className:p("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ue.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,g.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,g.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,g.jsxs)("div",{className:p("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[s.map(i=>(0,g.jsxs)(ge.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,g.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,g.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&s.length===0&&(0,g.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var G=require("react/jsx-runtime"),ye=(0,P.createContext)(null);function Je({children:e,docstraConfig:t,page:r}){let[o,a]=(0,P.useState)(!1),[s,n]=(0,P.useState)(!1),[c,m]=(0,P.useState)("npm");return(0,G.jsxs)(ye.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:c,setPackageManager:m,page:r},children:[(0,G.jsx)(he.ToastContainer,{}),(0,G.jsx)(xe,{}),e]})}function f(){let e=(0,P.useContext)(ye);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var q=require("lucide-react"),ve=require("react");var H=D(require("next/link"));var w=require("react/jsx-runtime");function X(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=O(),{docstraConfig:a}=f(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return(0,ve.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,w.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,w.jsx)(H.default,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,w.jsx)("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:p("h-9.5 w-auto",a.navbar?.logo?.className)})}),(0,w.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>(0,w.jsx)(H.default,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),(0,w.jsx)(H.default,{href:s||"https://github.com/sudhucodes/docstra",children:(0,w.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,w.jsx)("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,w.jsx)(q.XIcon,{className:"size-6.5"}):(0,w.jsx)(q.TextAlignEnd,{className:"size-6.5"})})]})}var _=require("lucide-react"),we=require("next/navigation");var je=D(require("lucide-react"));function Z(e){if(e)return je[e]}var J=D(require("next/link")),Se=require("react");var l=require("react/jsx-runtime");function et({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,s]=(0,Se.useState)(e.defaultOpen??!0),n=e.collapsible??!0,c=Z(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(J.default,{href:e.href,className:p("w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",e.href===t&&"bg-gray-100 text-gray-800"),children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&(0,l.jsx)("div",{onClick:()=>n&&s(m=>!m),className:"pl-3",children:(0,l.jsx)(_.ChevronDownIcon,{className:p("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})})]}),(!n||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,N)=>(0,l.jsx)(Ne,{item:m,pathname:t,openSidebar:r,setOpenSidebar:o},`${m.type}-${N}`))})]})}function tt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=Z(e.icon);return(0,l.jsxs)(J.default,{href:e.href,onClick:()=>r&&o(!1),className:p("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.nav_title?e.nav_title:e.title})]})}function Ne({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(tt,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});case"section":return(0,l.jsx)(et,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});default:return null}}function ke(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=O(),a=(0,we.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:p("fixed inset-0 z-20 bg-black/50 md:hidden opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,l.jsxs)("aside",{className:p("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(e&&!1),o(!0)},children:[(0,l.jsx)(_.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),r.map((s,n)=>(0,l.jsx)(Ne,{item:s,pathname:a,openSidebar:e,setOpenSidebar:t},`${s.type}-${n}`))]})]})}var F=require("react/jsx-runtime");function rt({children:e,tree:t}){return(0,F.jsx)(me,{initialSidebarItems:t,children:(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,F.jsx)(ke,{}),e]})})}var Ce=require("next/navigation"),Ie=require("lucide-react"),j=D(require("next/link")),k=require("react/jsx-runtime");function De(){let t=(0,Ce.usePathname)().split("/").filter(Boolean),r=t.map((o,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:s,title:n}});return(0,k.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,k.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,k.jsx)("li",{children:(0,k.jsx)(j.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let s=a===r.length-1;return(0,k.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,k.jsx)(Ie.ChevronRight,{className:"w-4 h-4 text-gray-400"}),s?(0,k.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,k.jsx)(j.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var $=require("lucide-react"),Oe=require("next/navigation"),v=require("react");var x=require("react/jsx-runtime");function Pe(){let[e,t]=(0,v.useState)(null),[r,o]=(0,v.useState)("down"),[a,s]=(0,v.useState)(!1),[n,c]=(0,v.useState)(!1),{docstraConfig:m,page:N}=f(),i=N?.path,h=N?.tableOfContents||[],ne=(0,v.useRef)(0),Me=(0,v.useRef)(null),He=(0,Oe.usePathname)(),qe=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,v.useEffect)(()=>{let u=()=>{let y=window.scrollY;o(y>ne.current?"down":"up"),s(y>100),ne.current=y};return window.addEventListener("scroll",u),()=>window.removeEventListener("scroll",u)},[]),(0,v.useEffect)(()=>{let u=document.querySelectorAll("h2[id], h3[id]"),y=new IntersectionObserver(E=>{if(n)return;let B=E.filter(z=>z.isIntersecting).sort((z,_e)=>z.boundingClientRect.top-_e.boundingClientRect.top);if(B.length>0){let z=r==="down"?B[0].target.id:B[B.length-1].target.id;t(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return u.forEach(E=>y.observe(E)),Me.current=y,()=>y.disconnect()},[He,r,n]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&t(h[0]?.id)},[h]),(0,v.useEffect)(()=>{if(!e)return;let u=document.querySelector(".toc-scroll-container");if(!u)return;let y=u.querySelector(`a[href="#${e}"]`);if(!y)return;let E=u.getBoundingClientRect(),B=y.getBoundingClientRect();(B.top<E.top||B.bottom>E.bottom)&&y.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,v.useEffect)(()=>{if(!n)return;let u=setTimeout(()=>c(!1),800);return()=>clearTimeout(u)},[n]);let se=u=>{t(u),c(!0)};return(0,x.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,x.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,x.jsx)($.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,x.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:h.map(u=>(0,x.jsxs)("li",{children:[(0,x.jsx)(Le,{heading:u,activeId:e,handleClick:se}),u.children.map(y=>(0,x.jsx)(Le,{heading:y,activeId:e,handleClick:se,className:"pl-8"},y.id))]},u.id))}),(0,x.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,x.jsxs)("a",{href:qe,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,x.jsx)($.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,x.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,x.jsx)($.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Le({heading:e,activeId:t,handleClick:r,className:o}){return(0,x.jsx)("a",{href:`#${e.id}`,className:p("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>r(e.id),children:e.text})}var A=require("react"),K=require("lucide-react");var R=require("react/jsx-runtime");function ee({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:s,value:n,readOnly:c=!1,className:m="",optional:N=!1}){return(0,R.jsxs)("div",{className:p("flex flex-col mt-4 w-full",m),children:[e&&(0,R.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,N&&(0,R.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?(0,R.jsx)("textarea",{id:o,name:o,className:p("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:r,required:a,onChange:s,rows:4,value:n,readOnly:c,maxLength:500}):(0,R.jsx)("input",{type:t,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:r,required:a,onChange:s,value:n,readOnly:c,maxLength:500})]})}var Be=require("lucide-react");var te=require("react/jsx-runtime");function re({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:s}){return(0,te.jsx)("button",{type:r,disabled:a,className:p("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:s,children:t?(0,te.jsx)(Be.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var V=require("formsync"),d=require("react/jsx-runtime");function Re(){let[e,t]=(0,A.useState)(null),{docstraConfig:r}=f(),[o,a]=(0,A.useState)(""),[s,n]=(0,A.useState)(!1),[c,m]=(0,A.useState)(null),N="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(re,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(K.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(K.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(V.FormSyncForm,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(ee,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(V.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),r?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${N}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function Te(){let{page:e}=f();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}var Y=require("lucide-react"),U=require("react");var T=require("react/jsx-runtime");function ze(){let{page:e}=f(),[t,r]=(0,U.useState)(!1),[o,a]=(0,U.useState)(null);(0,U.useEffect)(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${o} and explain it to me.`;return(0,T.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,T.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.raw||""),r(!0),setTimeout(()=>r(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?(0,T.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,T.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,T.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var $e=require("next/navigation"),oe=D(require("next/link")),Q=require("lucide-react");var S=require("react/jsx-runtime");function Ge(e){let t=[];for(let r of e)r.type==="page"?t.push({name:r.title,href:r.href,icon:r.icon}):r.type==="section"&&t.push(...Ge(r.children));return t}function Fe(){let e=(0,$e.usePathname)(),{docstraConfig:t}=f(),{sidebarItems:r}=O(),o=[];r&&r.length>0?o=Ge(r):t?.sidebar?.links&&(o=t.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),s=a>0?o[a-1]:null,n=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?(0,S.jsxs)(oe.default,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(Q.ArrowLeftIcon,{className:"size-5 mr-2"}),s.name]})]}):(0,S.jsx)("div",{}),n?(0,S.jsxs)(oe.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,S.jsx)(Q.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var b=require("react/jsx-runtime");function ot({children:e}){let{docstraConfig:t,page:r}=f();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(X,{}),(0,b.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose prose-headings:scroll-mt-28 max-w-none",children:[(0,b.jsx)(De,{}),(0,b.jsx)("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),(0,b.jsx)("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),(0,b.jsx)(ze,{}),(0,b.jsx)("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&(0,b.jsx)(Re,{}),(0,b.jsx)(Te,{}),(0,b.jsx)(Fe,{})]}),(0,b.jsx)(Pe,{})]})}var W=require("lucide-react"),Ae=require("react"),Ue=require("react-toast-msg");var C=require("react/jsx-runtime");function ae(e){return typeof e=="string"?e:Array.isArray(e)?e.map(ae).join(""):e?.props?.children?ae(e.props.children):""}function at(e){let{title:t,copy:r,children:o}=e;if(typeof o=="string")return(0,C.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:o});let[s,n]=(0,Ae.useState)(!1),c=e["data-language"],m=()=>{if(!r)return;let N=ae(o);navigator.clipboard.writeText(N),n(!0),Ue.toast.success("Code copied to clipboard"),setTimeout(()=>n(!1),2e3)};return(0,C.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[(0,C.jsx)("span",{className:p("text-xs text-gray-400 px-4 py-3",!r&&"py-4"),children:t||c}),r&&(0,C.jsx)("button",{onClick:m,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:s?(0,C.jsx)(W.CheckIcon,{className:"size-4 text-green-600"}):(0,C.jsx)(W.CopyIcon,{className:"size-4"})})]}),(0,C.jsx)("div",{className:"p-4 scrollbar-x max-md:max-w-[calc(100vw-34px)] whitespace-pre overflow-x-auto text-sm leading-relaxed",children:o})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as Ue,useContext as He,useState as A}from"react";import{ToastContainer as qe}from"react-toast-msg";import{SearchIcon as ze}from"lucide-react";import{twMerge as Pe}from"tailwind-merge";import Be from"clsx";function d(...e){return Pe(Be(e))}import{useEffect as G,useMemo as Me,useState as Z}from"react";import $e from"fuse.js";import Ge from"next/link";import{useRouter as Ae}from"next/navigation";import{createContext as Re,useContext as Te,useState as $}from"react";import{jsx as Ee}from"react/jsx-runtime";var W=Re(null);function X({children:e,initialSidebarItems:t}){let[o,r]=$(t),[a,s]=$(!1),[n,l]=$(!1);return Ee(W.Provider,{value:{openSidebar:a,setOpenSidebar:s,openSearchBox:n,setOpenSearchBox:l,sidebarItems:o,setSiderbarItems:r},children:e})}function v(){let e=Te(W);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}import{Fragment as Fe,jsx as w,jsxs as E}from"react/jsx-runtime";function J(){let{openSearchBox:e,setOpenSearchBox:t}=v(),{page:o}=m(),[r,a]=Z(""),[s,n]=Z([]),l=Ae();G(()=>{let i=f=>{f.ctrlKey&&f.key==="k"&&(f.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=Me(()=>!o||o.length===0?null:new $e(o,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[o]);G(()=>{if(r&&c){let i=c.search(r);n(i.map(f=>f.item))}else r||n([])},[r,c]);let x=i=>{if(i.preventDefault(),r){let f=s[0];f&&(l.push(`/docs/${f.slug}`),a(""),t(!1))}};return G(()=>{let i=f=>{f.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),w("div",{onClick:()=>{t(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:E("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[w("form",{onSubmit:x,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",r&&"rounded-b-none border-b-0"),children:e&&E(Fe,{children:[w(ze,{className:"size-5.5 mx-3 shrink-0"}),w("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:r,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),w("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),E("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",r&&"rounded-b-md border border-slate-200"),children:[s.map(i=>E(Ge,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[w("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),w("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),r&&s.length===0&&w("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as j,jsxs as _e}from"react/jsx-runtime";var ee=Ue(null);function Qt({children:e,docstraConfig:t,page:o}){let[r,a]=A(!1),[s,n]=A(!1),[l,c]=A("npm");return _e(ee.Provider,{value:{openSidebar:r,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:l,setPackageManager:c,page:o},children:[j(qe,{}),j(J,{}),e]})}function m(){let e=He(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ke,XIcon as Ve}from"lucide-react";import{useEffect as Ye}from"react";import F from"next/link";import{jsx as y,jsxs as te}from"react/jsx-runtime";function re(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:o,setOpenSearchBox:r}=v(),{docstraConfig:a}=m(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return Ye(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),te("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[y(F,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:y("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",a.navbar?.logo?.className)})}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>y(F,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),y(F,{href:s||"https://github.com/sudhucodes/docstra",children:y("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:y("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),y("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?y(Ve,{className:"size-6.5"}):y(Ke,{className:"size-6.5"})})]})}import{ChevronDownIcon as We,SearchIcon as Xe}from"lucide-react";import{usePathname as Ze}from"next/navigation";import*as Qe from"lucide-react";function U(e){if(e)return Qe[e]}import oe from"next/link";import{useState as Je}from"react";import{Fragment as tt,jsx as u,jsxs as S}from"react/jsx-runtime";function je({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){let[a,s]=Je(e.defaultOpen??!0),n=e.collapsible??!0,l=U(e.icon);return S("div",{children:[S(oe,{href:e.href,className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[S("span",{className:"flex items-center gap-2",children:[l&&u(l,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&u("div",{onClick:()=>n&&s(c=>!c),className:"pl-3",children:u(We,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})})]}),(!n||a)&&u("ul",{className:"mb-4 ml-2",children:e.children.map((c,x)=>u(ae,{item:c,pathname:t,openSidebar:o,setOpenSidebar:r},`${c.type}-${x}`))})]})}function et({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){let a=U(e.icon);return S(oe,{href:e.href,onClick:()=>o&&r(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&u(a,{className:"size-4"}),u("span",{children:e.nav_title?e.nav_title:e.title})]})}function ae({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){switch(e.type){case"page":return u(et,{item:e,pathname:t,openSidebar:o,setOpenSidebar:r});case"section":return u(je,{item:e,pathname:t,openSidebar:o,setOpenSidebar:r});default:return null}}function ne(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:o,setOpenSearchBox:r}=v(),a=Ze();return S(tt,{children:[u("div",{className:d("fixed inset-0 z-20 bg-black/50 md:hidden opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),S("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[S("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(e&&!1),r(!0)},children:[u(Xe,{className:"size-4.5"}),u("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[u("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),u("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),o.map((s,n)=>u(ae,{item:s,pathname:a,openSidebar:e,setOpenSidebar:t},`${s.type}-${n}`))]})]})}import{jsx as se,jsxs as rt}from"react/jsx-runtime";function xr({children:e,tree:t}){return se(X,{initialSidebarItems:t,children:rt("div",{className:"min-h-screen flex bg-white w-full",children:[se(ne,{}),e]})})}import{usePathname as ot}from"next/navigation";import{ChevronRight as at}from"lucide-react";import ie from"next/link";import{jsx as L,jsxs as le}from"react/jsx-runtime";function ce(){let t=ot().split("/").filter(Boolean),o=t.map((r,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=r.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:s,title:n}});return L("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:le("ol",{className:"flex items-center space-x-2",children:[L("li",{children:L(ie,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),o.map((r,a)=>{let s=a===o.length-1;return le("li",{className:"flex items-center space-x-2",children:[L(at,{className:"w-4 h-4 text-gray-400"}),s?L("span",{className:"text-gray-600 font-medium",children:r.title}):L(ie,{href:r.href,className:"hover:text-gray-700 font-medium transition-colors",children:r.title})]},r.href)})]})})}import{ArrowUpCircleIcon as nt,SquareArrowOutUpRightIcon as st,TextAlignStartIcon as it}from"lucide-react";import{usePathname as lt}from"next/navigation";import{useEffect as B,useRef as de,useState as z}from"react";import{jsx as N,jsxs as R}from"react/jsx-runtime";function pe(){let[e,t]=z(null),[o,r]=z("down"),[a,s]=z(!1),[n,l]=z(!1),{docstraConfig:c,page:x}=m(),i=x?.path,f=x?.tableOfContents||[],Y=de(0),Ie=de(null),De=lt(),Le=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;B(()=>{let p=()=>{let b=window.scrollY;r(b>Y.current?"down":"up"),s(b>100),Y.current=b};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),B(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(I=>{if(n)return;let k=I.filter(D=>D.isIntersecting).sort((D,Oe)=>D.boundingClientRect.top-Oe.boundingClientRect.top);if(k.length>0){let D=o==="down"?k[0].target.id:k[k.length-1].target.id;t(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(I=>b.observe(I)),Ie.current=b,()=>b.disconnect()},[De,o,n]),B(()=>{!(window.scrollY>100)&&t(f[0]?.id)},[f]),B(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let b=p.querySelector(`a[href="#${e}"]`);if(!b)return;let I=p.getBoundingClientRect(),k=b.getBoundingClientRect();(k.top<I.top||k.bottom>I.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),B(()=>{if(!n)return;let p=setTimeout(()=>l(!1),800);return()=>clearTimeout(p)},[n]);let Q=p=>{t(p),l(!0)};return R("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[R("p",{className:"flex items-center gap-2 mb-5",children:[N(it,{className:"size-4"}),"On this page"]}),N("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:f.map(p=>R("li",{children:[N(me,{heading:p,activeId:e,handleClick:Q}),p.children.map(b=>N(me,{heading:b,activeId:e,handleClick:Q,className:"pl-8"},b.id))]},p.id))}),N("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&R("a",{href:Le,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",N(st,{className:"size-4"})]}),a&&R("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",N(nt,{className:"size-4"})]})]})}function me({heading:e,activeId:t,handleClick:o,className:r}){return N("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",r,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>o(e.id),children:e.text})}import{useState as M}from"react";import{ThumbsUp as dt,ThumbsDown as mt}from"lucide-react";import{jsx as H,jsxs as ue}from"react/jsx-runtime";function q({label:e,type:t,placeholder:o="",id:r,required:a=!1,onChange:s,value:n,readOnly:l=!1,className:c="",optional:x=!1}){return ue("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&ue("label",{htmlFor:r,className:"font-medium w-max cursor-pointer",children:[e,x&&H("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?H("textarea",{id:r,name:r,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:o,required:a,onChange:s,rows:4,value:n,readOnly:l,maxLength:500}):H("input",{type:t,id:r,name:r,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:o,required:a,onChange:s,value:n,readOnly:l,maxLength:500})]})}import{Loader2Icon as ct}from"lucide-react";import{jsx as fe}from"react/jsx-runtime";function _({label:e,loading:t,type:o="submit",className:r="",disabled:a=!1,onClick:s}){return fe("button",{type:o,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",r),"aria-label":e,onClick:s,children:t?fe(ct,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as pt,FormSyncForm as ut}from"formsync";import{Fragment as be,jsx as g,jsxs as C}from"react/jsx-runtime";function ge(){let[e,t]=M(null),{docstraConfig:o}=m(),[r,a]=M(""),[s,n]=M(!1),[l,c]=M(null),x="https://github.com/"+o?.editOnGithub?.owner+"/"+o?.editOnGithub?.repo;return g("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?C(be,{children:[g("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),g(_,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):C(be,{children:[g("p",{className:"font-medium",children:"How is this guide?"}),C("div",{className:"flex gap-2",children:[C("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[g(dt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),C("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[g(mt,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&C(ut,{className:"flex flex-col gap-2",formId:o?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{c(i.message)},children:[g(q,{value:r,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&g("p",{className:"text-red-500",children:l}),g("input",{type:"hidden",name:"opinion",value:e}),g("input",{type:"hidden",name:"page",value:window.location.href}),g("input",{type:"hidden",name:"_redirect",value:window.location.href}),g(pt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),o?.feedback?.watermark!==!1&&C("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",g("a",{href:`https://www.formsync.app?utm_source=${x}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as ft}from"react/jsx-runtime";function xe(){let{page:e}=m();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return ft("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}import{CheckIcon as bt,CopyIcon as gt}from"lucide-react";import{useEffect as xt,useState as he}from"react";import{jsx as K,jsxs as ye}from"react/jsx-runtime";function ve(){let{pageData:e}=m(),[t,o]=he(!1),[r,a]=he(null);xt(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${r} and explain it to me.`;return ye("div",{className:"flex items-center gap-3 mt-6",children:[ye("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),o(!0),setTimeout(()=>o(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?K(bt,{className:"size-3.5"}):K(gt,{className:"size-3.5"}),"Copy Markdown"]}),K("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as ht}from"next/navigation";import we from"next/link";import{ArrowLeftIcon as yt,ArrowRightIcon as vt}from"lucide-react";import{jsx as O,jsxs as T}from"react/jsx-runtime";function Se(e){let t=[];for(let o of e)o.type==="page"?t.push({name:o.title,href:o.href,icon:o.icon}):o.type==="section"&&t.push(...Se(o.children));return t}function Ne(){let e=ht(),{docstraConfig:t}=m(),{sidebarItems:o}=v(),r=[];o&&o.length>0?r=Se(o):t?.sidebar?.links&&(r=t.sidebar.links.flatMap(l=>l.items));let a=r.findIndex(l=>l.href===e),s=a>0?r[a-1]:null,n=a<r.length-1?r[a+1]:null;return T("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?T(we,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[O("span",{className:"text-gray-500",children:"Previous"}),T("p",{className:"flex items-center font-medium",children:[O(yt,{className:"size-5 mr-2"}),s.name]})]}):O("div",{}),n?T(we,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[O("span",{className:"text-gray-500",children:"Next"}),T("p",{className:"flex items-center font-medium",children:[n.name,O(vt,{className:"size-5 ml-2"})]})]}):O("div",{})]})}import{Fragment as wt,jsx as h,jsxs as ke}from"react/jsx-runtime";function xo({children:e}){let{docstraConfig:t,page:o}=m();return ke(wt,{children:[h(re,{}),ke("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[h(ce,{}),h("h1",{className:"text-3xl font-bold",children:o?.metadata?.title}),h("p",{className:"my-4 text-gray-500",children:o?.metadata?.description}),h(ve,{}),h("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&h(ge,{}),h(xe,{}),h(Ne,{})]}),h(pe,{})]})}import{CheckIcon as St,CopyIcon as Nt}from"lucide-react";import{useState as kt}from"react";import{toast as Ct}from"react-toast-msg";import{jsx as P,jsxs as Ce}from"react/jsx-runtime";function V(e){return typeof e=="string"?e:Array.isArray(e)?e.map(V).join(""):e?.props?.children?V(e.props.children):""}function Co(e){let{title:t,copy:o,children:r}=e;if(typeof r=="string")return P("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:r});let{packageManager:s,setPackageManager:n}=m(),[l,c]=kt(!1),x=()=>{if(!o)return;let i=V(r);navigator.clipboard.writeText(i),c(!0),Ct.success("Code copied to clipboard"),setTimeout(()=>c(!1),2e3)};return Ce("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[Ce("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[P("span",{className:d("text-xs text-gray-400 px-4 py-3",!o&&"py-4"),children:t}),o&&P("button",{onClick:x,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:l?P(St,{className:"size-4 text-green-600"}):P(Nt,{className:"size-4"})})]}),P("div",{className:"p-4 scrollbar-x max-md:max-w-[calc(100vw-34px)] whitespace-pre overflow-x-auto text-sm leading-relaxed",children:r})]})}export{xo as DocstraBody,Co as DocstraCodeBlock,re as DocstraHeader,xr as DocstraLayout,Qt as DocstraProvider,m as useDocstra};
|
|
1
|
+
"use client";import{createContext as Me,useContext as He,useState as A}from"react";import{ToastContainer as qe}from"react-toast-msg";import{SearchIcon as ze}from"lucide-react";import{twMerge as Pe}from"tailwind-merge";import Be from"clsx";function d(...e){return Pe(Be(e))}import{useEffect as F,useMemo as $e,useState as Z}from"react";import Ge from"fuse.js";import Fe from"next/link";import{useRouter as Ae}from"next/navigation";import{createContext as Re,useContext as Te,useState as G}from"react";import{jsx as Ee}from"react/jsx-runtime";var W=Re(null);function X({children:e,initialSidebarItems:t}){let[o,r]=G(t),[a,s]=G(!1),[n,l]=G(!1);return Ee(W.Provider,{value:{openSidebar:a,setOpenSidebar:s,openSearchBox:n,setOpenSearchBox:l,sidebarItems:o,setSiderbarItems:r},children:e})}function v(){let e=Te(W);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}import{Fragment as Ue,jsx as w,jsxs as E}from"react/jsx-runtime";function J(){let{openSearchBox:e,setOpenSearchBox:t}=v(),{page:o}=p(),[r,a]=Z(""),[s,n]=Z([]),l=Ae();F(()=>{let i=f=>{f.ctrlKey&&f.key==="k"&&(f.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=$e(()=>!o||o.length===0?null:new Ge(o,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[o]);F(()=>{if(r&&c){let i=c.search(r);n(i.map(f=>f.item))}else r||n([])},[r,c]);let x=i=>{if(i.preventDefault(),r){let f=s[0];f&&(l.push(`/docs/${f.slug}`),a(""),t(!1))}};return F(()=>{let i=f=>{f.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),w("div",{onClick:()=>{t(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:E("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[w("form",{onSubmit:x,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",r&&"rounded-b-none border-b-0"),children:e&&E(Ue,{children:[w(ze,{className:"size-5.5 mx-3 shrink-0"}),w("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:r,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),w("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),E("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",r&&"rounded-b-md border border-slate-200"),children:[s.map(i=>E(Fe,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[w("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),w("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),r&&s.length===0&&w("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as j,jsxs as _e}from"react/jsx-runtime";var ee=Me(null);function Qt({children:e,docstraConfig:t,page:o}){let[r,a]=A(!1),[s,n]=A(!1),[l,c]=A("npm");return _e(ee.Provider,{value:{openSidebar:r,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:l,setPackageManager:c,page:o},children:[j(qe,{}),j(J,{}),e]})}function p(){let e=He(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ke,XIcon as Ve}from"lucide-react";import{useEffect as Ye}from"react";import U from"next/link";import{jsx as y,jsxs as te}from"react/jsx-runtime";function re(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:o,setOpenSearchBox:r}=v(),{docstraConfig:a}=p(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return Ye(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),te("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[y(U,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:y("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",a.navbar?.logo?.className)})}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>y(U,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),y(U,{href:s||"https://github.com/sudhucodes/docstra",children:y("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:y("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),y("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?y(Ve,{className:"size-6.5"}):y(Ke,{className:"size-6.5"})})]})}import{ChevronDownIcon as We,SearchIcon as Xe}from"lucide-react";import{usePathname as Ze}from"next/navigation";import*as Qe from"lucide-react";function M(e){if(e)return Qe[e]}import oe from"next/link";import{useState as Je}from"react";import{Fragment as tt,jsx as u,jsxs as S}from"react/jsx-runtime";function je({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){let[a,s]=Je(e.defaultOpen??!0),n=e.collapsible??!0,l=M(e.icon);return S("div",{children:[S(oe,{href:e.href,className:d("w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",e.href===t&&"bg-gray-100 text-gray-800"),children:[S("span",{className:"flex items-center gap-2",children:[l&&u(l,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&u("div",{onClick:()=>n&&s(c=>!c),className:"pl-3",children:u(We,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})})]}),(!n||a)&&u("ul",{className:"mb-4 ml-2",children:e.children.map((c,x)=>u(ae,{item:c,pathname:t,openSidebar:o,setOpenSidebar:r},`${c.type}-${x}`))})]})}function et({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){let a=M(e.icon);return S(oe,{href:e.href,onClick:()=>o&&r(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&u(a,{className:"size-4"}),u("span",{children:e.nav_title?e.nav_title:e.title})]})}function ae({item:e,pathname:t,openSidebar:o,setOpenSidebar:r}){switch(e.type){case"page":return u(et,{item:e,pathname:t,openSidebar:o,setOpenSidebar:r});case"section":return u(je,{item:e,pathname:t,openSidebar:o,setOpenSidebar:r});default:return null}}function ne(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:o,setOpenSearchBox:r}=v(),a=Ze();return S(tt,{children:[u("div",{className:d("fixed inset-0 z-20 bg-black/50 md:hidden opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),S("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",e?"top-32":"top-full"),children:[S("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(e&&!1),r(!0)},children:[u(Xe,{className:"size-4.5"}),u("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[u("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),u("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),o.map((s,n)=>u(ae,{item:s,pathname:a,openSidebar:e,setOpenSidebar:t},`${s.type}-${n}`))]})]})}import{jsx as se,jsxs as rt}from"react/jsx-runtime";function xr({children:e,tree:t}){return se(X,{initialSidebarItems:t,children:rt("div",{className:"min-h-screen flex bg-white w-full",children:[se(ne,{}),e]})})}import{usePathname as ot}from"next/navigation";import{ChevronRight as at}from"lucide-react";import ie from"next/link";import{jsx as L,jsxs as le}from"react/jsx-runtime";function ce(){let t=ot().split("/").filter(Boolean),o=t.map((r,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=r.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:s,title:n}});return L("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:le("ol",{className:"flex items-center space-x-2",children:[L("li",{children:L(ie,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),o.map((r,a)=>{let s=a===o.length-1;return le("li",{className:"flex items-center space-x-2",children:[L(at,{className:"w-4 h-4 text-gray-400"}),s?L("span",{className:"text-gray-600 font-medium",children:r.title}):L(ie,{href:r.href,className:"hover:text-gray-700 font-medium transition-colors",children:r.title})]},r.href)})]})})}import{ArrowUpCircleIcon as nt,SquareArrowOutUpRightIcon as st,TextAlignStartIcon as it}from"lucide-react";import{usePathname as lt}from"next/navigation";import{useEffect as B,useRef as de,useState as z}from"react";import{jsx as N,jsxs as R}from"react/jsx-runtime";function pe(){let[e,t]=z(null),[o,r]=z("down"),[a,s]=z(!1),[n,l]=z(!1),{docstraConfig:c,page:x}=p(),i=x?.path,f=x?.tableOfContents||[],Y=de(0),Ie=de(null),De=lt(),Le=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;B(()=>{let m=()=>{let g=window.scrollY;r(g>Y.current?"down":"up"),s(g>100),Y.current=g};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),B(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),g=new IntersectionObserver(I=>{if(n)return;let k=I.filter(D=>D.isIntersecting).sort((D,Oe)=>D.boundingClientRect.top-Oe.boundingClientRect.top);if(k.length>0){let D=o==="down"?k[0].target.id:k[k.length-1].target.id;t(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(I=>g.observe(I)),Ie.current=g,()=>g.disconnect()},[De,o,n]),B(()=>{!(window.scrollY>100)&&t(f[0]?.id)},[f]),B(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let g=m.querySelector(`a[href="#${e}"]`);if(!g)return;let I=m.getBoundingClientRect(),k=g.getBoundingClientRect();(k.top<I.top||k.bottom>I.bottom)&&g.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),B(()=>{if(!n)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[n]);let Q=m=>{t(m),l(!0)};return R("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[R("p",{className:"flex items-center gap-2 mb-5",children:[N(it,{className:"size-4"}),"On this page"]}),N("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:f.map(m=>R("li",{children:[N(me,{heading:m,activeId:e,handleClick:Q}),m.children.map(g=>N(me,{heading:g,activeId:e,handleClick:Q,className:"pl-8"},g.id))]},m.id))}),N("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&R("a",{href:Le,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",N(st,{className:"size-4"})]}),a&&R("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",N(nt,{className:"size-4"})]})]})}function me({heading:e,activeId:t,handleClick:o,className:r}){return N("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",r,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>o(e.id),children:e.text})}import{useState as $}from"react";import{ThumbsUp as dt,ThumbsDown as mt}from"lucide-react";import{jsx as H,jsxs as ue}from"react/jsx-runtime";function q({label:e,type:t,placeholder:o="",id:r,required:a=!1,onChange:s,value:n,readOnly:l=!1,className:c="",optional:x=!1}){return ue("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&ue("label",{htmlFor:r,className:"font-medium w-max cursor-pointer",children:[e,x&&H("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?H("textarea",{id:r,name:r,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:o,required:a,onChange:s,rows:4,value:n,readOnly:l,maxLength:500}):H("input",{type:t,id:r,name:r,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:o,required:a,onChange:s,value:n,readOnly:l,maxLength:500})]})}import{Loader2Icon as ct}from"lucide-react";import{jsx as fe}from"react/jsx-runtime";function _({label:e,loading:t,type:o="submit",className:r="",disabled:a=!1,onClick:s}){return fe("button",{type:o,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",r),"aria-label":e,onClick:s,children:t?fe(ct,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as pt,FormSyncForm as ut}from"formsync";import{Fragment as ge,jsx as b,jsxs as C}from"react/jsx-runtime";function be(){let[e,t]=$(null),{docstraConfig:o}=p(),[r,a]=$(""),[s,n]=$(!1),[l,c]=$(null),x="https://github.com/"+o?.editOnGithub?.owner+"/"+o?.editOnGithub?.repo;return b("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?C(ge,{children:[b("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),b(_,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):C(ge,{children:[b("p",{className:"font-medium",children:"How is this guide?"}),C("div",{className:"flex gap-2",children:[C("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[b(dt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),C("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[b(mt,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&C(ut,{className:"flex flex-col gap-2",formId:o?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{c(i.message)},children:[b(q,{value:r,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&b("p",{className:"text-red-500",children:l}),b("input",{type:"hidden",name:"opinion",value:e}),b("input",{type:"hidden",name:"page",value:window.location.href}),b("input",{type:"hidden",name:"_redirect",value:window.location.href}),b(pt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),o?.feedback?.watermark!==!1&&C("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",b("a",{href:`https://www.formsync.app?utm_source=${x}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as ft}from"react/jsx-runtime";function xe(){let{page:e}=p();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return ft("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}import{CheckIcon as gt,CopyIcon as bt}from"lucide-react";import{useEffect as xt,useState as he}from"react";import{jsx as K,jsxs as ye}from"react/jsx-runtime";function ve(){let{page:e}=p(),[t,o]=he(!1),[r,a]=he(null);xt(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${r} and explain it to me.`;return ye("div",{className:"flex items-center gap-3 mt-6",children:[ye("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.raw||""),o(!0),setTimeout(()=>o(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?K(gt,{className:"size-3.5"}):K(bt,{className:"size-3.5"}),"Copy Markdown"]}),K("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as ht}from"next/navigation";import we from"next/link";import{ArrowLeftIcon as yt,ArrowRightIcon as vt}from"lucide-react";import{jsx as O,jsxs as T}from"react/jsx-runtime";function Se(e){let t=[];for(let o of e)o.type==="page"?t.push({name:o.title,href:o.href,icon:o.icon}):o.type==="section"&&t.push(...Se(o.children));return t}function Ne(){let e=ht(),{docstraConfig:t}=p(),{sidebarItems:o}=v(),r=[];o&&o.length>0?r=Se(o):t?.sidebar?.links&&(r=t.sidebar.links.flatMap(l=>l.items));let a=r.findIndex(l=>l.href===e),s=a>0?r[a-1]:null,n=a<r.length-1?r[a+1]:null;return T("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?T(we,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[O("span",{className:"text-gray-500",children:"Previous"}),T("p",{className:"flex items-center font-medium",children:[O(yt,{className:"size-5 mr-2"}),s.name]})]}):O("div",{}),n?T(we,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[O("span",{className:"text-gray-500",children:"Next"}),T("p",{className:"flex items-center font-medium",children:[n.name,O(vt,{className:"size-5 ml-2"})]})]}):O("div",{})]})}import{Fragment as wt,jsx as h,jsxs as ke}from"react/jsx-runtime";function xo({children:e}){let{docstraConfig:t,page:o}=p();return ke(wt,{children:[h(re,{}),ke("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose prose-headings:scroll-mt-28 max-w-none",children:[h(ce,{}),h("h1",{className:"text-3xl font-bold",children:o?.metadata?.title}),h("p",{className:"my-4 text-gray-500",children:o?.metadata?.description}),h(ve,{}),h("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&h(be,{}),h(xe,{}),h(Ne,{})]}),h(pe,{})]})}import{CheckIcon as St,CopyIcon as Nt}from"lucide-react";import{useState as kt}from"react";import{toast as Ct}from"react-toast-msg";import{jsx as P,jsxs as Ce}from"react/jsx-runtime";function V(e){return typeof e=="string"?e:Array.isArray(e)?e.map(V).join(""):e?.props?.children?V(e.props.children):""}function ko(e){let{title:t,copy:o,children:r}=e;if(typeof r=="string")return P("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:r});let[s,n]=kt(!1),l=e["data-language"],c=()=>{if(!o)return;let x=V(r);navigator.clipboard.writeText(x),n(!0),Ct.success("Code copied to clipboard"),setTimeout(()=>n(!1),2e3)};return Ce("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[Ce("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[P("span",{className:d("text-xs text-gray-400 px-4 py-3",!o&&"py-4"),children:t||l}),o&&P("button",{onClick:c,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:s?P(St,{className:"size-4 text-green-600"}):P(Nt,{className:"size-4"})})]}),P("div",{className:"p-4 scrollbar-x max-md:max-w-[calc(100vw-34px)] whitespace-pre overflow-x-auto text-sm leading-relaxed",children:r})]})}export{xo as DocstraBody,ko as DocstraCodeBlock,re as DocstraHeader,xr as DocstraLayout,Qt as DocstraProvider,p as useDocstra};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstra",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "The Modern Documentation Framework for Next.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"lucide-react": "^0.554.0",
|
|
40
40
|
"react-toast-msg": "^2.5.5",
|
|
41
41
|
"tailwind-merge": "^3.4.0",
|
|
42
|
-
"docstra-mdx": "0.0.
|
|
42
|
+
"docstra-mdx": "0.0.8"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"next": ">=16.0.0",
|