docstra 1.9.3 → 1.9.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/cli/index.js +0 -0
- 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/docstra-loader.js +9 -8
- package/dist/server/docstra-loader.mjs +9 -8
- package/dist/server/index.d.mts +3 -2
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.js +10 -9
- package/dist/server/index.mjs +11 -10
- package/dist/{types-CvrHe34X.d.mts → types-DYyitlml.d.mts} +1 -0
- package/dist/{types-CvrHe34X.d.ts → types-DYyitlml.d.ts} +1 -0
- package/package.json +2 -1
package/cli/index.js
CHANGED
|
File without changes
|
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-DYyitlml.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-DYyitlml.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,r)=>{for(var t in r)U(e,t,{get:r[t],enumerable:!0})},se=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ae(r))!$e.call(e,a)&&a!==t&&U(e,a,{get:()=>r[a],enumerable:!(o=Fe(r,a))||o.enumerable});return e};var L=(e,r,t)=>(t=e!=null?Ge(He(e)):{},se(r||!e||!e.__esModule?U(t,"default",{value:e,enumerable:!0}):t,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 f(...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:r,docs:t}=d(),[o,a]=(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(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let g=(0,D.useMemo)(()=>!t||t.length===0?null:new me.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,D.useEffect)(()=>{if(o&&g){let i=g.search(o);s(i.map(p=>p.item))}else o||s([])},[o,g]);let w=i=>{if(i.preventDefault(),o){let p=n[0];p&&(c.push(`/docs/${p.slug}`),a(""),r(!1))}};return(0,D.useEffect)(()=>{let i=p=>{p.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:f("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:w,className:f("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:f("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=>(0,h.jsxs)(de.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!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&&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:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(p=>p.slug===i)})(),[s,c]=(0,O.useState)(!1),[g,w]=(0,O.useState)(!1);return(0,G.jsxs)(ge.Provider,{value:{openSidebar:s,setOpenSidebar:c,docstraConfig:r,openSearchBox:g,setOpenSearchBox:w,pageData:n,docs:t},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")),N=require("react/jsx-runtime");function Ke(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=d(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,he.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,N.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,N.jsx)(K.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,N.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:f("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,N.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,N.jsx)(K.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,N.jsx)(K.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,N.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,N.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,N.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,N.jsx)(V.XIcon,{className:"size-6.5"}):(0,N.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:r,docstraConfig:t,setOpenSearchBox:o}=d(),a=(0,ye.usePathname)();return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:f("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),(0,m.jsxs)("aside",{className:f("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:()=>{r(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"})]})]}),t.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&&r(!1),className:f("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===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"),y=require("react");var b=require("react/jsx-runtime");function Ce(){let[e,r]=(0,y.useState)(null),[t,o]=(0,y.useState)("down"),[a,n]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),{docstraConfig:g,pageData:w}=d(),i=w?.path,p=w?.data?.tableOfContents||[],$=(0,y.useRef)(0),Z=(0,y.useRef)(null),M=(0,ke.usePathname)(),ee=`${"https://github.com/"+g?.editOnGithub?.owner+"/"+g?.editOnGithub?.repo}/edit/main/${g?.editOnGithub?.path}/${i}`;(0,y.useEffect)(()=>{let u=()=>{let x=window.scrollY;o(x>$.current?"down":"up"),n(x>100),$.current=x};return window.addEventListener("scroll",u),()=>window.removeEventListener("scroll",u)},[]),(0,y.useEffect)(()=>{let u=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=t==="down"?I[0].target.id:I[I.length-1].target.id;r(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return u.forEach(E=>x.observe(E)),Z.current=x,()=>x.disconnect()},[M,t,s]),(0,y.useEffect)(()=>{!(window.scrollY>100)&&r(p[0]?.id)},[p]),(0,y.useEffect)(()=>{if(!e)return;let u=document.querySelector(".toc-scroll-container");if(!u)return;let x=u.querySelector(`a[href="#${e}"]`);if(!x)return;let E=u.getBoundingClientRect(),I=x.getBoundingClientRect();(I.top<E.top||I.bottom>E.bottom)&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,y.useEffect)(()=>{if(!s)return;let u=setTimeout(()=>c(!1),800);return()=>clearTimeout(u)},[s]);let q=u=>{r(u),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(u=>(0,b.jsxs)("li",{children:[(0,b.jsx)(Ne,{heading:u,activeId:e,handleClick:q}),u.children.map(x=>(0,b.jsx)(Ne,{heading:x,activeId:e,handleClick:q,className:"pl-8"},x.id))]},u.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"})]}),a&&(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:r,handleClick:t,className:o}){return(0,b.jsx)("a",{href:`#${e.id}`,className:f("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var F=require("react/jsx-runtime");function Ye({children:e,toc:r=!0,sidebar:t=!0}){return(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[t&&(0,F.jsx)(we,{}),e,r&&(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 r=(0,De.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.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"})}),t.map((o,a)=>{let n=a===t.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: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(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`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||""),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:[r?(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(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("h1",{className:"text-3xl font-bold",children:r}),(0,S.jsx)("p",{className:"my-4 text-gray-500",children:t}),(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:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:g="",optional:w=!1}){return(0,R.jsxs)("div",{className:f("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,w&&(0,R.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,R.jsx)("textarea",{id:o,name:o,className:f("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:t,required:a,onChange:n,rows:4,value:s,readOnly:c}):(0,R.jsx)("input",{type:r,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:a,onChange:n,value:s,readOnly:c})]})}var Pe=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,oe.jsx)("button",{type:t,disabled:a,className:f("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:r?(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,r]=(0,H.useState)(null),{docstraConfig:t}=d(),[o,a]=(0,H.useState)(""),[n,s]=(0,H.useState)(!1),[c,g]=(0,H.useState)(null),w="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.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),r(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:()=>r("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:()=>r("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:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(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"}),t?.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=${w}`,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:r}=d(),t=r?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[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",{}),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:r}=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,r?.feedback?.enabled&&(0,T.jsx)(Re,{}),(0,T.jsx)(Ee,{})]})}var X=require("lucide-react"),J=require("prism-react-renderer"),ze=require("react"),v=require("react/jsx-runtime");function _e(e){let{filename:r,children:t,className:o}=e,a=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)return(0,v.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),w=o?.match(/language-([\w-]+)/)?.[1]??"txt";return(0,v.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[(0,v.jsxs)("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[(0,v.jsx)("span",{className:"text-xs text-gray-400 p-4",children:r||w}),(0,v.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,v.jsx)(X.CheckIcon,{className:"size-4"}):(0,v.jsx)(X.CopyIcon,{className:"size-4"})})]}),(0,v.jsx)(J.Highlight,{theme:J.themes.vsLight,code:n.trim(),language:w,children:({tokens:p,getLineProps:$,getTokenProps:Z})=>(0,v.jsx)("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:p.map((M,j)=>(0,v.jsxs)("div",{...$({line:M}),children:[(0,v.jsx)("span",{className:"text-slate-500 mr-4 select-none",children:j+1}),M.map((ee,q)=>(0,v.jsx)("span",{...Z({token:ee})},q))]},j))})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraPage,DocstraProvider,useDocstra});
|
|
1
|
+
"use strict";"use client";var Ae=Object.create;var q=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var qe=(e,r)=>{for(var t in r)q(e,t,{get:r[t],enumerable:!0})},se=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of He(r))!Me.call(e,a)&&a!==t&&q(e,a,{get:()=>r[a],enumerable:!(o=Ue(r,a))||o.enumerable});return e};var L=(e,r,t)=>(t=e!=null?Ae($e(e)):{},se(r||!e||!e.__esModule?q(t,"default",{value:e,enumerable:!0}):t,e)),Ke=e=>se(q({},"__esModule",{value:!0}),e);var Ze={};qe(Ze,{DocstraBody:()=>We,DocstraCodeBlock:()=>Xe,DocstraHeader:()=>Ye,DocstraPage:()=>_e,DocstraProvider:()=>Ve,useDocstra:()=>c});module.exports=Ke(Ze);var P=require("react"),fe=require("react-toast-msg");var ce=require("lucide-react");var ie=require("tailwind-merge"),le=L(require("clsx"));function f(...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:r,docs:t}=c(),[o,a]=(0,D.useState)(""),[n,s]=(0,D.useState)([]),m=(0,pe.useRouter)();(0,D.useEffect)(()=>{let i=p=>{p.ctrlKey&&p.key==="k"&&(p.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let g=(0,D.useMemo)(()=>!t||t.length===0?null:new me.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,D.useEffect)(()=>{if(o&&g){let i=g.search(o);s(i.map(p=>p.item))}else o||s([])},[o,g]);let w=i=>{if(i.preventDefault(),o){let p=n[0];p&&(m.push(`/docs/${p.slug}`),a(""),r(!1))}};return(0,D.useEffect)(()=>{let i=p=>{p.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:f("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:w,className:f("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:f("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=>(0,h.jsxs)(de.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!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&&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,P.createContext)(null);function Ve({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(p=>p.slug===i)})(),[s,m]=(0,P.useState)(!1),[g,w]=(0,P.useState)(!1);return(0,G.jsxs)(ge.Provider,{value:{openSidebar:s,setOpenSidebar:m,docstraConfig:r,openSearchBox:g,setOpenSearchBox:w,pageData:n,docs:t},children:[(0,G.jsx)(fe.ToastContainer,{}),(0,G.jsx)(ue,{}),e]})}function c(){let e=(0,P.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")),N=require("react/jsx-runtime");function Ye(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=c(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,he.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,N.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,N.jsx)(K.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,N.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:f("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,N.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,N.jsx)(K.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,N.jsx)(K.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,N.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,N.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,N.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,N.jsx)(V.XIcon,{className:"size-6.5"}):(0,N.jsx)(V.TextAlignEnd,{className:"size-6.5"})})]})}var xe=require("lucide-react"),ye=require("next/navigation");var Qe=L(require("lucide-react"));function be(e){if(e)return Qe[e]}var ve=L(require("next/link")),d=require("react/jsx-runtime");function we(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=(0,ye.usePathname)();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:f("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),(0,d.jsxs)("aside",{className:f("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,d.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:()=>{r(e&&!1),o(!0)},children:[(0,d.jsx)(xe.SearchIcon,{className:"size-4.5"}),(0,d.jsx)("p",{children:"Search"}),(0,d.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,d.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,d.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),(0,d.jsx)("ul",{className:"mb-4",children:n.items.map(s=>{let m=be(s.icon);return(0,d.jsx)("li",{children:(0,d.jsxs)(ve.default,{href:s.href,onNavigate:()=>e&&r(!1),className:f("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===s.href&&"bg-gray-100 text-gray-800"),children:[m&&(0,d.jsx)(m,{className:"size-4"}),(0,d.jsx)("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}var B=require("lucide-react"),ke=require("next/navigation"),y=require("react");var b=require("react/jsx-runtime");function Ce(){let[e,r]=(0,y.useState)(null),[t,o]=(0,y.useState)("down"),[a,n]=(0,y.useState)(!1),[s,m]=(0,y.useState)(!1),{docstraConfig:g,pageData:w}=c(),i=w?.path,p=w?.data?.tableOfContents||[],H=(0,y.useRef)(0),J=(0,y.useRef)(null),$=(0,ke.usePathname)(),ee=`${"https://github.com/"+g?.editOnGithub?.owner+"/"+g?.editOnGithub?.repo}/edit/main/${g?.editOnGithub?.path}/${i}`;(0,y.useEffect)(()=>{let u=()=>{let x=window.scrollY;o(x>H.current?"down":"up"),n(x>100),H.current=x};return window.addEventListener("scroll",u),()=>window.removeEventListener("scroll",u)},[]),(0,y.useEffect)(()=>{let u=document.querySelectorAll("h2[id], h3[id]"),x=new IntersectionObserver(E=>{if(s)return;let O=E.filter(z=>z.isIntersecting).sort((z,Fe)=>z.boundingClientRect.top-Fe.boundingClientRect.top);if(O.length>0){let z=t==="down"?O[0].target.id:O[O.length-1].target.id;r(z)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return u.forEach(E=>x.observe(E)),J.current=x,()=>x.disconnect()},[$,t,s]),(0,y.useEffect)(()=>{!(window.scrollY>100)&&r(p[0]?.id)},[p]),(0,y.useEffect)(()=>{if(!e)return;let u=document.querySelector(".toc-scroll-container");if(!u)return;let x=u.querySelector(`a[href="#${e}"]`);if(!x)return;let E=u.getBoundingClientRect(),O=x.getBoundingClientRect();(O.top<E.top||O.bottom>E.bottom)&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,y.useEffect)(()=>{if(!s)return;let u=setTimeout(()=>m(!1),800);return()=>clearTimeout(u)},[s]);let M=u=>{r(u),m(!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(u=>(0,b.jsxs)("li",{children:[(0,b.jsx)(Ne,{heading:u,activeId:e,handleClick:M}),u.children.map(x=>(0,b.jsx)(Ne,{heading:x,activeId:e,handleClick:M,className:"pl-8"},x.id))]},u.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"})]}),a&&(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:r,handleClick:t,className:o}){return(0,b.jsx)("a",{href:`#${e.id}`,className:f("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var F=require("react/jsx-runtime");function _e({children:e,toc:r=!0,sidebar:t=!0}){return(0,F.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[t&&(0,F.jsx)(we,{}),e,r&&(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 r=(0,De.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,m=>m.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 not-prose",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"})}),t.map((o,a)=>{let n=a===t.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: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 R=require("react/jsx-runtime");function Ie(){let{pageData:e}=c(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,R.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,R.jsxs)("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:[r?(0,R.jsx)(Y.CheckIcon,{className:"size-3.5"}):(0,R.jsx)(Y.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,R.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var S=require("react/jsx-runtime");function Oe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("h1",{className:"text-3xl font-bold",children:r}),(0,S.jsx)("p",{className:"my-4 text-gray-500",children:t}),(0,S.jsx)(Ie,{}),(0,S.jsx)("hr",{className:"my-10 border-gray-200"})]})}var U=require("react"),Q=require("lucide-react");var T=require("react/jsx-runtime");function re({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:m=!1,className:g="",optional:w=!1}){return(0,T.jsxs)("div",{className:f("flex flex-col mt-4 w-full",g),children:[e&&(0,T.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,w&&(0,T.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,T.jsx)("textarea",{id:o,name:o,className:f("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:t,required:a,onChange:n,rows:4,value:s,readOnly:m,maxLength:500}):(0,T.jsx)("input",{type:r,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:a,onChange:n,value:s,readOnly:m,maxLength:500})]})}var Pe=require("lucide-react");var oe=require("react/jsx-runtime");function ae({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,oe.jsx)("button",{type:t,disabled:a,className:f("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:r?(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,r]=(0,U.useState)(null),{docstraConfig:t}=c(),[o,a]=(0,U.useState)(""),[n,s]=(0,U.useState)(!1),[m,g]=(0,U.useState)(null),w="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,l.jsx)("div",{className:"border-y border-gray-200 mt-10 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),r(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:()=>r("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:()=>r("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:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(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"}),m&&(0,l.jsx)("p",{className:"text-red-500",children:m}),(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"}),t?.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=${w}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function Te(){let{pageData:e}=c();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var ze=require("next/navigation"),ne=L(require("next/link")),W=require("lucide-react");var k=require("react/jsx-runtime");function Be(){let e=(0,ze.usePathname)(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),a=o>0?t[o-1]:null,n=o<t.length-1?t[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 not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,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",{}),n?(0,k.jsxs)(ne.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,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 I=require("react/jsx-runtime");function We({children:e}){let{docstraConfig:r}=c();return(0,I.jsxs)("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[(0,I.jsx)(Le,{}),(0,I.jsx)(Oe,{}),e,r?.feedback?.enabled&&(0,I.jsx)(Re,{}),(0,I.jsx)(Te,{}),(0,I.jsx)(Be,{})]})}var X=require("lucide-react"),Z=require("prism-react-renderer"),Ge=require("react"),v=require("react/jsx-runtime");function Xe(e){let{filename:r,children:t,className:o}=e,a=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)return(0,v.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,m]=(0,Ge.useState)(!1),w=o?.match(/language-([\w-]+)/)?.[1]??"txt";return(0,v.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200/80 mt-4",children:[(0,v.jsxs)("div",{className:"flex items-center bg-gray-50 justify-between border-b border-gray-200/80",children:[(0,v.jsx)("span",{className:"text-xs text-gray-400 p-4",children:r||w}),(0,v.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(n.trim()),m(!0),setTimeout(()=>m(!1),2e3)},className:"rounded cursor-pointer aspect-square p-2 m-2 text-xs hover:bg-gray-200 transition",children:s?(0,v.jsx)(X.CheckIcon,{className:"size-4"}):(0,v.jsx)(X.CopyIcon,{className:"size-4"})})]}),(0,v.jsx)(Z.Highlight,{theme:Z.themes.vsLight,code:n.trim(),language:w,children:({tokens:p,getLineProps:H,getTokenProps:J})=>(0,v.jsx)("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:p.map(($,j)=>(0,v.jsxs)("div",{...H({line:$}),children:[(0,v.jsx)("span",{className:"text-slate-500 mr-4 select-none",children:j+1}),$.map((ee,M)=>(0,v.jsx)("span",{...J({token:ee})},M))]},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 p(...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}=m(),[r,a]=X(""),[n,s]=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);s(i.map(c=>c.item))}else r||s([])},[r,u]);let g=i=>{if(i.preventDefault(),r){let c=n[0];c&&(l.push(`/docs/${c.slug}`),a(""),o(!1))}};return U(()=>{let i=c=>{c.key==="Escape"&&(o(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),v("div",{onClick:()=>{o(!1),a("")},className:p("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children: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:p("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",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=>a(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:p("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:[n.map(i=>B(Le,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{o(!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:[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&&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:o,docs:t,pageData:r,slug:a}){let n=r||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"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:o,openSearchBox:u,setOpenSearchBox:g,pageData:n,docs:t},children:[j(Te,{}),j(J,{}),e]})}function m(){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 x,jsxs as te}from"react/jsx-runtime";function Ht(){let{openSidebar:e,setOpenSidebar:o,docstraConfig:t}=m(),r="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return Ge(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),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:[x(K,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:x("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:p("h-9.5 w-auto",t.navbar?.logo?.className)})}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>x(K,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),x(K,{href:r||"https://github.com/sudhucodes/docstra",children:x("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:x("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"})})})]}),x("button",{onClick:()=>o(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?x(Be,{className:"size-6.5"}):x(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 b,jsxs as S}from"react/jsx-runtime";function oe(){let{openSidebar:e,setOpenSidebar:o,docstraConfig:t,setOpenSearchBox:r}=m(),a=He();return S(Me,{children:[b("div",{className:p("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:p("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:[b(Ae,{className:"size-4.5"}),b("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>S("div",{children:[b("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),b("ul",{className:"mb-4",children:n.items.map(s=>{let l=re(s.icon);return b("li",{children:S($e,{href:s.href,onNavigate:()=>e&&o(!1),className:p("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===s.href&&"bg-gray-100 text-gray-800"),children:[l&&b(l,{className:"size-4"}),b("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,o]=G(null),[t,r]=G("down"),[a,n]=G(!1),[s,l]=G(!1),{docstraConfig:u,pageData:g}=m(),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 d=()=>{let f=window.scrollY;r(f>T.current?"down":"up"),n(f>100),T.current=f};return window.addEventListener("scroll",d),()=>window.removeEventListener("scroll",d)},[]),O(()=>{let d=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;o(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return d.forEach(C=>f.observe(C)),$.current=f,()=>f.disconnect()},[E,t,s]),O(()=>{!(window.scrollY>100)&&o(c[0]?.id)},[c]),O(()=>{if(!e)return;let d=document.querySelector(".toc-scroll-container");if(!d)return;let f=d.querySelector(`a[href="#${e}"]`);if(!f)return;let C=d.getBoundingClientRect(),N=f.getBoundingClientRect();(N.top<C.top||N.bottom>C.bottom)&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),O(()=>{if(!s)return;let d=setTimeout(()=>l(!1),800);return()=>clearTimeout(d)},[s]);let z=d=>{o(d),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(d=>P("li",{children:[w(ne,{heading:d,activeId:e,handleClick:z}),d.children.map(f=>w(ne,{heading:f,activeId:e,handleClick:z,className:"pl-8"},f.id))]},d.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"})]}),a&&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:p("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,a)=>{let n="/"+o.slice(0,a+1).join("/"),s=r.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((r,a)=>{let n=a===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: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}=m(),[o,t]=de(!1),[r,a]=de(null);Je(()=>{a(window.location.href)},[]);let n=`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(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}=m(),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:a=!1,onChange:n,value:s,readOnly:l=!1,className:u="",optional:g=!1}){return ge("div",{className:p("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:p("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",u),placeholder:t,required:a,onChange:n,rows:4,value:s,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:a,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:o,type:t="submit",className:r="",disabled:a=!1,onClick:n}){return he("button",{type:t,disabled:a,className:p("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",r),"aria-label":e,onClick:n,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}=m(),[r,a]=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),o(null),a("")},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=>{s(!0),o(null),a("")},onSubmitError:i=>{u(i.message)},children:[h(Q,{value:r,id:"message",onChange:i=>a(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}=m(),t=o?.sidebar?.links?.flatMap(s=>s.items),r=t.findIndex(s=>s.href===e),a=r>0?t[r-1]:null,n=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:[a?R(ye,{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:[I("span",{className:"text-gray-500",children:"Previous"}),R("p",{className:"flex items-center font-medium",children:[I(st,{className:"size-5 mr-2"}),a.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:o}=m();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,a=!r?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)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=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(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,m as useDocstra};
|
|
1
|
+
"use client";import{createContext as Re,useContext as Te,useState as J}from"react";import{ToastContainer as Ee}from"react-toast-msg";import{SearchIcon as De}from"lucide-react";import{twMerge as ke}from"tailwind-merge";import Ce from"clsx";function p(...e){return ke(Ce(e))}import{useEffect as q,useMemo as Se,useState as X}from"react";import Le from"fuse.js";import Ie from"next/link";import{useRouter as Oe}from"next/navigation";import{Fragment as Pe,jsx as v,jsxs as G}from"react/jsx-runtime";function Z(){let{openSearchBox:e,setOpenSearchBox:r,docs:t}=c(),[o,a]=X(""),[n,s]=X([]),l=Oe();q(()=>{let i=m=>{m.ctrlKey&&m.key==="k"&&(m.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let u=Se(()=>!t||t.length===0?null:new Le(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);q(()=>{if(o&&u){let i=u.search(o);s(i.map(m=>m.item))}else o||s([])},[o,u]);let g=i=>{if(i.preventDefault(),o){let m=n[0];m&&(l.push(`/docs/${m.slug}`),a(""),r(!1))}};return q(()=>{let i=m=>{m.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),v("div",{onClick:()=>{r(!1),a("")},className:p("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("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:p("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G(Pe,{children:[v(De,{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=>a(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"})]})}),G("div",{className:p("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>G(Ie,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!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:[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 ze}from"react/jsx-runtime";var ee=Re(null);function Et({children:e,docstraConfig:r,docs:t,pageData:o,slug:a}){let n=o||(()=>{let i=Array.isArray(a)?a.length===0?"index":a.join("/"):a||"index";return t.find(m=>m.slug===i)})(),[s,l]=J(!1),[u,g]=J(!1);return ze(ee.Provider,{value:{openSidebar:s,setOpenSidebar:l,docstraConfig:r,openSearchBox:u,setOpenSearchBox:g,pageData:n,docs:t},children:[j(Ee,{}),j(Z,{}),e]})}function c(){let e=Te(ee);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Be,XIcon as Ge}from"lucide-react";import{useEffect as Fe}from"react";import K from"next/link";import{jsx as x,jsxs as te}from"react/jsx-runtime";function $t(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=c(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return Fe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),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:[x(K,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:x("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:p("h-9.5 w-auto",t.navbar?.logo?.className)})}),te("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>x(K,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),x(K,{href:o||"https://github.com/sudhucodes/docstra",children:x("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:x("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"})})})]}),x("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?x(Ge,{className:"size-6.5"}):x(Be,{className:"size-6.5"})})]})}import{SearchIcon as Ue}from"lucide-react";import{usePathname as He}from"next/navigation";import*as Ae from"lucide-react";function re(e){if(e)return Ae[e]}import $e from"next/link";import{Fragment as Me,jsx as b,jsxs as S}from"react/jsx-runtime";function oe(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t,setOpenSearchBox:o}=c(),a=He();return S(Me,{children:[b("div",{className:p("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),S("aside",{className:p("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:()=>{r(e&&!1),o(!0)},children:[b(Ue,{className:"size-4.5"}),b("p",{children:"Search"}),S("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),t.sidebar?.links?.map(n=>S("div",{children:[b("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:n.section}),b("ul",{className:"mb-4",children:n.items.map(s=>{let l=re(s.icon);return b("li",{children:S($e,{href:s.href,onNavigate:()=>e&&r(!1),className:p("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",a===s.href&&"bg-gray-100 text-gray-800"),children:[l&&b(l,{className:"size-4"}),b("span",{children:s.name})]})},s.href)})})]},n.section))]})]})}import{ArrowUpCircleIcon as qe,SquareArrowOutUpRightIcon as Ke,TextAlignStartIcon as Ve}from"lucide-react";import{usePathname as Ye}from"next/navigation";import{useEffect as O,useRef as ae,useState as F}from"react";import{jsx as w,jsxs as P}from"react/jsx-runtime";function se(){let[e,r]=F(null),[t,o]=F("down"),[a,n]=F(!1),[s,l]=F(!1),{docstraConfig:u,pageData:g}=c(),i=g?.path,m=g?.data?.tableOfContents||[],E=ae(0),H=ae(null),z=Ye(),M=`${"https://github.com/"+u?.editOnGithub?.owner+"/"+u?.editOnGithub?.repo}/edit/main/${u?.editOnGithub?.path}/${i}`;O(()=>{let d=()=>{let f=window.scrollY;o(f>E.current?"down":"up"),n(f>100),E.current=f};return window.addEventListener("scroll",d),()=>window.removeEventListener("scroll",d)},[]),O(()=>{let d=document.querySelectorAll("h2[id], h3[id]"),f=new IntersectionObserver(C=>{if(s)return;let N=C.filter(D=>D.isIntersecting).sort((D,Ne)=>D.boundingClientRect.top-Ne.boundingClientRect.top);if(N.length>0){let D=t==="down"?N[0].target.id:N[N.length-1].target.id;r(D)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return d.forEach(C=>f.observe(C)),H.current=f,()=>f.disconnect()},[z,t,s]),O(()=>{!(window.scrollY>100)&&r(m[0]?.id)},[m]),O(()=>{if(!e)return;let d=document.querySelector(".toc-scroll-container");if(!d)return;let f=d.querySelector(`a[href="#${e}"]`);if(!f)return;let C=d.getBoundingClientRect(),N=f.getBoundingClientRect();(N.top<C.top||N.bottom>C.bottom)&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),O(()=>{if(!s)return;let d=setTimeout(()=>l(!1),800);return()=>clearTimeout(d)},[s]);let B=d=>{r(d),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(Ve,{className:"size-4"}),"On this page"]}),w("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:m.map(d=>P("li",{children:[w(ne,{heading:d,activeId:e,handleClick:B}),d.children.map(f=>w(ne,{heading:f,activeId:e,handleClick:B,className:"pl-8"},f.id))]},d.id))}),w("hr",{className:"my-6 border-gray-200"}),u.editOnGithub&&P("a",{href:M,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",w(Ke,{className:"size-4"})]}),a&&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:r,handleClick:t,className:o}){return w("a",{href:`#${e.id}`,className:p("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{jsx as ie,jsxs as Qe}from"react/jsx-runtime";function lr({children:e,toc:r=!0,sidebar:t=!0}){return Qe("div",{className:"min-h-screen flex bg-white w-full",children:[t&&ie(oe,{}),e,r&&ie(se,{})]})}import{usePathname as _e}from"next/navigation";import{ChevronRight as We}from"lucide-react";import le from"next/link";import{jsx as L,jsxs as ce}from"react/jsx-runtime";function me(){let r=_e().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+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 not-prose",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,a)=>{let n=a===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[L(We,{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 Xe,CopyIcon as Ze}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}=c(),[r,t]=de(!1),[o,a]=de(null);Je(()=>{a(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:[r?V(Xe,{className:"size-3.5"}):V(Ze,{className:"size-3.5"}),"Copy Markdown"]}),V("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{Fragment as je,jsx as A,jsxs as et}from"react/jsx-runtime";function fe(){let{pageData:e}=c(),r=e?.data?.metadata?.title,t=e?.data?.metadata?.description;return et(je,{children:[A("h1",{className:"text-3xl font-bold",children:r}),A("p",{className:"my-4 text-gray-500",children:t}),A(ue,{}),A("hr",{className:"my-10 border-gray-200"})]})}import{useState as U}from"react";import{ThumbsUp as rt,ThumbsDown as ot}from"lucide-react";import{jsx as Y,jsxs as ge}from"react/jsx-runtime";function Q({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:u="",optional:g=!1}){return ge("div",{className:p("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)"})]}),r==="textarea"?Y("textarea",{id:o,name:o,className:p("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",u),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:l,maxLength:500}):Y("input",{type:r,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:a,onChange:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as tt}from"lucide-react";import{jsx as he}from"react/jsx-runtime";function _({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return he("button",{type:t,disabled:a,className:p("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?he(tt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as at,FormSyncForm as nt}from"formsync";import{Fragment as be,jsx as h,jsxs as k}from"react/jsx-runtime";function xe(){let[e,r]=U(null),{docstraConfig:t}=c(),[o,a]=U(""),[n,s]=U(!1),[l,u]=U(null),g="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-10 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),r(null),a("")},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:()=>r("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(rt,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),k("button",{onClick:()=>r("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(ot,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&k(nt,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{u(i.message)},children:[h(Q,{value:o,id:"message",onChange:i=>a(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(at,{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 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as st}from"react/jsx-runtime";function ye(){let{pageData:e}=c();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return st("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{usePathname as it}from"next/navigation";import ve from"next/link";import{ArrowLeftIcon as lt,ArrowRightIcon as ct}from"lucide-react";import{jsx as I,jsxs as R}from"react/jsx-runtime";function we(){let e=it(),{docstraConfig:r}=c(),t=r?.sidebar?.links?.flatMap(s=>s.items),o=t.findIndex(s=>s.href===e),a=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:[a?R(ve,{href:a.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[I("span",{className:"text-gray-500",children:"Previous"}),R("p",{className:"flex items-center font-medium",children:[I(lt,{className:"size-5 mr-2"}),a.name]})]}):I("div",{}),n?R(ve,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[I("span",{className:"text-gray-500",children:"Next"}),R("p",{className:"flex items-center font-medium",children:[n.name,I(ct,{className:"size-5 ml-2"})]})]}):I("div",{})]})}import{jsx as T,jsxs as mt}from"react/jsx-runtime";function to({children:e}){let{docstraConfig:r}=c();return mt("main",{className:"flex-1 px-4 md:px-8 py-10 text-base/7 prose max-w-none",children:[T(me,{}),T(fe,{}),e,r?.feedback?.enabled&&T(xe,{}),T(ye,{}),T(we,{})]})}import{CheckIcon as dt,CopyIcon as pt}from"lucide-react";import{Highlight as ut,themes as ft}from"prism-react-renderer";import{useState as gt}from"react";import{jsx as y,jsxs as W}from"react/jsx-runtime";function io(e){let{filename:r,children:t,className:o}=e,a=!o?.includes("language-"),n=typeof t=="string"?t:t?.props?.children||"";if(a)return y("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 text-gray-800 text-sm",children:n});let[s,l]=gt(!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:r||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(dt,{className:"size-4"}):y(pt,{className:"size-4"})})]}),y(ut,{theme:ft.vsLight,code:n.trim(),language:g,children:({tokens:m,getLineProps:E,getTokenProps:H})=>y("pre",{className:"p-4 font-mono whitespace-pre overflow-x-auto",children:m.map((z,$)=>W("div",{...E({line:z}),children:[y("span",{className:"text-slate-500 mr-4 select-none",children:$+1}),z.map((M,B)=>y("span",{...H({token:M})},B))]},$))})})]})}export{to as DocstraBody,io as DocstraCodeBlock,$t as DocstraHeader,lr as DocstraPage,Et as DocstraProvider,c as useDocstra};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),r=[],n=null;for(let o of t){o=o.trim();let
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";var N=Object.create;var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},m=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!O.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(n=S(t,o))||n.enumerable});return e};var d=(e,t,r)=>(r=e!=null?N(F(e)):{},m(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),J=e=>m(p({},"__esModule",{value:!0}),e);var L={};E(L,{default:()=>y});module.exports=J(L);var h=d(require("gray-matter"));function l(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function g(e){let t=e.split(`
|
|
2
|
+
`),r=[],n=null;for(let o of t){o=o.trim();let i=o.match(/^##\s+(.*)/),a=o.match(/^###\s+(.*)/);if(i){let s=i[1].trim();n={id:l(s),text:s,children:[]},r.push(n)}if(a&&n){let s=a[1].trim(),c=l(s);n.children.push({id:c,text:s})}}return r}var f=require("unist-util-visit");function u(){return e=>{(0,f.visit)(e,"element",t=>{if(t.tagName!=="code")return;t.properties||(t.properties={});let r=t.data?.meta||"";if(r){let n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"']+)))?/g,o;for(;(o=n.exec(r))!==null;){let i=o[1],a=o[2]||o[3]||o[4]||!0;t.properties[i]=a}}Array.isArray(t.properties.className)&&(t.properties.className=t.properties.className.join(" "))})}}var x=require("child_process");async function y(e){let t=this.async();try{let{compile:r}=await import("@mdx-js/mdx"),{content:n,data:o}=(0,h.default)(e),i=await r(n,{outputFormat:"program",development:this.mode==="development",rehypePlugins:[[u]]}),a=null;try{a=(0,x.execSync)(`git log -1 --format=%aI "${this.resourcePath}"`,{encoding:"utf-8"}).trim()}catch{a=null}let s=`export const metadata = ${JSON.stringify(o)};`,c=`export const raw = ${JSON.stringify(e)};`,C=g(e),$=`export const tableOfContents = ${JSON.stringify(C)};`,H="export const mdxContent = MDXContent;",w=`export const lastUpdated = ${JSON.stringify(a)};`,M=`
|
|
3
|
+
${i.value}
|
|
4
|
+
${s}
|
|
5
|
+
${c}
|
|
6
|
+
${$}
|
|
7
|
+
${H}
|
|
8
|
+
${w}
|
|
9
|
+
`;t(null,M)}catch(r){t(r)}}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
`),o=[],n=null;for(let e of t){e=e.trim();let
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import y from"gray-matter";function p(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function l(r){let t=r.split(`
|
|
2
|
+
`),o=[],n=null;for(let e of t){e=e.trim();let i=e.match(/^##\s+(.*)/),a=e.match(/^###\s+(.*)/);if(i){let s=i[1].trim();n={id:p(s),text:s,children:[]},o.push(n)}if(a&&n){let s=a[1].trim(),c=p(s);n.children.push({id:c,text:s})}}return o}import{visit as x}from"unist-util-visit";function m(){return r=>{x(r,"element",t=>{if(t.tagName!=="code")return;t.properties||(t.properties={});let o=t.data?.meta||"";if(o){let n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"']+)))?/g,e;for(;(e=n.exec(o))!==null;){let i=e[1],a=e[2]||e[3]||e[4]||!0;t.properties[i]=a}}Array.isArray(t.properties.className)&&(t.properties.className=t.properties.className.join(" "))})}}import{execSync as C}from"child_process";async function $(r){let t=this.async();try{let{compile:o}=await import("@mdx-js/mdx"),{content:n,data:e}=y(r),i=await o(n,{outputFormat:"program",development:this.mode==="development",rehypePlugins:[[m]]}),a=null;try{a=C(`git log -1 --format=%aI "${this.resourcePath}"`,{encoding:"utf-8"}).trim()}catch{a=null}let s=`export const metadata = ${JSON.stringify(e)};`,c=`export const raw = ${JSON.stringify(r)};`,d=l(r),g=`export const tableOfContents = ${JSON.stringify(d)};`,f="export const mdxContent = MDXContent;",u=`export const lastUpdated = ${JSON.stringify(a)};`,h=`
|
|
3
|
+
${i.value}
|
|
4
|
+
${s}
|
|
5
|
+
${c}
|
|
6
|
+
${g}
|
|
7
|
+
${f}
|
|
8
|
+
${u}
|
|
9
|
+
`;t(null,h)}catch(o){t(o)}}export{$ as default};
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-DYyitlml.mjs';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -13,12 +13,13 @@ declare const defaultMdxComponents: {
|
|
|
13
13
|
h4: (props: any) => react_jsx_runtime.JSX.Element;
|
|
14
14
|
h5: (props: any) => react_jsx_runtime.JSX.Element;
|
|
15
15
|
p: (props: any) => react_jsx_runtime.JSX.Element;
|
|
16
|
-
hr: () => react_jsx_runtime.JSX.Element;
|
|
16
|
+
hr: (props: any) => react_jsx_runtime.JSX.Element;
|
|
17
17
|
a: (props: any) => react_jsx_runtime.JSX.Element;
|
|
18
18
|
ul: (props: any) => react_jsx_runtime.JSX.Element;
|
|
19
19
|
li: (props: any) => react_jsx_runtime.JSX.Element;
|
|
20
20
|
ol: (props: any) => react_jsx_runtime.JSX.Element;
|
|
21
21
|
blockquote: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
pre: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
declare function getPageData(slug: string[], docs: any[]): any;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-DYyitlml.js';
|
|
2
2
|
import { NextConfig } from 'next';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -13,12 +13,13 @@ declare const defaultMdxComponents: {
|
|
|
13
13
|
h4: (props: any) => react_jsx_runtime.JSX.Element;
|
|
14
14
|
h5: (props: any) => react_jsx_runtime.JSX.Element;
|
|
15
15
|
p: (props: any) => react_jsx_runtime.JSX.Element;
|
|
16
|
-
hr: () => react_jsx_runtime.JSX.Element;
|
|
16
|
+
hr: (props: any) => react_jsx_runtime.JSX.Element;
|
|
17
17
|
a: (props: any) => react_jsx_runtime.JSX.Element;
|
|
18
18
|
ul: (props: any) => react_jsx_runtime.JSX.Element;
|
|
19
19
|
li: (props: any) => react_jsx_runtime.JSX.Element;
|
|
20
20
|
ol: (props: any) => react_jsx_runtime.JSX.Element;
|
|
21
21
|
blockquote: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
pre: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
declare function getPageData(slug: string[], docs: any[]): any;
|
package/dist/server/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
slug: "${
|
|
3
|
-
path: "${
|
|
1
|
+
"use strict";var _=Object.create;var y=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var H=(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 I(t))!B.call(e,n)&&n!==r&&y(e,n,{get:()=>t[n],enumerable:!(o=M(t,n))||o.enumerable});return e};var l=(e,t,r)=>(r=e!=null?_(L(e)):{},w(t||!e||!e.__esModule?y(r,"default",{value:e,enumerable:!0}):r,e)),U=e=>w(y({},"__esModule",{value:!0}),e);var G={};H(G,{createSource:()=>R,defaultMdxComponents:()=>J,defineDocstraConfig:()=>z,getPageData:()=>Q,withDocstra:()=>X});module.exports=U(G);function z(e){return e}var d=l(require("fs")),f=l(require("path"));var u={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m"},i={info:e=>{console.log(`${u.blue}[Docstra]${u.reset} ${e}`)},success:e=>{console.log(`${u.green}[Docstra]${u.reset} ${e}`)},warn:e=>{console.warn(`${u.yellow}[Docstra Warning]${u.reset} ${e}`)},error:(e,t)=>{console.error(`${u.red}[Docstra Error]${u.reset} ${e}`),t&&console.error(t)}};function g(e){let t=process.cwd(),r=f.default.join(t,".docstra"),o=f.default.join(r,"index.ts");d.default.existsSync(e)||(i.error(`Content directory not found: ${e}`),i.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),d.default.existsSync(r)||d.default.mkdirSync(r,{recursive:!0});let n=v(e);n.length===0&&i.warn(`No .md or .mdx files found in ${e}`);let s=[],c=[];n.forEach((D,q)=>{let O=f.default.relative(r,D).replace(/\\/g,"/"),m=`d${q}`;s.push(`import * as ${m} from "${O}?docstra";`);let b=f.default.relative(e,D).replace(/\\/g,"/"),W=A(b);c.push(`{
|
|
2
|
+
slug: "${W}",
|
|
3
|
+
path: "${b}",
|
|
4
4
|
data: {
|
|
5
|
-
metadata: ${
|
|
6
|
-
raw: ${
|
|
7
|
-
tableOfContents: ${
|
|
8
|
-
mdxContent: ${
|
|
5
|
+
metadata: ${m}.metadata,
|
|
6
|
+
raw: ${m}.raw,
|
|
7
|
+
tableOfContents: ${m}.tableOfContents,
|
|
8
|
+
mdxContent: ${m}.mdxContent,
|
|
9
|
+
lastUpdated: ${m}.lastUpdated,
|
|
9
10
|
}
|
|
10
11
|
}`)});let P=`// @ts-nocheck -- auto generated by docstra
|
|
11
12
|
${s.join(`
|
|
12
13
|
`)}
|
|
13
14
|
|
|
14
15
|
export const docs = [
|
|
15
|
-
${
|
|
16
|
+
${c.join(`,
|
|
16
17
|
`)}
|
|
17
18
|
];
|
|
18
|
-
`;d.default.writeFileSync(o,P,"utf8")}function
|
|
19
|
+
`;d.default.writeFileSync(o,P,"utf8")}function v(e){return d.default.readdirSync(e).flatMap(t=>{let r=f.default.join(e,t);return d.default.statSync(r).isDirectory()?v(r):t.endsWith(".md")||t.endsWith(".mdx")?[r]:[]})}function A(e){return e.replace(/\\/g,"/").replace(/\/index\.(md|mdx)$/,"").replace(/\.(md|mdx)$/,"")}var C=!1,$=null;async function N(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]),i.info("Dev server started..."),o.on("all",async(n,s)=>{!s.endsWith(".md")&&!s.endsWith(".mdx")&&!s.endsWith("docstra.config.ts")||($&&clearTimeout($),$=setTimeout(async()=>{await g(e)},200),i.info("MDX content rebuilt successfully"))}),process.on("exit",()=>{o.closed||o.close()})}var h=l(require("path")),k=l(require("fs"));var V="docs/content";function T(){let e=process.cwd(),t=h.default.join(e,"docstra.config.ts"),r={};if(k.default.existsSync(t))try{delete require.cache[require.resolve(t)];let n=require(t);r=n.default??n}catch(n){i.error("Failed to load docstra.config.ts",n),process.exit(1)}else i.warn("No docstra.config.ts found, using defaults");let o=r.contentDir?h.default.resolve(e,r.contentDir):h.default.join(e,V);return{root:e,contentDir:o,userConfig:r}}var S=!1;function X(e={}){let t=process.env.NODE_ENV==="development",r=process.env.NODE_ENV==="production",o=T().contentDir;S||(S=!0,t&&N(o),r&&(g(o),i.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,c)=>(s.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:require.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(s,c):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 p({children:e,level:t}){let r=`h${t}`,n=F(typeof e=="string"?e:"");return(0,x.jsxs)(r,{id:n,className:"group",children:[(0,x.jsx)("a",{className:"not-prose",href:`#${n}`,children:e}),(0,x.jsx)(E.LinkIcon,{className:"inline-block ml-2 size-5 text-gray-400 opacity-0 group-hover:opacity-100 transition"})]})}var j=l(require("next/link")),a=require("react/jsx-runtime"),J={h1:e=>(0,a.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:e.children}),h2:e=>(0,a.jsx)(p,{...e,level:2}),h3:e=>(0,a.jsx)(p,{...e,level:3}),h4:e=>(0,a.jsx)(p,{...e,level:4}),h5:e=>(0,a.jsx)(p,{...e,level:5}),p:e=>(0,a.jsx)("p",{children:e.children}),hr:e=>(0,a.jsx)("hr",{...e,className:"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",{children:e.children}),li:e=>(0,a.jsx)("li",{children:e.children}),ol:e=>(0,a.jsx)("ol",{children:e.children}),blockquote:e=>(0,a.jsx)("blockquote",{className:"not-italic",children:e.children}),pre:e=>(0,a.jsx)("pre",{className:"not-prose",children:e.children})};function Q(e,t){return t.find(o=>o.slug===(e?.join("/")||"index"))}function R(e){return{getPage:t=>{let r=t?.join("/")||"index",o=e.find(c=>c.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=>{let c=s.slug==="index"?"":s.slug.replace(/\/?index$/,"");return{url:`${t}/${c}`.replace(/\/$/,""),lastModified:r,changeFrequency:o,priority:n}})}}0&&(module.exports={createSource,defaultMdxComponents,defineDocstraConfig,getPageData,withDocstra});
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
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
|
|
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 I(e){return e}import m 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"},i={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");m.existsSync(e)||(i.error(`Content directory not found: ${e}`),i.error(`Please create "${e}" or update "contentDir" in docstra.config.ts`),process.exit(1)),m.existsSync(r)||m.mkdirSync(r,{recursive:!0});let n=D(e);n.length===0&&i.warn(`No .md or .mdx files found in ${e}`);let s=[],c=[];n.forEach((h,S)=>{let F=p.relative(r,h).replace(/\\/g,"/"),u=`d${S}`;s.push(`import * as ${u} from "${F}?docstra";`);let $=p.relative(e,h).replace(/\\/g,"/"),E=j($);c.push(`{
|
|
2
2
|
slug: "${E}",
|
|
3
|
-
path: "${
|
|
3
|
+
path: "${$}",
|
|
4
4
|
data: {
|
|
5
|
-
metadata: ${
|
|
6
|
-
raw: ${
|
|
7
|
-
tableOfContents: ${
|
|
8
|
-
mdxContent: ${
|
|
5
|
+
metadata: ${u}.metadata,
|
|
6
|
+
raw: ${u}.raw,
|
|
7
|
+
tableOfContents: ${u}.tableOfContents,
|
|
8
|
+
mdxContent: ${u}.mdxContent,
|
|
9
|
+
lastUpdated: ${u}.lastUpdated,
|
|
9
10
|
}
|
|
10
|
-
}`)});let
|
|
11
|
-
${
|
|
11
|
+
}`)});let T=`// @ts-nocheck -- auto generated by docstra
|
|
12
|
+
${s.join(`
|
|
12
13
|
`)}
|
|
13
14
|
|
|
14
15
|
export const docs = [
|
|
15
|
-
${
|
|
16
|
+
${c.join(`,
|
|
16
17
|
`)}
|
|
17
18
|
];
|
|
18
|
-
`;
|
|
19
|
+
`;m.writeFileSync(o,T,"utf8")}function D(e){return m.readdirSync(e).flatMap(t=>{let r=p.join(e,t);return m.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 b=!1,x=null;async function w(e){if(b)return;b=!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]),i.info("Dev server started..."),o.on("all",async(n,s)=>{!s.endsWith(".md")&&!s.endsWith(".mdx")&&!s.endsWith("docstra.config.ts")||(x&&clearTimeout(x),x=setTimeout(async()=>{await g(e)},200),i.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 v(){let e=process.cwd(),t=y.join(e,"docstra.config.ts"),r={};if(P.existsSync(t))try{delete d.cache[d.resolve(t)];let n=d(t);r=n.default??n}catch(n){i.error("Failed to load docstra.config.ts",n),process.exit(1)}else i.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=v().contentDir;C||(C=!0,t&&w(o),r&&(g(o),i.info("MDX content generated successfully")));let n={...e.turbopack,rules:{...e.turbopack?.rules,"*.{md,mdx}":{loaders:[{loader:d.resolve("./docstra-loader")}],as:"*.js"}}};return{...e,turbopack:n,pageExtensions:e.pageExtensions??["ts","tsx","js","jsx","md","mdx"],webpack:(s,c)=>(s.module.rules.push({test:/\.(md|mdx)$/,resourceQuery:/docstra/,use:[{loader:d.resolve("./docstra-loader")}]}),typeof e.webpack=="function"?e.webpack(s,c):s)}}import{LinkIcon as O}from"lucide-react";function N(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}import{jsx as k,jsxs as W}from"react/jsx-runtime";function f({children:e,level:t}){let r=`h${t}`,n=N(typeof e=="string"?e:"");return W(r,{id:n,className:"group",children:[k("a",{className:"not-prose",href:`#${n}`,children:e}),k(O,{className:"inline-block ml-2 size-5 text-gray-400 opacity-0 group-hover:opacity-100 transition"})]})}import _ from"next/link";import{jsx as a}from"react/jsx-runtime";var fe={h1:e=>a("h1",{className:"text-3xl font-bold text-gray-900",children:e.children}),h2:e=>a(f,{...e,level:2}),h3:e=>a(f,{...e,level:3}),h4:e=>a(f,{...e,level:4}),h5:e=>a(f,{...e,level:5}),p:e=>a("p",{children:e.children}),hr:e=>a("hr",{...e,className:"border-gray-200"}),a:e=>e.href.startsWith("http")?a("a",{href:e.href,className:"underline underline-offset-4",...e,target:"_blank",rel:"noopener noreferrer",children:e.children}):a(_,{href:e.href,className:"underline underline-offset-4",...e,children:e.children}),ul:e=>a("ul",{children:e.children}),li:e=>a("li",{children:e.children}),ol:e=>a("ol",{children:e.children}),blockquote:e=>a("blockquote",{className:"not-italic",children:e.children}),pre:e=>a("pre",{className:"not-prose",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(c=>c.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=>{let c=s.slug==="index"?"":s.slug.replace(/\/?index$/,"");return{url:`${t}/${c}`.replace(/\/$/,""),lastModified:r,changeFrequency:o,priority:n}})}}export{he as createSource,fe as defaultMdxComponents,I as defineDocstraConfig,xe as getPageData,oe as withDocstra};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstra",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.6",
|
|
4
4
|
"bin": {
|
|
5
5
|
"docstra": "cli/index.js"
|
|
6
6
|
},
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tailwindcss/cli": "^4.1.17",
|
|
39
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
39
40
|
"@types/node": "^24.10.1",
|
|
40
41
|
"@types/react": "^19.2.2",
|
|
41
42
|
"@types/react-dom": "^19.2.2",
|