docstra 1.8.4 → 1.8.6
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 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/server/index.d.mts +2 -3
- package/dist/server/index.d.ts +2 -3
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/{types-B_0cE1Pd.d.mts → types-CuNOikJf.d.mts} +11 -4
- package/dist/{types-B_0cE1Pd.d.ts → types-CuNOikJf.d.ts} +11 -4
- package/package.json +1 -1
package/dist/client/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
|
-
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-
|
|
3
|
+
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-CuNOikJf.mjs';
|
|
4
4
|
|
|
5
5
|
declare function DocstraProvider({ children, docstraConfig, docs, pageData: initialPageData, slug }: {
|
|
6
6
|
children: React$1.ReactNode;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
|
-
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-
|
|
3
|
+
import { D as DocstraConfig, p as pageDataContent, a as DocstraContextType } from '../types-CuNOikJf.js';
|
|
4
4
|
|
|
5
5
|
declare function DocstraProvider({ children, docstraConfig, docs, pageData: initialPageData, slug }: {
|
|
6
6
|
children: React$1.ReactNode;
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Ge=Object.create;var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ae(t))!$e.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(a=Fe(t,o))||a.enumerable});return e};var L=(e,t,r)=>(r=e!=null?Ge(He(e)):{},se(t||!e||!e.__esModule?U(r,"default",{value:e,enumerable:!0}):r,e)),qe=e=>se(U({},"__esModule",{value:!0}),e);var We={};Me(We,{DocstraBody:()=>Qe,DocstraCodeBlock:()=>_e,DocstraHeader:()=>Ke,DocstraPage:()=>Ye,DocstraProvider:()=>Ue,useDocstra:()=>d});module.exports=qe(We);var O=require("react"),fe=require("react-toast-msg");var ce=require("lucide-react");var ie=require("tailwind-merge"),le=L(require("clsx"));function u(...e){return(0,ie.twMerge)((0,le.default)(e))}var D=require("react"),me=L(require("fuse.js")),de=L(require("next/link")),pe=require("next/navigation"),h=require("react/jsx-runtime");function ue(){let{openSearchBox:e,setOpenSearchBox:t,docs:r}=d(),[a,o]=(0,D.useState)(""),[n,s]=(0,D.useState)([]),c=(0,pe.useRouter)();(0,D.useEffect)(()=>{let i=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let g=(0,D.useMemo)(()=>!r||r.length===0?null:new me.default(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);(0,D.useEffect)(()=>{if(a&&g){let i=g.search(a);s(i.map(p=>p.item))}else a||s([])},[a,g]);let N=i=>{if(i.preventDefault(),a){let p=n[0];p&&(c.push(`/docs/${p.slug}`),o(""),t(!1))}};return(0,D.useEffect)(()=>{let i=p=>{p.key==="Escape"&&(t(!1),o(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{t(!1),o("")},className:u("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,h.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,h.jsx)("form",{onSubmit:N,className:u("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",a&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ce.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.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:a,onChange:i=>o(i.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:u("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",a&&"rounded-b-md border border-slate-200"),children:[n.map(i=>(0,h.jsxs)(de.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),o("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),a&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var G=require("react/jsx-runtime"),ge=(0,O.createContext)(null);function Ue({children:e,docstraConfig:t,docs:r,pageData:a,slug:o}){let n=a||(()=>{let i=Array.isArray(o)?o.length===0?"index":o.join("/"):o||"index";return r.find(p=>p.slug===i)})(),[s,c]=(0,O.useState)(!1),[g,N]=(0,O.useState)(!1);return(0,G.jsxs)(ge.Provider,{value:{openSidebar:s,setOpenSidebar:c,docstraConfig:t,openSearchBox:g,setOpenSearchBox:N,pageData:n,docs:r},children:[(0,G.jsx)(fe.ToastContainer,{}),(0,G.jsx)(ue,{}),e]})}function d(){let e=(0,O.useContext)(ge);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var V=require("lucide-react"),he=require("react");var K=L(require("next/link")),y=require("react/jsx-runtime");function Ke(){let{openSidebar:e,setOpenSidebar:t,docstraConfig:r}=d(),a="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;(0,he.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]);let o=r.navbar?.logo,n=s=>!!s&&"src"in s;return(0,y.jsxs)("header",{className:"sticky 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,y.jsx)(K.default,{href:o?.link||"/",className:u("hover:opacity-80 transition",o?.className),children:!o||n(o)?(0,y.jsx)("img",{src:n(o)?o.src:"/logo.png",alt:n(o)?o.alt:"Logo",className:u("h-9.5 w-auto",o?.className)}):typeof o.component=="function"?(0,y.jsx)(o.component,{}):o.component}),(0,y.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[r.navbar?.links?.map(s=>(0,y.jsx)(K.default,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),(0,y.jsx)(K.default,{href:a||"https://github.com/sudhucodes/docstra",children:(0,y.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,y.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,y.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,y.jsx)(V.XIcon,{className:"size-6.5"}):(0,y.jsx)(V.TextAlignEnd,{className:"size-6.5"})})]})}var xe=require("lucide-react"),ye=require("next/navigation");var Ve=L(require("lucide-react"));function be(e){if(e)return Ve[e]}var ve=L(require("next/link")),m=require("react/jsx-runtime");function we(){let{openSidebar:e,setOpenSidebar:t,docstraConfig:r,setOpenSearchBox:a}=d(),o=(0,ye.usePathname)();return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:u("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,m.jsxs)("aside",{className:u("sticky 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,m.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),a(!0)},children:[(0,m.jsx)(xe.SearchIcon,{className:"size-4.5"}),(0,m.jsx)("p",{children:"Search"}),(0,m.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,m.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,m.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),r.sidebar?.links?.map(n=>(0,m.jsxs)("div",{children:[(0,m.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),(0,m.jsx)("ul",{className:"mb-4",children:n.items.map(s=>{let c=be(s.icon);return(0,m.jsx)("li",{children:(0,m.jsxs)(ve.default,{href:s.href,onNavigate:()=>e&&t(!1),className:u("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",o===s.href&&"bg-gray-100 text-gray-800"),children:[c&&(0,m.jsx)(c,{className:"size-4"}),(0,m.jsx)("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}var B=require("lucide-react"),ke=require("next/navigation"),v=require("react");var b=require("react/jsx-runtime");function Ce(){let[e,t]=(0,v.useState)(null),[r,a]=(0,v.useState)("down"),[o,n]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),{docstraConfig:g,pageData:N}=d(),i=N?.path,p=N?.data?.tableOfContents||[],$=(0,v.useRef)(0),Z=(0,v.useRef)(null),M=(0,ke.usePathname)(),ee=`${"https://github.com/"+g?.editOnGithub?.owner+"/"+g?.editOnGithub?.repo}/edit/main/${g?.editOnGithub?.path}/${i}`;(0,v.useEffect)(()=>{let f=()=>{let x=window.scrollY;a(x>$.current?"down":"up"),n(x>100),$.current=x};return window.addEventListener("scroll",f),()=>window.removeEventListener("scroll",f)},[]),(0,v.useEffect)(()=>{let f=document.querySelectorAll("h2[id], h3[id]"),x=new IntersectionObserver(E=>{if(s)return;let I=E.filter(z=>z.isIntersecting).sort((z,Be)=>z.boundingClientRect.top-Be.boundingClientRect.top);if(I.length>0){let z=r==="down"?I[0].target.id:I[I.length-1].target.id;t(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return f.forEach(E=>x.observe(E)),Z.current=x,()=>x.disconnect()},[M,r,s]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&t(p[0]?.id)},[p]),(0,v.useEffect)(()=>{if(!e)return;let f=document.querySelector(".toc-scroll-container");if(!f)return;let x=f.querySelector(`a[href="#${e}"]`);if(!x)return;let E=f.getBoundingClientRect(),I=x.getBoundingClientRect();(I.top<E.top||I.bottom>E.bottom)&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,v.useEffect)(()=>{if(!s)return;let f=setTimeout(()=>c(!1),800);return()=>clearTimeout(f)},[s]);let q=f=>{t(f),c(!0)};return(0,b.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,b.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,b.jsx)(B.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,b.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:p.map(f=>(0,b.jsxs)("li",{children:[(0,b.jsx)(Ne,{heading:f,activeId:e,handleClick:q}),f.children.map(x=>(0,b.jsx)(Ne,{heading:x,activeId:e,handleClick:q,className:"pl-8"},x.id))]},f.id))}),(0,b.jsx)("hr",{className:"my-6 border-gray-200"}),g.editOnGithub&&(0,b.jsxs)("a",{href:ee,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,b.jsx)(B.SquareArrowOutUpRightIcon,{className:"size-4"})]}),o&&(0,b.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,b.jsx)(B.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Ne({heading:e,activeId:t,handleClick:r,className:a}){return(0,b.jsx)("a",{href:`#${e.id}`,className:u("border-l border-gray-200 block py-1.5 pl-4 transition-colors",a,{"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 F=require("react/jsx-runtime");function Ye({children:e,toc:t=!0,sidebar:r=!0}){return(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[r&&(0,F.jsx)(we,{}),e,t&&(0,F.jsx)(Ce,{})]})}var De=require("next/navigation"),Se=require("lucide-react"),te=L(require("next/link")),C=require("react/jsx-runtime");function Le(){let t=(0,De.usePathname)().split("/").filter(Boolean),r=t.map((a,o)=>{let n="/"+t.slice(0,o+1).join("/"),s=a.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:n,title:s}});return(0,C.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500",children:(0,C.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,C.jsx)("li",{children:(0,C.jsx)(te.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((a,o)=>{let n=o===r.length-1;return(0,C.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,C.jsx)(Se.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,C.jsx)("span",{className:"text-gray-600 font-medium",children:a.title}):(0,C.jsx)(te.default,{href:a.href,className:"hover:text-gray-700 font-medium transition-colors",children:a.title})]},a.href)})]})})}var Y=require("lucide-react"),A=require("react");var P=require("react/jsx-runtime");function Ie(){let{pageData:e}=d(),[t,r]=(0,A.useState)(!1),[a,o]=(0,A.useState)(null);(0,A.useEffect)(()=>{o(window.location.href)},[]);let n=`Read from this URL: ${a} and explain it to me.`;return(0,P.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,P.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,P.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,P.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,P.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex 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 S=require("react/jsx-runtime");function Oe(){let{pageData:e}=d(),t=e?.data?.metadata?.title,r=e?.data?.metadata?.description;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("h1",{className:"text-3xl font-bold",children:t}),(0,S.jsx)("p",{className:"my-4 text-gray-500",children:r}),(0,S.jsx)(Ie,{}),(0,S.jsx)("hr",{className:"my-10 border-gray-200"})]})}var H=require("react"),Q=require("lucide-react");var R=require("react/jsx-runtime");function re({label:e,type:t,placeholder:r="",id:a,required:o=!1,onChange:n,value:s,readOnly:c=!1,className:g="",optional:N=!1}){return(0,R.jsxs)("div",{className:u("flex flex-col mt-4 w-full",g),children:[e&&(0,R.jsxs)("label",{htmlFor:a,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:a,name:a,className:u("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",g),placeholder:r,required:o,onChange:n,rows:4,value:s,readOnly:c}):(0,R.jsx)("input",{type:t,id:a,name:a,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:o,onChange:n,value:s,readOnly:c})]})}var Pe=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:t,type:r="submit",className:a="",disabled:o=!1,onClick:n}){return(0,oe.jsx)("button",{type:r,disabled:o,className:u("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",a),"aria-label":e,onClick:n,children:t?(0,oe.jsx)(Pe.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var _=require("formsync"),l=require("react/jsx-runtime");function Re(){let[e,t]=(0,H.useState)(null),{docstraConfig:r}=d(),[a,o]=(0,H.useState)(""),[n,s]=(0,H.useState)(!1),[c,g]=(0,H.useState)(null),N="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return(0,l.jsx)("div",{className:"border-y border-gray-200 mt-20 py-10 space-y-4",children:n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,l.jsx)(ae,{onClick:()=>{s(!1),t(null),o("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.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,l.jsx)(Q.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,l.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,l.jsx)(Q.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,l.jsxs)(_.FormSyncForm,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),t(null),o("")},onSubmitError:i=>{g(i.message)},children:[(0,l.jsx)(re,{value:a,id:"message",onChange:i=>o(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,l.jsx)("p",{className:"text-red-500",children:c}),(0,l.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,l.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,l.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,l.jsx)(_.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,l.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,l.jsx)("a",{href:`https://www.formsync.app?utm_source=${N}`,className:"text-gray-800",children:"FormSync"})]})]})]})})}var Te=require("next/navigation"),ne=L(require("next/link")),W=require("lucide-react");var k=require("react/jsx-runtime");function Ee(){let e=(0,Te.usePathname)(),{docstraConfig:t}=d(),r=t?.sidebar?.links?.flatMap(s=>s.items),a=r.findIndex(s=>s.href===e),o=a>0?r[a-1]:null,n=a<r.length-1?r[a+1]:null;return(0,k.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[o?(0,k.jsxs)(ne.default,{href:o.href,className:"flex flex-col 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,k.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[(0,k.jsx)(W.ArrowLeftIcon,{className:"size-5 mr-2"}),o.name]})]}):(0,k.jsx)("div",{}),n?(0,k.jsxs)(ne.default,{href:n.href,className:"flex flex-col 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,k.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,k.jsx)(W.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,k.jsx)("div",{})]})}var T=require("react/jsx-runtime");function Qe({children:e}){let{docstraConfig:t}=d();return(0,T.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 max-w-full text-base/7",children:[(0,T.jsx)(Le,{}),(0,T.jsx)(Oe,{}),e,t?.feedback?.enabled&&(0,T.jsx)(Re,{}),(0,T.jsx)(Ee,{})]})}var X=require("lucide-react"),J=require("prism-react-renderer"),ze=require("react"),w=require("react/jsx-runtime");function _e(e){let{filename:t,children:r,className:a}=e,o=!a?.includes("language-"),n=typeof r=="string"?r:r?.props?.children||"";if(o)return(0,w.jsx)("code",{className:"px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,c]=(0,ze.useState)(!1),N=a?.match(/language-([\w-]+)/)?.[1]??"txt";return(0,w.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[(0,w.jsxs)("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[(0,w.jsx)("span",{className:"text-xs text-gray-400 p-4",children:t||N}),(0,w.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(n.trim()),c(!0),setTimeout(()=>c(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:s?(0,w.jsx)(X.CheckIcon,{className:"size-4"}):(0,w.jsx)(X.CopyIcon,{className:"size-4"})})]}),(0,w.jsx)(J.Highlight,{theme:J.themes.vsLight,code:n.trim(),language:N,children:({tokens:p,getLineProps:$,getTokenProps:Z})=>(0,w.jsx)("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:p.map((M,j)=>(0,w.jsxs)("div",{...$({line:M}),children:[(0,w.jsx)("span",{className:"text-slate-500 mr-4 select-none",children:j+1}),M.map((ee,q)=>(0,w.jsx)("span",{...Z({token:ee})},q))]},j))})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraPage,DocstraProvider,useDocstra});
|
|
1
|
+
"use strict";"use client";var Ge=Object.create;var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ae(t))!$e.call(e,a)&&a!==r&&U(e,a,{get:()=>t[a],enumerable:!(o=Fe(t,a))||o.enumerable});return e};var L=(e,t,r)=>(r=e!=null?Ge(He(e)):{},se(t||!e||!e.__esModule?U(r,"default",{value:e,enumerable:!0}):r,e)),qe=e=>se(U({},"__esModule",{value:!0}),e);var We={};Me(We,{DocstraBody:()=>Qe,DocstraCodeBlock:()=>_e,DocstraHeader:()=>Ke,DocstraPage:()=>Ye,DocstraProvider:()=>Ue,useDocstra:()=>d});module.exports=qe(We);var O=require("react"),fe=require("react-toast-msg");var ce=require("lucide-react");var ie=require("tailwind-merge"),le=L(require("clsx"));function u(...e){return(0,ie.twMerge)((0,le.default)(e))}var D=require("react"),me=L(require("fuse.js")),de=L(require("next/link")),pe=require("next/navigation"),h=require("react/jsx-runtime");function ue(){let{openSearchBox:e,setOpenSearchBox:t,docs:r}=d(),[o,a]=(0,D.useState)(""),[s,n]=(0,D.useState)([]),c=(0,pe.useRouter)();(0,D.useEffect)(()=>{let i=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let g=(0,D.useMemo)(()=>!r||r.length===0?null:new me.default(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);(0,D.useEffect)(()=>{if(o&&g){let i=g.search(o);n(i.map(p=>p.item))}else o||n([])},[o,g]);let N=i=>{if(i.preventDefault(),o){let p=s[0];p&&(c.push(`/docs/${p.slug}`),a(""),t(!1))}};return(0,D.useEffect)(()=>{let i=p=>{p.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{t(!1),a("")},className:u("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,h.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,h.jsx)("form",{onSubmit:N,className:u("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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ce.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.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,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:u("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,h.jsxs)(de.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,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&s.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var G=require("react/jsx-runtime"),ge=(0,O.createContext)(null);function Ue({children:e,docstraConfig:t,docs:r,pageData:o,slug:a}){let s=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return r.find(p=>p.slug===i)})(),[n,c]=(0,O.useState)(!1),[g,N]=(0,O.useState)(!1);return(0,G.jsxs)(ge.Provider,{value:{openSidebar:n,setOpenSidebar:c,docstraConfig:t,openSearchBox:g,setOpenSearchBox:N,pageData:s,docs:r},children:[(0,G.jsx)(fe.ToastContainer,{}),(0,G.jsx)(ue,{}),e]})}function d(){let e=(0,O.useContext)(ge);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var V=require("lucide-react"),he=require("react");var K=L(require("next/link")),b=require("react/jsx-runtime");function Ke(){let{openSidebar:e,setOpenSidebar:t,docstraConfig:r}=d(),o="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;(0,he.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]);let a=r.navbar?.logo;function s(n){if(!n)return(0,b.jsx)("img",{src:"/logo.png",alt:"Logo",className:"h-9.5 w-auto"});switch(n.type){case"image":return(0,b.jsx)("img",{src:n.src,alt:n.alt,className:u("h-9.5 w-auto",n.className)});case"component":{let c=n.component;return(0,b.jsx)(c,{className:n.className})}case"node":return n.node}}return(0,b.jsxs)("header",{className:"sticky 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,b.jsx)(K.default,{href:a?.link||"/",className:u("hover:opacity-80 transition",a?.className),children:s(a)}),(0,b.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[r.navbar?.links?.map(n=>(0,b.jsx)(K.default,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),(0,b.jsx)(K.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,b.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,b.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,b.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,b.jsx)(V.XIcon,{className:"size-6.5"}):(0,b.jsx)(V.TextAlignEnd,{className:"size-6.5"})})]})}var xe=require("lucide-react"),ye=require("next/navigation");var Ve=L(require("lucide-react"));function be(e){if(e)return Ve[e]}var ve=L(require("next/link")),m=require("react/jsx-runtime");function we(){let{openSidebar:e,setOpenSidebar:t,docstraConfig:r,setOpenSearchBox:o}=d(),a=(0,ye.usePathname)();return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:u("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,m.jsxs)("aside",{className:u("sticky 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,m.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,m.jsx)(xe.SearchIcon,{className:"size-4.5"}),(0,m.jsx)("p",{children:"Search"}),(0,m.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,m.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,m.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),r.sidebar?.links?.map(s=>(0,m.jsxs)("div",{children:[(0,m.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:s.section}),(0,m.jsx)("ul",{className:"mb-4",children:s.items.map(n=>{let c=be(n.icon);return(0,m.jsx)("li",{children:(0,m.jsxs)(ve.default,{href:n.href,onNavigate:()=>e&&t(!1),className:u("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===n.href&&"bg-gray-100 text-gray-800"),children:[c&&(0,m.jsx)(c,{className:"size-4"}),(0,m.jsx)("span",{children:n.name})]})},n.href)})})]},s.section))]})]})}var B=require("lucide-react"),ke=require("next/navigation"),v=require("react");var x=require("react/jsx-runtime");function Ce(){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:g,pageData:N}=d(),i=N?.path,p=N?.data?.tableOfContents||[],$=(0,v.useRef)(0),Z=(0,v.useRef)(null),M=(0,ke.usePathname)(),ee=`${"https://github.com/"+g?.editOnGithub?.owner+"/"+g?.editOnGithub?.repo}/edit/main/${g?.editOnGithub?.path}/${i}`;(0,v.useEffect)(()=>{let f=()=>{let y=window.scrollY;o(y>$.current?"down":"up"),s(y>100),$.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 I=E.filter(z=>z.isIntersecting).sort((z,Be)=>z.boundingClientRect.top-Be.boundingClientRect.top);if(I.length>0){let z=r==="down"?I[0].target.id:I[I.length-1].target.id;t(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return f.forEach(E=>y.observe(E)),Z.current=y,()=>y.disconnect()},[M,r,n]),(0,v.useEffect)(()=>{!(window.scrollY>100)&&t(p[0]?.id)},[p]),(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(),I=y.getBoundingClientRect();(I.top<E.top||I.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 q=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)(B.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:p.map(f=>(0,x.jsxs)("li",{children:[(0,x.jsx)(Ne,{heading:f,activeId:e,handleClick:q}),f.children.map(y=>(0,x.jsx)(Ne,{heading:y,activeId:e,handleClick:q,className:"pl-8"},y.id))]},f.id))}),(0,x.jsx)("hr",{className:"my-6 border-gray-200"}),g.editOnGithub&&(0,x.jsxs)("a",{href:ee,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)(B.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)(B.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Ne({heading:e,activeId:t,handleClick:r,className:o}){return(0,x.jsx)("a",{href:`#${e.id}`,className:u("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 F=require("react/jsx-runtime");function Ye({children:e,toc:t=!0,sidebar:r=!0}){return(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[r&&(0,F.jsx)(we,{}),e,t&&(0,F.jsx)(Ce,{})]})}var De=require("next/navigation"),Se=require("lucide-react"),te=L(require("next/link")),C=require("react/jsx-runtime");function Le(){let t=(0,De.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,C.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500",children:(0,C.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,C.jsx)("li",{children:(0,C.jsx)(te.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,C.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,C.jsx)(Se.ChevronRight,{className:"w-4 h-4 text-gray-400"}),s?(0,C.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,C.jsx)(te.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var Y=require("lucide-react"),A=require("react");var P=require("react/jsx-runtime");function Ie(){let{pageData:e}=d(),[t,r]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${o} and explain it to me.`;return(0,P.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,P.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,P.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,P.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,P.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex 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 S=require("react/jsx-runtime");function Oe(){let{pageData:e}=d(),t=e?.data?.metadata?.title,r=e?.data?.metadata?.description;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("h1",{className:"text-3xl font-bold",children:t}),(0,S.jsx)("p",{className:"my-4 text-gray-500",children:r}),(0,S.jsx)(Ie,{}),(0,S.jsx)("hr",{className:"my-10 border-gray-200"})]})}var H=require("react"),Q=require("lucide-react");var R=require("react/jsx-runtime");function re({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:s,value:n,readOnly:c=!1,className:g="",optional:N=!1}){return(0,R.jsxs)("div",{className:u("flex flex-col mt-4 w-full",g),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:u("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",g),placeholder:r,required:a,onChange:s,rows:4,value:n,readOnly:c}):(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})]})}var Pe=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:s}){return(0,oe.jsx)("button",{type:r,disabled:a,className:u("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,oe.jsx)(Pe.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var _=require("formsync"),l=require("react/jsx-runtime");function Re(){let[e,t]=(0,H.useState)(null),{docstraConfig:r}=d(),[o,a]=(0,H.useState)(""),[s,n]=(0,H.useState)(!1),[c,g]=(0,H.useState)(null),N="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return(0,l.jsx)("div",{className:"border-y border-gray-200 mt-20 py-10 space-y-4",children:s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,l.jsx)(ae,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.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,l.jsx)(Q.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,l.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,l.jsx)(Q.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,l.jsxs)(_.FormSyncForm,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{g(i.message)},children:[(0,l.jsx)(re,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,l.jsx)("p",{className:"text-red-500",children:c}),(0,l.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,l.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,l.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,l.jsx)(_.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,l.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,l.jsx)("a",{href:`https://www.formsync.app?utm_source=${N}`,className:"text-gray-800",children:"FormSync"})]})]})]})})}var Te=require("next/navigation"),ne=L(require("next/link")),W=require("lucide-react");var k=require("react/jsx-runtime");function Ee(){let e=(0,Te.usePathname)(),{docstraConfig:t}=d(),r=t?.sidebar?.links?.flatMap(n=>n.items),o=r.findIndex(n=>n.href===e),a=o>0?r[o-1]:null,s=o<r.length-1?r[o+1]:null;return(0,k.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[a?(0,k.jsxs)(ne.default,{href:a.href,className:"flex flex-col 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,k.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[(0,k.jsx)(W.ArrowLeftIcon,{className:"size-5 mr-2"}),a.name]})]}):(0,k.jsx)("div",{}),s?(0,k.jsxs)(ne.default,{href:s.href,className:"flex flex-col 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,k.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,k.jsx)(W.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,k.jsx)("div",{})]})}var T=require("react/jsx-runtime");function Qe({children:e}){let{docstraConfig:t}=d();return(0,T.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 max-w-full text-base/7",children:[(0,T.jsx)(Le,{}),(0,T.jsx)(Oe,{}),e,t?.feedback?.enabled&&(0,T.jsx)(Re,{}),(0,T.jsx)(Ee,{})]})}var X=require("lucide-react"),J=require("prism-react-renderer"),ze=require("react"),w=require("react/jsx-runtime");function _e(e){let{filename:t,children:r,className:o}=e,a=!o?.includes("language-"),s=typeof r=="string"?r:r?.props?.children||"";if(a)return(0,w.jsx)("code",{className:"px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:s});let[n,c]=(0,ze.useState)(!1),N=o?.match(/language-([\w-]+)/)?.[1]??"txt";return(0,w.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[(0,w.jsxs)("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[(0,w.jsx)("span",{className:"text-xs text-gray-400 p-4",children:t||N}),(0,w.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(s.trim()),c(!0),setTimeout(()=>c(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:n?(0,w.jsx)(X.CheckIcon,{className:"size-4"}):(0,w.jsx)(X.CopyIcon,{className:"size-4"})})]}),(0,w.jsx)(J.Highlight,{theme:J.themes.vsLight,code:s.trim(),language:N,children:({tokens:p,getLineProps:$,getTokenProps:Z})=>(0,w.jsx)("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:p.map((M,j)=>(0,w.jsxs)("div",{...$({line:M}),children:[(0,w.jsx)("span",{className:"text-slate-500 mr-4 select-none",children:j+1}),M.map((ee,q)=>(0,w.jsx)("span",{...Z({token:ee})},q))]},j))})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraPage,DocstraProvider,useDocstra});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as Pe,useContext as Re,useState as Z}from"react";import{ToastContainer as Te}from"react-toast-msg";import{SearchIcon as Ce}from"lucide-react";import{twMerge as Ne}from"tailwind-merge";import ke from"clsx";function m(...e){return Ne(ke(e))}import{useEffect as U,useMemo as De,useState as X}from"react";import Se from"fuse.js";import Le from"next/link";import{useRouter as Ie}from"next/navigation";import{Fragment as Oe,jsx as v,jsxs as B}from"react/jsx-runtime";function J(){let{openSearchBox:e,setOpenSearchBox:a,docs:t}=d(),[o,r]=X(""),[n,s]=X([]),l=Ie();U(()=>{let i=c=>{c.ctrlKey&&c.key==="k"&&(c.preventDefault(),a(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let u=De(()=>!t||t.length===0?null:new Se(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);U(()=>{if(o&&u){let i=u.search(o);s(i.map(c=>c.item))}else o||s([])},[o,u]);let g=i=>{if(i.preventDefault(),o){let c=n[0];c&&(l.push(`/docs/${c.slug}`),r(""),a(!1))}};return U(()=>{let i=c=>{c.key==="Escape"&&(a(!1),r(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),v("div",{onClick:()=>{a(!1),r("")},className:m("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:B("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[v("form",{onSubmit:g,className:m("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&&B(Oe,{children:[v(Ce,{className:"size-5.5 mx-3 shrink-0"}),v("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=>r(i.target.value),name:"searchQuery",required:!0}),v("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),B("div",{className:m("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:[n.map(i=>B(Le,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{a(!1),r("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[v("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),v("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&v("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as j,jsxs as Ee}from"react/jsx-runtime";var ee=Pe(null);function Rt({children:e,docstraConfig:a,docs:t,pageData:o,slug:r}){let n=o||(()=>{let i=Array.isArray(r)?r.length===0?"index":r.join("/"):r||"index";return t.find(c=>c.slug===i)})(),[s,l]=Z(!1),[u,g]=Z(!1);return Ee(ee.Provider,{value:{openSidebar:s,setOpenSidebar:l,docstraConfig:a,openSearchBox:u,setOpenSearchBox:g,pageData:n,docs:t},children:[j(Te,{}),j(J,{}),e]})}function d(){let e=Re(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as ze,XIcon as Be}from"lucide-react";import{useEffect as Ge}from"react";import K from"next/link";import{jsx as b,jsxs as te}from"react/jsx-runtime";function Ht(){let{openSidebar:e,setOpenSidebar:a,docstraConfig:t}=d(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;Ge(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]);let r=t.navbar?.logo,n=s=>!!s&&"src"in s;return te("header",{className:"sticky 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:[b(K,{href:r?.link||"/",className:m("hover:opacity-80 transition",r?.className),children:!r||n(r)?b("img",{src:n(r)?r.src:"/logo.png",alt:n(r)?r.alt:"Logo",className:m("h-9.5 w-auto",r?.className)}):typeof r.component=="function"?b(r.component,{}):r.component}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(s=>b(K,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),b(K,{href:o||"https://github.com/sudhucodes/docstra",children:b("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:b("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"})})})]}),b("button",{onClick:()=>a(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?b(Be,{className:"size-6.5"}):b(ze,{className:"size-6.5"})})]})}import{SearchIcon as Ae}from"lucide-react";import{usePathname as He}from"next/navigation";import*as Fe from"lucide-react";function re(e){if(e)return Fe[e]}import $e from"next/link";import{Fragment as Me,jsx as x,jsxs as S}from"react/jsx-runtime";function oe(){let{openSidebar:e,setOpenSidebar:a,docstraConfig:t,setOpenSearchBox:o}=d(),r=He();return S(Me,{children:[x("div",{className:m("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>a(!1)}),S("aside",{className:m("sticky 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:()=>{a(e&&!1),o(!0)},children:[x(Ae,{className:"size-4.5"}),x("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[x("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),x("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>S("div",{children:[x("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),x("ul",{className:"mb-4",children:n.items.map(s=>{let l=re(s.icon);return x("li",{children:S($e,{href:s.href,onNavigate:()=>e&&a(!1),className:m("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===s.href&&"bg-gray-100 text-gray-800"),children:[l&&x(l,{className:"size-4"}),x("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}import{ArrowUpCircleIcon as qe,SquareArrowOutUpRightIcon as Ue,TextAlignStartIcon as Ke}from"lucide-react";import{usePathname as Ve}from"next/navigation";import{useEffect as O,useRef as ae,useState as G}from"react";import{jsx as w,jsxs as P}from"react/jsx-runtime";function se(){let[e,a]=G(null),[t,o]=G("down"),[r,n]=G(!1),[s,l]=G(!1),{docstraConfig:u,pageData:g}=d(),i=g?.path,c=g?.data?.tableOfContents||[],T=ae(0),$=ae(null),E=Ve(),q=`${"https://github.com/"+u?.editOnGithub?.owner+"/"+u?.editOnGithub?.repo}/edit/main/${u?.editOnGithub?.path}/${i}`;O(()=>{let p=()=>{let f=window.scrollY;o(f>T.current?"down":"up"),n(f>100),T.current=f};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),O(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),f=new IntersectionObserver(C=>{if(s)return;let N=C.filter(D=>D.isIntersecting).sort((D,we)=>D.boundingClientRect.top-we.boundingClientRect.top);if(N.length>0){let D=t==="down"?N[0].target.id:N[N.length-1].target.id;a(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(C=>f.observe(C)),$.current=f,()=>f.disconnect()},[E,t,s]),O(()=>{!(window.scrollY>100)&&a(c[0]?.id)},[c]),O(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let f=p.querySelector(`a[href="#${e}"]`);if(!f)return;let C=p.getBoundingClientRect(),N=f.getBoundingClientRect();(N.top<C.top||N.bottom>C.bottom)&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),O(()=>{if(!s)return;let p=setTimeout(()=>l(!1),800);return()=>clearTimeout(p)},[s]);let z=p=>{a(p),l(!0)};return P("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:[P("p",{className:"flex items-center gap-2 mb-5",children:[w(Ke,{className:"size-4"}),"On this page"]}),w("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:c.map(p=>P("li",{children:[w(ne,{heading:p,activeId:e,handleClick:z}),p.children.map(f=>w(ne,{heading:f,activeId:e,handleClick:z,className:"pl-8"},f.id))]},p.id))}),w("hr",{className:"my-6 border-gray-200"}),u.editOnGithub&&P("a",{href:q,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",w(Ue,{className:"size-4"})]}),r&&P("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",w(qe,{className:"size-4"})]})]})}function ne({heading:e,activeId:a,handleClick:t,className:o}){return w("a",{href:`#${e.id}`,className:m("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":a===e.id,"hover:text-gray-800 hover:border-gray-400":a!==e.id}),onClick:()=>t(e.id),children:e.text})}import{jsx as ie,jsxs as Ye}from"react/jsx-runtime";function sr({children:e,toc:a=!0,sidebar:t=!0}){return Ye("div",{className:"min-h-screen flex bg-white w-full",children:[t&&ie(oe,{}),e,a&&ie(se,{})]})}import{usePathname as Qe}from"next/navigation";import{ChevronRight as _e}from"lucide-react";import le from"next/link";import{jsx as L,jsxs as ce}from"react/jsx-runtime";function me(){let a=Qe().split("/").filter(Boolean),t=a.map((o,r)=>{let n="/"+a.slice(0,r+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:n,title:s}});return L("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500",children:ce("ol",{className:"flex items-center space-x-2",children:[L("li",{children:L(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,r)=>{let n=r===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[L(_e,{className:"w-4 h-4 text-gray-400"}),n?L("span",{className:"text-gray-600 font-medium",children:o.title}):L(le,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{CheckIcon as We,CopyIcon as Xe}from"lucide-react";import{useEffect as Je,useState as de}from"react";import{jsx as V,jsxs as pe}from"react/jsx-runtime";function ue(){let{pageData:e}=d(),[a,t]=de(!1),[o,r]=de(null);Je(()=>{r(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return pe("div",{className:"flex items-center gap-3 mt-6",children:[pe("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!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:[a?V(We,{className:"size-3.5"}):V(Xe,{className:"size-3.5"}),"Copy Markdown"]}),V("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex 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{Fragment as Ze,jsx as F,jsxs as je}from"react/jsx-runtime";function fe(){let{pageData:e}=d(),a=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return je(Ze,{children:[F("h1",{className:"text-3xl font-bold",children:a}),F("p",{className:"my-4 text-gray-500",children:t}),F(ue,{}),F("hr",{className:"my-10 border-gray-200"})]})}import{useState as A}from"react";import{ThumbsUp as tt,ThumbsDown as rt}from"lucide-react";import{jsx as Y,jsxs as ge}from"react/jsx-runtime";function Q({label:e,type:a,placeholder:t="",id:o,required:r=!1,onChange:n,value:s,readOnly:l=!1,className:u="",optional:g=!1}){return ge("div",{className:m("flex flex-col mt-4 w-full",u),children:[e&&ge("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,g&&Y("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),a==="textarea"?Y("textarea",{id:o,name:o,className:m("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",u),placeholder:t,required:r,onChange:n,rows:4,value:s,readOnly:l}):Y("input",{type:a,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:t,required:r,onChange:n,value:s,readOnly:l})]})}import{Loader2Icon as et}from"lucide-react";import{jsx as he}from"react/jsx-runtime";function _({label:e,loading:a,type:t="submit",className:o="",disabled:r=!1,onClick:n}){return he("button",{type:t,disabled:r,className:m("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:n,children:a?he(et,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as ot,FormSyncForm as at}from"formsync";import{Fragment as be,jsx as h,jsxs as k}from"react/jsx-runtime";function xe(){let[e,a]=A(null),{docstraConfig:t}=d(),[o,r]=A(""),[n,s]=A(!1),[l,u]=A(null),g="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-20 py-10 space-y-4",children:n?k(be,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(_,{onClick:()=>{s(!1),a(null),r("")},label:"Submit Again",className:"w-max text-sm"})]}):k(be,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),k("div",{className:"flex gap-2",children:[k("button",{onClick:()=>a("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:[h(tt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),k("button",{onClick:()=>a("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:[h(rt,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&k(at,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),a(null),r("")},onSubmitError:i=>{u(i.message)},children:[h(Q,{value:o,id:"message",onChange:i=>r(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&h("p",{className:"text-red-500",children:l}),h("input",{type:"hidden",name:"opinion",value:e}),h("input",{type:"hidden",name:"page",value:window.location.href}),h("input",{type:"hidden",name:"_redirect",value:window.location.href}),h(ot,{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"}),t?.feedback?.watermark!==!1&&k("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${g}`,className:"text-gray-800",children:"FormSync"})]})]})]})})}import{usePathname as nt}from"next/navigation";import ye from"next/link";import{ArrowLeftIcon as st,ArrowRightIcon as it}from"lucide-react";import{jsx as I,jsxs as R}from"react/jsx-runtime";function ve(){let e=nt(),{docstraConfig:a}=d(),t=a?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),r=o>0?t[o-1]:null,n=o<t.length-1?t[o+1]:null;return R("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[r?R(ye,{href:r.href,className:"flex flex-col 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:[I("span",{className:"text-gray-500",children:"Previous"}),R("p",{className:"flex items-center font-medium",children:[I(st,{className:"size-5 mr-2"}),r.name]})]}):I("div",{}),n?R(ye,{href:n.href,className:"flex flex-col 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:[I("span",{className:"text-gray-500",children:"Next"}),R("p",{className:"flex items-center font-medium",children:[n.name,I(it,{className:"size-5 ml-2"})]})]}):I("div",{})]})}import{jsx as H,jsxs as lt}from"react/jsx-runtime";function Wr({children:e}){let{docstraConfig:a}=d();return lt("main",{className:"flex-1 px-4 md:px-8 py-10 max-w-full text-base/7",children:[H(me,{}),H(fe,{}),e,a?.feedback?.enabled&&H(xe,{}),H(ve,{})]})}import{CheckIcon as ct,CopyIcon as mt}from"lucide-react";import{Highlight as dt,themes as pt}from"prism-react-renderer";import{useState as ut}from"react";import{jsx as y,jsxs as W}from"react/jsx-runtime";function to(e){let{filename:a,children:t,className:o}=e,r=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(r)return y("code",{className:"px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,l]=ut(!1),g=o?.match(/language-([\w-]+)/)?.[1]??"txt";return W("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[W("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[y("span",{className:"text-xs text-gray-400 p-4",children:a||g}),y("button",{onClick:()=>{navigator.clipboard.writeText(n.trim()),l(!0),setTimeout(()=>l(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:s?y(ct,{className:"size-4"}):y(mt,{className:"size-4"})})]}),y(dt,{theme:pt.vsLight,code:n.trim(),language:g,children:({tokens:c,getLineProps:T,getTokenProps:$})=>y("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:c.map((E,M)=>W("div",{...T({line:E}),children:[y("span",{className:"text-slate-500 mr-4 select-none",children:M+1}),E.map((q,z)=>y("span",{...$({token:q})},z))]},M))})})]})}export{Wr as DocstraBody,to as DocstraCodeBlock,Ht as DocstraHeader,sr as DocstraPage,Rt as DocstraProvider,d as useDocstra};
|
|
1
|
+
"use client";import{createContext as Pe,useContext as Re,useState as Z}from"react";import{ToastContainer as Te}from"react-toast-msg";import{SearchIcon as Ce}from"lucide-react";import{twMerge as Ne}from"tailwind-merge";import ke from"clsx";function m(...e){return Ne(ke(e))}import{useEffect as U,useMemo as De,useState as X}from"react";import Se from"fuse.js";import Le from"next/link";import{useRouter as Ie}from"next/navigation";import{Fragment as Oe,jsx as v,jsxs as B}from"react/jsx-runtime";function J(){let{openSearchBox:e,setOpenSearchBox:o,docs:t}=d(),[r,n]=X(""),[s,a]=X([]),l=Ie();U(()=>{let i=c=>{c.ctrlKey&&c.key==="k"&&(c.preventDefault(),o(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let u=De(()=>!t||t.length===0?null:new Se(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);U(()=>{if(r&&u){let i=u.search(r);a(i.map(c=>c.item))}else r||a([])},[r,u]);let g=i=>{if(i.preventDefault(),r){let c=s[0];c&&(l.push(`/docs/${c.slug}`),n(""),o(!1))}};return U(()=>{let i=c=>{c.key==="Escape"&&(o(!1),n(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),v("div",{onClick:()=>{o(!1),n("")},className:m("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:B("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[v("form",{onSubmit:g,className:m("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&&B(Oe,{children:[v(Ce,{className:"size-5.5 mx-3 shrink-0"}),v("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=>n(i.target.value),name:"searchQuery",required:!0}),v("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),B("div",{className:m("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=>B(Le,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{o(!1),n("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[v("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),v("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),r&&s.length===0&&v("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as j,jsxs as Ee}from"react/jsx-runtime";var ee=Pe(null);function Rt({children:e,docstraConfig:o,docs:t,pageData:r,slug:n}){let s=r||(()=>{let i=Array.isArray(n)?n.length===0?"index":n.join("/"):n||"index";return t.find(c=>c.slug===i)})(),[a,l]=Z(!1),[u,g]=Z(!1);return Ee(ee.Provider,{value:{openSidebar:a,setOpenSidebar:l,docstraConfig:o,openSearchBox:u,setOpenSearchBox:g,pageData:s,docs:t},children:[j(Te,{}),j(J,{}),e]})}function d(){let e=Re(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as ze,XIcon as Be}from"lucide-react";import{useEffect as Ge}from"react";import K from"next/link";import{jsx as b,jsxs as te}from"react/jsx-runtime";function Ht(){let{openSidebar:e,setOpenSidebar:o,docstraConfig:t}=d(),r="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;Ge(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]);let n=t.navbar?.logo;function s(a){if(!a)return b("img",{src:"/logo.png",alt:"Logo",className:"h-9.5 w-auto"});switch(a.type){case"image":return b("img",{src:a.src,alt:a.alt,className:m("h-9.5 w-auto",a.className)});case"component":{let l=a.component;return b(l,{className:a.className})}case"node":return a.node}}return te("header",{className:"sticky 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:[b(K,{href:n?.link||"/",className:m("hover:opacity-80 transition",n?.className),children:s(n)}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>b(K,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),b(K,{href:r||"https://github.com/sudhucodes/docstra",children:b("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:b("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"})})})]}),b("button",{onClick:()=>o(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?b(Be,{className:"size-6.5"}):b(ze,{className:"size-6.5"})})]})}import{SearchIcon as Ae}from"lucide-react";import{usePathname as He}from"next/navigation";import*as Fe from"lucide-react";function re(e){if(e)return Fe[e]}import $e from"next/link";import{Fragment as Me,jsx as x,jsxs as S}from"react/jsx-runtime";function oe(){let{openSidebar:e,setOpenSidebar:o,docstraConfig:t,setOpenSearchBox:r}=d(),n=He();return S(Me,{children:[x("div",{className:m("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>o(!1)}),S("aside",{className:m("sticky 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:()=>{o(e&&!1),r(!0)},children:[x(Ae,{className:"size-4.5"}),x("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[x("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),x("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(s=>S("div",{children:[x("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:s.section}),x("ul",{className:"mb-4",children:s.items.map(a=>{let l=re(a.icon);return x("li",{children:S($e,{href:a.href,onNavigate:()=>e&&o(!1),className:m("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",n===a.href&&"bg-gray-100 text-gray-800"),children:[l&&x(l,{className:"size-4"}),x("span",{children:a.name})]})},a.href)})})]},s.section))]})]})}import{ArrowUpCircleIcon as qe,SquareArrowOutUpRightIcon as Ue,TextAlignStartIcon as Ke}from"lucide-react";import{usePathname as Ve}from"next/navigation";import{useEffect as O,useRef as ae,useState as G}from"react";import{jsx as w,jsxs as P}from"react/jsx-runtime";function se(){let[e,o]=G(null),[t,r]=G("down"),[n,s]=G(!1),[a,l]=G(!1),{docstraConfig:u,pageData:g}=d(),i=g?.path,c=g?.data?.tableOfContents||[],T=ae(0),$=ae(null),E=Ve(),q=`${"https://github.com/"+u?.editOnGithub?.owner+"/"+u?.editOnGithub?.repo}/edit/main/${u?.editOnGithub?.path}/${i}`;O(()=>{let p=()=>{let f=window.scrollY;r(f>T.current?"down":"up"),s(f>100),T.current=f};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),O(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),f=new IntersectionObserver(C=>{if(a)return;let N=C.filter(D=>D.isIntersecting).sort((D,we)=>D.boundingClientRect.top-we.boundingClientRect.top);if(N.length>0){let D=t==="down"?N[0].target.id:N[N.length-1].target.id;o(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(C=>f.observe(C)),$.current=f,()=>f.disconnect()},[E,t,a]),O(()=>{!(window.scrollY>100)&&o(c[0]?.id)},[c]),O(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let f=p.querySelector(`a[href="#${e}"]`);if(!f)return;let C=p.getBoundingClientRect(),N=f.getBoundingClientRect();(N.top<C.top||N.bottom>C.bottom)&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),O(()=>{if(!a)return;let p=setTimeout(()=>l(!1),800);return()=>clearTimeout(p)},[a]);let z=p=>{o(p),l(!0)};return P("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:[P("p",{className:"flex items-center gap-2 mb-5",children:[w(Ke,{className:"size-4"}),"On this page"]}),w("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:c.map(p=>P("li",{children:[w(ne,{heading:p,activeId:e,handleClick:z}),p.children.map(f=>w(ne,{heading:f,activeId:e,handleClick:z,className:"pl-8"},f.id))]},p.id))}),w("hr",{className:"my-6 border-gray-200"}),u.editOnGithub&&P("a",{href:q,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",w(Ue,{className:"size-4"})]}),n&&P("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",w(qe,{className:"size-4"})]})]})}function ne({heading:e,activeId:o,handleClick:t,className:r}){return w("a",{href:`#${e.id}`,className:m("border-l border-gray-200 block py-1.5 pl-4 transition-colors",r,{"border-gray-800 text-gray-900 font-medium":o===e.id,"hover:text-gray-800 hover:border-gray-400":o!==e.id}),onClick:()=>t(e.id),children:e.text})}import{jsx as ie,jsxs as Ye}from"react/jsx-runtime";function sr({children:e,toc:o=!0,sidebar:t=!0}){return Ye("div",{className:"min-h-screen flex bg-white w-full",children:[t&&ie(oe,{}),e,o&&ie(se,{})]})}import{usePathname as Qe}from"next/navigation";import{ChevronRight as _e}from"lucide-react";import le from"next/link";import{jsx as L,jsxs as ce}from"react/jsx-runtime";function me(){let o=Qe().split("/").filter(Boolean),t=o.map((r,n)=>{let s="/"+o.slice(0,n+1).join("/"),a=r.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:s,title:a}});return L("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500",children:ce("ol",{className:"flex items-center space-x-2",children:[L("li",{children:L(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((r,n)=>{let s=n===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[L(_e,{className:"w-4 h-4 text-gray-400"}),s?L("span",{className:"text-gray-600 font-medium",children:r.title}):L(le,{href:r.href,className:"hover:text-gray-700 font-medium transition-colors",children:r.title})]},r.href)})]})})}import{CheckIcon as We,CopyIcon as Xe}from"lucide-react";import{useEffect as Je,useState as de}from"react";import{jsx as V,jsxs as pe}from"react/jsx-runtime";function ue(){let{pageData:e}=d(),[o,t]=de(!1),[r,n]=de(null);Je(()=>{n(window.location.href)},[]);let s=`Read from this URL: ${r} and explain it to me.`;return pe("div",{className:"flex items-center gap-3 mt-6",children:[pe("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!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:[o?V(We,{className:"size-3.5"}):V(Xe,{className:"size-3.5"}),"Copy Markdown"]}),V("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex 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{Fragment as Ze,jsx as F,jsxs as je}from"react/jsx-runtime";function fe(){let{pageData:e}=d(),o=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return je(Ze,{children:[F("h1",{className:"text-3xl font-bold",children:o}),F("p",{className:"my-4 text-gray-500",children:t}),F(ue,{}),F("hr",{className:"my-10 border-gray-200"})]})}import{useState as A}from"react";import{ThumbsUp as tt,ThumbsDown as rt}from"lucide-react";import{jsx as Y,jsxs as ge}from"react/jsx-runtime";function Q({label:e,type:o,placeholder:t="",id:r,required:n=!1,onChange:s,value:a,readOnly:l=!1,className:u="",optional:g=!1}){return ge("div",{className:m("flex flex-col mt-4 w-full",u),children:[e&&ge("label",{htmlFor:r,className:"font-medium w-max cursor-pointer",children:[e,g&&Y("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),o==="textarea"?Y("textarea",{id:r,name:r,className:m("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",u),placeholder:t,required:n,onChange:s,rows:4,value:a,readOnly:l}):Y("input",{type:o,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:t,required:n,onChange:s,value:a,readOnly:l})]})}import{Loader2Icon as et}from"lucide-react";import{jsx as he}from"react/jsx-runtime";function _({label:e,loading:o,type:t="submit",className:r="",disabled:n=!1,onClick:s}){return he("button",{type:t,disabled:n,className:m("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:o?he(et,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as ot,FormSyncForm as at}from"formsync";import{Fragment as be,jsx as h,jsxs as k}from"react/jsx-runtime";function xe(){let[e,o]=A(null),{docstraConfig:t}=d(),[r,n]=A(""),[s,a]=A(!1),[l,u]=A(null),g="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-20 py-10 space-y-4",children:s?k(be,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(_,{onClick:()=>{a(!1),o(null),n("")},label:"Submit Again",className:"w-max text-sm"})]}):k(be,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),k("div",{className:"flex gap-2",children:[k("button",{onClick:()=>o("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:[h(tt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),k("button",{onClick:()=>o("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:[h(rt,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&k(at,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{a(!0),o(null),n("")},onSubmitError:i=>{u(i.message)},children:[h(Q,{value:r,id:"message",onChange:i=>n(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&h("p",{className:"text-red-500",children:l}),h("input",{type:"hidden",name:"opinion",value:e}),h("input",{type:"hidden",name:"page",value:window.location.href}),h("input",{type:"hidden",name:"_redirect",value:window.location.href}),h(ot,{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"}),t?.feedback?.watermark!==!1&&k("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${g}`,className:"text-gray-800",children:"FormSync"})]})]})]})})}import{usePathname as nt}from"next/navigation";import ye from"next/link";import{ArrowLeftIcon as st,ArrowRightIcon as it}from"lucide-react";import{jsx as I,jsxs as R}from"react/jsx-runtime";function ve(){let e=nt(),{docstraConfig:o}=d(),t=o?.sidebar?.links?.flatMap(a=>a.items),r=t.findIndex(a=>a.href===e),n=r>0?t[r-1]:null,s=r<t.length-1?t[r+1]:null;return R("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?R(ye,{href:n.href,className:"flex flex-col 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:[I("span",{className:"text-gray-500",children:"Previous"}),R("p",{className:"flex items-center font-medium",children:[I(st,{className:"size-5 mr-2"}),n.name]})]}):I("div",{}),s?R(ye,{href:s.href,className:"flex flex-col 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:[I("span",{className:"text-gray-500",children:"Next"}),R("p",{className:"flex items-center font-medium",children:[s.name,I(it,{className:"size-5 ml-2"})]})]}):I("div",{})]})}import{jsx as H,jsxs as lt}from"react/jsx-runtime";function Wr({children:e}){let{docstraConfig:o}=d();return lt("main",{className:"flex-1 px-4 md:px-8 py-10 max-w-full text-base/7",children:[H(me,{}),H(fe,{}),e,o?.feedback?.enabled&&H(xe,{}),H(ve,{})]})}import{CheckIcon as ct,CopyIcon as mt}from"lucide-react";import{Highlight as dt,themes as pt}from"prism-react-renderer";import{useState as ut}from"react";import{jsx as y,jsxs as W}from"react/jsx-runtime";function to(e){let{filename:o,children:t,className:r}=e,n=!r?.includes("language-"),s=typeof t=="string"?t:t?.props?.children||"";if(n)return y("code",{className:"px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:s});let[a,l]=ut(!1),g=r?.match(/language-([\w-]+)/)?.[1]??"txt";return W("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[W("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[y("span",{className:"text-xs text-gray-400 p-4",children:o||g}),y("button",{onClick:()=>{navigator.clipboard.writeText(s.trim()),l(!0),setTimeout(()=>l(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:a?y(ct,{className:"size-4"}):y(mt,{className:"size-4"})})]}),y(dt,{theme:pt.vsLight,code:s.trim(),language:g,children:({tokens:c,getLineProps:T,getTokenProps:$})=>y("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:c.map((E,M)=>W("div",{...T({line:E}),children:[y("span",{className:"text-slate-500 mr-4 select-none",children:M+1}),E.map((q,z)=>y("span",{...$({token:q})},z))]},M))})})]})}export{Wr as DocstraBody,to as DocstraCodeBlock,Ht as DocstraHeader,sr as DocstraPage,Rt as DocstraProvider,d as useDocstra};
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-
|
|
1
|
+
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-CuNOikJf.mjs';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import 'react';
|
|
5
4
|
|
|
6
|
-
declare function defineDocstraConfig
|
|
5
|
+
declare function defineDocstraConfig(config: DocstraConfig): DocstraConfig;
|
|
7
6
|
|
|
8
7
|
declare function withDocstra<T extends NextConfig>(nextConfig?: T): T;
|
|
9
8
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-
|
|
1
|
+
import { D as DocstraConfig, p as pageDataContent, g as getSitemapProps } from '../types-CuNOikJf.js';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import 'react';
|
|
5
4
|
|
|
6
|
-
declare function defineDocstraConfig
|
|
5
|
+
declare function defineDocstraConfig(config: DocstraConfig): DocstraConfig;
|
|
7
6
|
|
|
8
7
|
declare function withDocstra<T extends NextConfig>(nextConfig?: T): T;
|
|
9
8
|
|
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var W=Object.create;var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var r in t)y(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of M(t))!L.call(e,n)&&n!==r&&y(e,n,{get:()=>t[n],enumerable:!(o=_(t,n))||o.enumerable});return e};var l=(e,t,r)=>(r=e!=null?W(I(e)):{},w(t||!e||!e.__esModule?y(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>w(y({},"__esModule",{value:!0}),e);var G={};B(G,{createSource:()=>U,defaultMdxComponents:()=>Q,defineDocstraConfig:()=>A,getPageData:()=>R,withDocstra:()=>J});module.exports=H(G);function A(e){return e}var u=l(require("fs")),m=l(require("path"));var d={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},c={info:e=>{console.log(`${d.blue}[Docstra]${d.reset} ${e}`)},success:e=>{console.log(`${d.green}[Docstra]${d.reset} ${e}`)},warn:e=>{console.warn(`${d.yellow}[Docstra Warning]${d.reset} ${e}`)},error:(e,t)=>{console.error(`${d.red}[Docstra Error]${d.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=m.default.join(t,".docstra"),o=m.default.join(r,"index.ts");u.default.existsSync(e)||(c.error(`Content directory not found: ${e}`),c.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),u.default.existsSync(r)||u.default.mkdirSync(r,{recursive:!0});let n=N(e);n.length===0&&c.warn(`No .md or .mdx files found in ${e}`);let s=[],i=[];n.forEach((
|
|
1
|
+
"use strict";var W=Object.create;var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var r in t)y(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of M(t))!L.call(e,n)&&n!==r&&y(e,n,{get:()=>t[n],enumerable:!(o=_(t,n))||o.enumerable});return e};var l=(e,t,r)=>(r=e!=null?W(I(e)):{},w(t||!e||!e.__esModule?y(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>w(y({},"__esModule",{value:!0}),e);var G={};B(G,{createSource:()=>U,defaultMdxComponents:()=>Q,defineDocstraConfig:()=>A,getPageData:()=>R,withDocstra:()=>J});module.exports=H(G);function A(e){return e}var u=l(require("fs")),m=l(require("path"));var d={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},c={info:e=>{console.log(`${d.blue}[Docstra]${d.reset} ${e}`)},success:e=>{console.log(`${d.green}[Docstra]${d.reset} ${e}`)},warn:e=>{console.warn(`${d.yellow}[Docstra Warning]${d.reset} ${e}`)},error:(e,t)=>{console.error(`${d.red}[Docstra Error]${d.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=m.default.join(t,".docstra"),o=m.default.join(r,"index.ts");u.default.existsSync(e)||(c.error(`Content directory not found: ${e}`),c.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),u.default.existsSync(r)||u.default.mkdirSync(r,{recursive:!0});let n=N(e);n.length===0&&c.warn(`No .md or .mdx files found in ${e}`);let s=[],i=[];n.forEach((D,q)=>{let z=m.default.relative(r,D).replace(/\\/g,"/"),p=`d${q}`;s.push(`import * as ${p} from "${z}?docstra";`);let $=m.default.relative(e,D).replace(/\\/g,"/"),O=V($);i.push(`{
|
|
2
2
|
slug: "${O}",
|
|
3
|
-
path: "${
|
|
3
|
+
path: "${$}",
|
|
4
4
|
data: {
|
|
5
5
|
metadata: ${p}.metadata,
|
|
6
6
|
raw: ${p}.raw,
|
|
@@ -15,4 +15,4 @@ export const docs = [
|
|
|
15
15
|
${i.join(`,
|
|
16
16
|
`)}
|
|
17
17
|
];
|
|
18
|
-
`;u.default.writeFileSync(o,P,"utf8")}function N(e){return u.default.readdirSync(e).flatMap(t=>{let r=m.default.join(e,t);return u.default.statSync(r).isDirectory()?N(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function V(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var
|
|
18
|
+
`;u.default.writeFileSync(o,P,"utf8")}function N(e){return u.default.readdirSync(e).flatMap(t=>{let r=m.default.join(e,t);return u.default.statSync(r).isDirectory()?N(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function V(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var C=!1,b=null;async function k(e){if(C)return;C=!0,await g(e);let{FSWatcher:t}=await import("chokidar"),r="docstra.config.ts",o=new t({ignoreInitial:!0,persistent:!0,ignored:["node_modules",".next"]});o.add([e,r]),c.info("Dev server started..."),o.on("all",async(n,s)=>{!s.endsWith(".md")&&!s.endsWith(".mdx")&&!s.endsWith("docstra.config.ts")||(b&&clearTimeout(b),b=setTimeout(async()=>{await g(e)},200),c.info("MDX content rebuilt successfully"))}),process.on("exit",()=>{o.closed||o.close()})}var h=l(require("path")),v=l(require("fs"));var X="docs/content";function S(){let e=process.cwd(),t=h.default.join(e,"docstra.config.ts"),r={};if(v.default.existsSync(t))try{delete require.cache[require.resolve(t)];let n=require(t);r=n.default??n}catch(n){c.error("Failed to load docstra.config.ts",n),process.exit(1)}else c.warn("No docstra.config.ts found, using defaults");let o=r.contentDir?h.default.resolve(e,r.contentDir):h.default.join(e,X);return{root:e,contentDir:o,userConfig:r}}var T=!1;function J(e={}){let t=process.env.NODE_ENV==="development",r=process.env.NODE_ENV==="production",o=S().contentDir;T||(T=!0,t&&k(o),r&&(g(o),c.info("MDX content generated successfully")));let n={...e.turbopack,rules:{...e.turbopack?.rules,"*.{md,mdx}":{loaders:[{loader:require.resolve("./docstra-loader")}],as:"*.js"}}};return{...e,turbopack:n,pageExtensions:e.pageExtensions??["ts","tsx","js","jsx","md","mdx"],webpack:(s,i)=>(s.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:require.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(s,i):s)}}var E=require("lucide-react");function F(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}var x=require("react/jsx-runtime");function f({children:e,level:t}){let r=`h${t}`,n=F(typeof e=="string"?e:""),s,i;switch(t){case 2:s="text-2xl",i="size-5";break;case 3:s="text-xl",i="size-4.5";break;case 4:s="text-lg",i="size-4.5";break;case 5:s="text-base",i="size-3.5";break;default:s="text-base",i="size-3.5"}return(0,x.jsxs)(r,{id:n,className:`group mt-10 gap-2 mb-4 flex items-center scroll-mt-26 ${s} font-semibold text-gray-900`,children:[(0,x.jsx)("a",{href:`#${n}`,children:e}),(0,x.jsx)(E.LinkIcon,{className:`${i} text-gray-400 opacity-0 group-hover:opacity-100 transition`})]})}var j=l(require("next/link")),a=require("react/jsx-runtime"),Q={h1:e=>(0,a.jsx)("h1",{className:"text-3xl font-bold text-gray-900 mb-4",children:e.children}),h2:e=>(0,a.jsx)(f,{...e,level:2}),h3:e=>(0,a.jsx)(f,{...e,level:3}),h4:e=>(0,a.jsx)(f,{...e,level:4}),h5:e=>(0,a.jsx)(f,{...e,level:5}),p:e=>(0,a.jsx)("p",{className:"my-5",children:e.children}),hr:()=>(0,a.jsx)("hr",{className:"my-10 border-gray-200"}),a:e=>e.href.startsWith("http")?(0,a.jsx)("a",{href:e.href,className:"underline underline-offset-4",...e,target:"_blank",rel:"noopener noreferrer",children:e.children}):(0,a.jsx)(j.default,{href:e.href,className:"underline underline-offset-4",...e,children:e.children}),ul:e=>(0,a.jsx)("ul",{className:"list-['-'] pl-4 space-y-2",children:e.children}),li:e=>(0,a.jsx)("li",{className:"mb-2 pl-3 text-gray-700",children:e.children}),ol:e=>(0,a.jsx)("ol",{className:"list-decimal pl-4 space-y-2",children:e.children}),blockquote:e=>(0,a.jsx)("blockquote",{className:"border-l-4 border-gray-200 pl-4 my-8 text-gray-700",children:e.children})};function R(e,t){return t.find(o=>o.slug===(e?.join("/")||"index"))}function U(e){return{getPage:t=>{let r=t?.join("/")||"index",o=e.find(i=>i.slug===r);if(!o)return null;let{mdxContent:n,...s}=o.data;return{info:{...o,data:s},body:o.data.mdxContent}},generateStaticParams:()=>e.map(t=>({slug:t.slug==="index"?[]:t.slug.split("/")})),files:e.map(t=>{let{mdxContent:r,...o}=t.data;return{...t,data:o}}),generateSitemap:({baseUrl:t,lastmod:r,changefreq:o,priority:n})=>e.map(s=>({url:`${t}/${s.slug.replace("index","docs")}`,lastModified:r,changeFrequency:o,priority:n}))}}0&&(module.exports={createSource,defaultMdxComponents,defineDocstraConfig,getPageData,withDocstra});
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var d=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function M(e){return e}import u from"fs";import p from"path";var l={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},c={info:e=>{console.log(`${l.blue}[Docstra]${l.reset} ${e}`)},success:e=>{console.log(`${l.green}[Docstra]${l.reset} ${e}`)},warn:e=>{console.warn(`${l.yellow}[Docstra Warning]${l.reset} ${e}`)},error:(e,t)=>{console.error(`${l.red}[Docstra Error]${l.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=p.join(t,".docstra"),o=p.join(r,"index.ts");u.existsSync(e)||(c.error(`Content directory not found: ${e}`),c.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),u.existsSync(r)||u.mkdirSync(r,{recursive:!0});let s
|
|
1
|
+
var d=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function M(e){return e}import u from"fs";import p from"path";var l={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},c={info:e=>{console.log(`${l.blue}[Docstra]${l.reset} ${e}`)},success:e=>{console.log(`${l.green}[Docstra]${l.reset} ${e}`)},warn:e=>{console.warn(`${l.yellow}[Docstra Warning]${l.reset} ${e}`)},error:(e,t)=>{console.error(`${l.red}[Docstra Error]${l.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=p.join(t,".docstra"),o=p.join(r,"index.ts");u.existsSync(e)||(c.error(`Content directory not found: ${e}`),c.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),u.existsSync(r)||u.mkdirSync(r,{recursive:!0});let s=D(e);s.length===0&&c.warn(`No .md or .mdx files found in ${e}`);let n=[],a=[];s.forEach((h,T)=>{let F=p.relative(r,h).replace(/\\/g,"/"),f=`d${T}`;n.push(`import * as ${f} from "${F}?docstra";`);let b=p.relative(e,h).replace(/\\/g,"/"),E=j(b);a.push(`{
|
|
2
2
|
slug: "${E}",
|
|
3
3
|
path: "${b}",
|
|
4
4
|
data: {
|
|
@@ -15,4 +15,4 @@ export const docs = [
|
|
|
15
15
|
${a.join(`,
|
|
16
16
|
`)}
|
|
17
17
|
];
|
|
18
|
-
`;u.writeFileSync(o,S,"utf8")}function
|
|
18
|
+
`;u.writeFileSync(o,S,"utf8")}function D(e){return u.readdirSync(e).flatMap(t=>{let r=p.join(e,t);return u.statSync(r).isDirectory()?D(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function j(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var $=!1,x=null;async function w(e){if($)return;$=!0,await g(e);let{FSWatcher:t}=await import("chokidar"),r="docstra.config.ts",o=new t({ignoreInitial:!0,persistent:!0,ignored:["node_modules",".next"]});o.add([e,r]),c.info("Dev server started..."),o.on("all",async(s,n)=>{!n.endsWith(".md")&&!n.endsWith(".mdx")&&!n.endsWith("docstra.config.ts")||(x&&clearTimeout(x),x=setTimeout(async()=>{await g(e)},200),c.info("MDX content rebuilt successfully"))}),process.on("exit",()=>{o.closed||o.close()})}import y from"path";import P from"fs";var q="docs/content";function N(){let e=process.cwd(),t=y.join(e,"docstra.config.ts"),r={};if(P.existsSync(t))try{delete d.cache[d.resolve(t)];let s=d(t);r=s.default??s}catch(s){c.error("Failed to load docstra.config.ts",s),process.exit(1)}else c.warn("No docstra.config.ts found, using defaults");let o=r.contentDir?y.resolve(e,r.contentDir):y.join(e,q);return{root:e,contentDir:o,userConfig:r}}var C=!1;function oe(e={}){let t=process.env.NODE_ENV==="development",r=process.env.NODE_ENV==="production",o=N().contentDir;C||(C=!0,t&&w(o),r&&(g(o),c.info("MDX content generated successfully")));let s={...e.turbopack,rules:{...e.turbopack?.rules,"*.{md,mdx}":{loaders:[{loader:d.resolve("./docstra-loader")}],as:"*.js"}}};return{...e,turbopack:s,pageExtensions:e.pageExtensions??["ts","tsx","js","jsx","md","mdx"],webpack:(n,a)=>(n.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:d.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(n,a):n)}}import{LinkIcon as z}from"lucide-react";function k(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}import{jsx as v,jsxs as O}from"react/jsx-runtime";function m({children:e,level:t}){let r=`h${t}`,s=k(typeof e=="string"?e:""),n,a;switch(t){case 2:n="text-2xl",a="size-5";break;case 3:n="text-xl",a="size-4.5";break;case 4:n="text-lg",a="size-4.5";break;case 5:n="text-base",a="size-3.5";break;default:n="text-base",a="size-3.5"}return O(r,{id:s,className:`group mt-10 gap-2 mb-4 flex items-center scroll-mt-26 ${n} font-semibold text-gray-900`,children:[v("a",{href:`#${s}`,children:e}),v(z,{className:`${a} text-gray-400 opacity-0 group-hover:opacity-100 transition`})]})}import W from"next/link";import{jsx as i}from"react/jsx-runtime";var fe={h1:e=>i("h1",{className:"text-3xl font-bold text-gray-900 mb-4",children:e.children}),h2:e=>i(m,{...e,level:2}),h3:e=>i(m,{...e,level:3}),h4:e=>i(m,{...e,level:4}),h5:e=>i(m,{...e,level:5}),p:e=>i("p",{className:"my-5",children:e.children}),hr:()=>i("hr",{className:"my-10 border-gray-200"}),a:e=>e.href.startsWith("http")?i("a",{href:e.href,className:"underline underline-offset-4",...e,target:"_blank",rel:"noopener noreferrer",children:e.children}):i(W,{href:e.href,className:"underline underline-offset-4",...e,children:e.children}),ul:e=>i("ul",{className:"list-['-'] pl-4 space-y-2",children:e.children}),li:e=>i("li",{className:"mb-2 pl-3 text-gray-700",children:e.children}),ol:e=>i("ol",{className:"list-decimal pl-4 space-y-2",children:e.children}),blockquote:e=>i("blockquote",{className:"border-l-4 border-gray-200 pl-4 my-8 text-gray-700",children:e.children})};function xe(e,t){return t.find(o=>o.slug===(e?.join("/")||"index"))}function he(e){return{getPage:t=>{let r=t?.join("/")||"index",o=e.find(a=>a.slug===r);if(!o)return null;let{mdxContent:s,...n}=o.data;return{info:{...o,data:n},body:o.data.mdxContent}},generateStaticParams:()=>e.map(t=>({slug:t.slug==="index"?[]:t.slug.split("/")})),files:e.map(t=>{let{mdxContent:r,...o}=t.data;return{...t,data:o}}),generateSitemap:({baseUrl:t,lastmod:r,changefreq:o,priority:s})=>e.map(n=>({url:`${t}/${n.slug.replace("index","docs")}`,lastModified:r,changeFrequency:o,priority:s}))}}export{he as createSource,fe as defaultMdxComponents,M as defineDocstraConfig,xe as getPageData,oe as withDocstra};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
|
|
3
1
|
interface DocstraContextType {
|
|
4
2
|
openSidebar: boolean;
|
|
5
3
|
setOpenSidebar: (open: boolean) => void;
|
|
@@ -10,16 +8,25 @@ interface DocstraContextType {
|
|
|
10
8
|
pageData: pageDataContent;
|
|
11
9
|
}
|
|
12
10
|
type ImageLogo = {
|
|
11
|
+
type: "image";
|
|
13
12
|
link: string;
|
|
14
13
|
src: string;
|
|
15
14
|
alt: string;
|
|
16
15
|
className?: string;
|
|
17
16
|
};
|
|
18
17
|
type ComponentLogo = {
|
|
18
|
+
type: "component";
|
|
19
|
+
link: string;
|
|
20
|
+
component: React.ComponentType<any>;
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
type NodeLogo = {
|
|
24
|
+
type: "node";
|
|
19
25
|
link: string;
|
|
20
|
-
|
|
26
|
+
node: React.ReactNode;
|
|
21
27
|
className?: string;
|
|
22
28
|
};
|
|
29
|
+
type NavbarLogo = ImageLogo | ComponentLogo | NodeLogo;
|
|
23
30
|
interface pageDataContent {
|
|
24
31
|
slug: string;
|
|
25
32
|
path: string;
|
|
@@ -42,7 +49,7 @@ interface DocstraConfig {
|
|
|
42
49
|
watermark?: boolean;
|
|
43
50
|
};
|
|
44
51
|
navbar?: {
|
|
45
|
-
logo?:
|
|
52
|
+
logo?: NavbarLogo;
|
|
46
53
|
links?: {
|
|
47
54
|
name: string;
|
|
48
55
|
href: string;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
|
|
3
1
|
interface DocstraContextType {
|
|
4
2
|
openSidebar: boolean;
|
|
5
3
|
setOpenSidebar: (open: boolean) => void;
|
|
@@ -10,16 +8,25 @@ interface DocstraContextType {
|
|
|
10
8
|
pageData: pageDataContent;
|
|
11
9
|
}
|
|
12
10
|
type ImageLogo = {
|
|
11
|
+
type: "image";
|
|
13
12
|
link: string;
|
|
14
13
|
src: string;
|
|
15
14
|
alt: string;
|
|
16
15
|
className?: string;
|
|
17
16
|
};
|
|
18
17
|
type ComponentLogo = {
|
|
18
|
+
type: "component";
|
|
19
|
+
link: string;
|
|
20
|
+
component: React.ComponentType<any>;
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
type NodeLogo = {
|
|
24
|
+
type: "node";
|
|
19
25
|
link: string;
|
|
20
|
-
|
|
26
|
+
node: React.ReactNode;
|
|
21
27
|
className?: string;
|
|
22
28
|
};
|
|
29
|
+
type NavbarLogo = ImageLogo | ComponentLogo | NodeLogo;
|
|
23
30
|
interface pageDataContent {
|
|
24
31
|
slug: string;
|
|
25
32
|
path: string;
|
|
@@ -42,7 +49,7 @@ interface DocstraConfig {
|
|
|
42
49
|
watermark?: boolean;
|
|
43
50
|
};
|
|
44
51
|
navbar?: {
|
|
45
|
-
logo?:
|
|
52
|
+
logo?: NavbarLogo;
|
|
46
53
|
links?: {
|
|
47
54
|
name: string;
|
|
48
55
|
href: string;
|