docstra 0.1.0 → 1.0.1

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/package.json CHANGED
@@ -1,25 +1,44 @@
1
1
  {
2
2
  "name": "docstra",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
+ "description": "A Modern Documentation Framework for Next.js",
5
+ "keywords": [
6
+ "next",
7
+ "nextjs",
8
+ "documentation",
9
+ "docs",
10
+ "docstra",
11
+ "nextra",
12
+ "tailwindcss"
13
+ ],
14
+ "author": "@sudhucodes",
4
15
  "files": [
5
16
  "dist"
6
17
  ],
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
18
+ "types": "./dist/client/index.d.ts",
10
19
  "exports": {
11
20
  ".": {
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js"
21
+ "import": "./dist/client/index.mjs",
22
+ "require": "./dist/client/index.js"
23
+ },
24
+ "./server": {
25
+ "import": "./dist/server/index.mjs",
26
+ "require": "./dist/server/index.js"
27
+ },
28
+ "./config": {
29
+ "import": "./dist/server/index.mjs",
30
+ "require": "./dist/server/index.js"
14
31
  },
15
32
  "./styles.css": "./dist/styles.css"
16
33
  },
17
34
  "scripts": {
18
- "build": "tsup && npm run build:css",
19
- "build:css": "npx @tailwindcss/cli -i ./src/input.css -o ./dist/styles.css",
35
+ "build": "npm run prettier && npm run build:ts && npm run build:css",
36
+ "build:ts": "tsup",
37
+ "build:css": "npx @tailwindcss/cli -i ./src/styles/input.css -o ./dist/styles.css",
20
38
  "prettier": "prettier --write src"
21
39
  },
22
40
  "devDependencies": {
41
+ "@types/node": "^24.10.1",
23
42
  "@types/react": "^19.2.2",
24
43
  "@types/react-dom": "^19.2.2",
25
44
  "prettier": "^3.6.2",
@@ -28,10 +47,15 @@
28
47
  },
29
48
  "dependencies": {
30
49
  "@tailwindcss/cli": "^4.1.17",
50
+ "clsx": "^2.1.1",
51
+ "gray-matter": "^4.0.3",
31
52
  "lucide-react": "^0.554.0",
32
53
  "next": "^16.0.3",
54
+ "next-mdx-remote": "^5.0.0",
55
+ "prism-react-renderer": "^2.4.1",
33
56
  "react": "^18 || ^19",
34
57
  "react-dom": "^18 || ^19",
58
+ "react-toast-msg": "^2.2.6",
35
59
  "tailwind-merge": "^3.4.0",
36
60
  "tailwindcss": "^4.1.17"
37
61
  }
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- "use client";
2
- "use strict";var B=Object.create;var g=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var o in t)g(e,o,{get:t[o],enumerable:!0})},k=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of E(t))!O.call(e,r)&&r!==o&&g(e,r,{get:()=>t[r],enumerable:!(i=R(t,r))||i.enumerable});return e};var H=(e,t,o)=>(o=e!=null?B(M(e)):{},k(t||!e||!e.__esModule?g(o,"default",{value:e,enumerable:!0}):o,e)),I=e=>k(g({},"__esModule",{value:!0}),e);var Q={};T(Q,{DocstraLayout:()=>F,DocstraProvider:()=>v,useDocstra:()=>p});module.exports=I(Q);var l=require("react"),L=require("react/jsx-runtime"),C=(0,l.createContext)(null);function v({children:e,docstraConfig:t}){let[o,i]=(0,l.useState)(!1),[r,m]=(0,l.useState)(!1);return(0,L.jsx)(C.Provider,{value:{openSidebar:o,setOpenSidebar:i,docstraConfig:t,openSearchBox:r,setOpenSearchBox:m},children:e})}var p=()=>(0,l.useContext)(C);var x=require("lucide-react"),D=require("react");var d=require("tailwind-merge");var S=H(require("next/link")),b=require("react/jsx-runtime");function f({href:e,children:t,className:o,onNavigate:i,...r}){return e.startsWith("http")?(0,b.jsx)("a",{href:e,className:o,...r,target:"_blank",rel:"noopener noreferrer",children:t}):(0,b.jsx)(S.default,{href:e,className:o,onNavigate:i,...r,"aria-label":"Ns",children:t})}var n=require("react/jsx-runtime");function y(){let{openSidebar:e,setOpenSidebar:t,docstraConfig:o}=p(),i=[{name:"Guides",href:"/docs/guides"},{name:"APIs",href:"/docs/apis"},{name:"Examples",href:"/docs/examples"}];return(0,D.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 flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,n.jsx)(f,{href:"/",children:(0,n.jsx)("img",{src:o.navbar?.logo?.src||"/logo.png",alt:o.navbar?.logo?.alt||"Logo",className:(0,d.twMerge)("h-9.5 w-auto",o.navbar?.logo?.className)})}),(0,n.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[o.navbar?.links?.map(r=>(0,n.jsx)(f,{href:r.href,className:"px-6 hover:text-gray-500",children:r.name},r.name)),(0,n.jsx)(f,{href:o.navbar?.githubRepo||"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:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,n.jsx)(x.XIcon,{className:"size-6.5"}):(0,n.jsx)(x.TextAlignEnd,{className:"size-6.5"})})]})}var z=require("lucide-react"),A=require("next/navigation");var a=require("react/jsx-runtime");function N(){let{openSidebar:e,setOpenSidebar:t,setOpenSearchBox:o,docstraConfig:i}=p(),r=(0,A.usePathname)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:(0,d.twMerge)("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,a.jsxs)("aside",{className:(0,d.twMerge)("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen z-21 md:w-72 pb-10 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,a.jsxs)("div",{className:"flex items-center 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(!0),children:[(0,a.jsx)(z.SearchIcon,{className:"size-4.5"}),(0,a.jsx)("p",{children:"Search"}),(0,a.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,a.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,a.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),i.sidebar?.links?.map(m=>(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:m.section}),(0,a.jsx)("ul",{className:"mb-4",children:m.items.map(u=>(0,a.jsx)("li",{children:(0,a.jsxs)(f,{href:u.href,onNavigate:()=>e&&t(!1),className:(0,d.twMerge)("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg text-sm",r===u.href&&"bg-gray-100 text-gray-800"),children:[u.icon&&(0,a.jsx)(u.icon,{className:"size-4"}),(0,a.jsx)("span",{children:u.name})]})},u.href))})]},m.section))]})]})}var P=require("lucide-react");var h=require("react"),s=require("react/jsx-runtime");function w(){let{openSearchBox:e,setOpenSearchBox:t}=p(),[o,i]=(0,h.useState)("");return(0,h.useEffect)(()=>{console.log(`Search query: ${o}`)},[o]),(0,h.useEffect)(()=>{let r=m=>{m.ctrlKey&&m.key==="k"&&(m.preventDefault(),t(!0))};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[]),(0,s.jsx)("div",{onClick:()=>{t(!1),i("")},className:(0,d.twMerge)("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,s.jsx)("div",{onClick:r=>r.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:(0,s.jsx)("form",{className:(0,d.twMerge)("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md"),children:e&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(P.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,s.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search components",spellCheck:"false",autoFocus:!0,value:o,onChange:r=>i(r.target.value),name:"searchQuery",required:!0}),(0,s.jsxs)("svg",{className:"h-4.5 shrink-0 w-auto mr-3",width:"29",height:"18",viewBox:"0 0 29 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M13.5 2.25a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 1 0 2.25-2.25h-9a2.25 2.25 0 1 0 2.25 2.25v-9A2.25 2.25 0 1 0 4.5 6.75h9a2.25 2.25 0 0 0 0-4.5",stroke:"#99A1AF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M25.986 14 21.45 8.89l4.438-4.69h2.058l-4.9 5.096v-.882L28.086 14zm-5.922 0V4.2h1.61V14z",fill:"#99A1AF"})]})]})})})})}var c=require("react/jsx-runtime");function K({children:e}){return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(y,{}),(0,c.jsx)(w,{}),(0,c.jsxs)("div",{className:"min-h-screen flex bg-white",children:[(0,c.jsx)(N,{}),(0,c.jsx)("main",{id:"docs-content",className:"w-full px-4 md:px-8 py-10",children:e})]})]})}function F({children:e,docstraConfig:t}){return(0,c.jsx)(v,{docstraConfig:t,children:(0,c.jsx)(K,{children:e})})}0&&(module.exports={DocstraLayout,DocstraProvider,useDocstra});
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{createContext as S,useContext as D,useState as v}from"react";import{jsx as z}from"react/jsx-runtime";var b=S(null);function y({children:e,docstraConfig:r}){let[o,n]=v(!1),[t,s]=v(!1);return z(b.Provider,{value:{openSidebar:o,setOpenSidebar:n,docstraConfig:r,openSearchBox:t,setOpenSearchBox:s},children:e})}var p=()=>D(b);import{TextAlignEnd as P,XIcon as B}from"lucide-react";import{useEffect as R}from"react";import{twMerge as i}from"tailwind-merge";import A from"next/link";import{jsx as N}from"react/jsx-runtime";function d({href:e,children:r,className:o,onNavigate:n,...t}){return e.startsWith("http")?N("a",{href:e,className:o,...t,target:"_blank",rel:"noopener noreferrer",children:r}):N(A,{href:e,className:o,onNavigate:n,...t,"aria-label":"Ns",children:r})}import{jsx as c,jsxs as w}from"react/jsx-runtime";function h(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:o}=p(),n=[{name:"Guides",href:"/docs/guides"},{name:"APIs",href:"/docs/apis"},{name:"Examples",href:"/docs/examples"}];return R(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),w("header",{className:"sticky top-0 z-10 flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[c(d,{href:"/",children:c("img",{src:o.navbar?.logo?.src||"/logo.png",alt:o.navbar?.logo?.alt||"Logo",className:i("h-9.5 w-auto",o.navbar?.logo?.className)})}),w("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[o.navbar?.links?.map(t=>c(d,{href:t.href,className:"px-6 hover:text-gray-500",children:t.name},t.name)),c(d,{href:o.navbar?.githubRepo||"https://github.com/sudhucodes/docstra",children:c("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:c("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"})})})]}),c("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?c(B,{className:"size-6.5"}):c(P,{className:"size-6.5"})})]})}import{SearchIcon as E}from"lucide-react";import{usePathname as M}from"next/navigation";import{Fragment as O,jsx as a,jsxs as f}from"react/jsx-runtime";function g(){let{openSidebar:e,setOpenSidebar:r,setOpenSearchBox:o,docstraConfig:n}=p(),t=M();return f(O,{children:[a("div",{className:i("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)}),f("aside",{className:i("sticky md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen z-21 md:w-72 pb-10 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:[f("div",{className:"flex items-center 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(!0),children:[a(E,{className:"size-4.5"}),a("p",{children:"Search"}),f("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[a("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),a("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),n.sidebar?.links?.map(s=>f("div",{children:[a("p",{className:"inline-flex items-center gap-2 mb-2 mt-2 px-2",children:s.section}),a("ul",{className:"mb-4",children:s.items.map(l=>a("li",{children:f(d,{href:l.href,onNavigate:()=>e&&r(!1),className:i("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg text-sm",t===l.href&&"bg-gray-100 text-gray-800"),children:[l.icon&&a(l.icon,{className:"size-4"}),a("span",{children:l.name})]})},l.href))})]},s.section))]})]})}import{SearchIcon as T}from"lucide-react";import{useEffect as k,useState as H}from"react";import{Fragment as I,jsx as m,jsxs as C}from"react/jsx-runtime";function x(){let{openSearchBox:e,setOpenSearchBox:r}=p(),[o,n]=H("");return k(()=>{console.log(`Search query: ${o}`)},[o]),k(()=>{let t=s=>{s.ctrlKey&&s.key==="k"&&(s.preventDefault(),r(!0))};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[]),m("div",{onClick:()=>{r(!1),n("")},className:i("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:m("div",{onClick:t=>t.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:m("form",{className:i("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md"),children:e&&C(I,{children:[m(T,{className:"size-5.5 mx-3 shrink-0"}),m("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search components",spellCheck:"false",autoFocus:!0,value:o,onChange:t=>n(t.target.value),name:"searchQuery",required:!0}),C("svg",{className:"h-4.5 shrink-0 w-auto mr-3",width:"29",height:"18",viewBox:"0 0 29 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("path",{d:"M13.5 2.25a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 1 0 2.25-2.25h-9a2.25 2.25 0 1 0 2.25 2.25v-9A2.25 2.25 0 1 0 4.5 6.75h9a2.25 2.25 0 0 0 0-4.5",stroke:"#99A1AF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),m("path",{d:"M25.986 14 21.45 8.89l4.438-4.69h2.058l-4.9 5.096v-.882L28.086 14zm-5.922 0V4.2h1.61V14z",fill:"#99A1AF"})]})]})})})})}import{Fragment as F,jsx as u,jsxs as L}from"react/jsx-runtime";function K({children:e}){return L(F,{children:[u(h,{}),u(x,{}),L("div",{className:"min-h-screen flex bg-white",children:[u(g,{}),u("main",{id:"docs-content",className:"w-full px-4 md:px-8 py-10",children:e})]})]})}function ye({children:e,docstraConfig:r}){return u(y,{docstraConfig:r,children:u(K,{children:e})})}export{ye as DocstraLayout,y as DocstraProvider,p as useDocstra};