docstra 1.3.0 → 1.4.0

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.
@@ -7,10 +7,22 @@ interface DocstraContextType {
7
7
  docstraConfig: DocstraConfig;
8
8
  openSearchBox: boolean;
9
9
  setOpenSearchBox: (open: boolean) => void;
10
+ mdxData: mdxDataContent;
11
+ }
12
+ interface mdxDataContent {
13
+ metadata: Record<string, any>;
14
+ mdxContent: string;
15
+ rawMdxContent: string;
16
+ mdxFilePath: string;
10
17
  }
11
18
  interface DocstraConfig {
12
19
  siteName?: string;
13
20
  editOnGithub?: boolean;
21
+ feedback?: {
22
+ enabled?: boolean;
23
+ formSyncFormID?: string;
24
+ watermark?: boolean;
25
+ };
14
26
  formSyncFormID?: string;
15
27
  githubRepo?: string;
16
28
  navbar?: {
@@ -39,9 +51,10 @@ interface DocsLinkGroup {
39
51
  items: DocsLinkItem[];
40
52
  }
41
53
 
42
- declare function DocstraProvider({ children, docstraConfig }: {
54
+ declare function DocstraProvider({ children, docstraConfig, mdxData }: {
43
55
  children: React$1.ReactNode;
44
56
  docstraConfig: DocstraConfig;
57
+ mdxData: mdxDataContent;
45
58
  }): react_jsx_runtime.JSX.Element;
46
59
  declare function useDocstra(): DocstraContextType;
47
60
 
@@ -55,10 +68,8 @@ declare function DocstraPage({ children }: {
55
68
 
56
69
  interface Props {
57
70
  children: React.ReactNode;
58
- metadata: any;
59
- mdxContent: string;
60
71
  }
61
- declare function DocstraBody({ children, metadata, mdxContent }: Props): react_jsx_runtime.JSX.Element;
72
+ declare function DocstraBody({ children }: Props): react_jsx_runtime.JSX.Element;
62
73
 
63
74
  declare function DocstraTOC({ mdxFilePath, rawMdxContent }: {
64
75
  mdxFilePath: string;
@@ -7,10 +7,22 @@ interface DocstraContextType {
7
7
  docstraConfig: DocstraConfig;
8
8
  openSearchBox: boolean;
9
9
  setOpenSearchBox: (open: boolean) => void;
10
+ mdxData: mdxDataContent;
11
+ }
12
+ interface mdxDataContent {
13
+ metadata: Record<string, any>;
14
+ mdxContent: string;
15
+ rawMdxContent: string;
16
+ mdxFilePath: string;
10
17
  }
11
18
  interface DocstraConfig {
12
19
  siteName?: string;
13
20
  editOnGithub?: boolean;
21
+ feedback?: {
22
+ enabled?: boolean;
23
+ formSyncFormID?: string;
24
+ watermark?: boolean;
25
+ };
14
26
  formSyncFormID?: string;
15
27
  githubRepo?: string;
16
28
  navbar?: {
@@ -39,9 +51,10 @@ interface DocsLinkGroup {
39
51
  items: DocsLinkItem[];
40
52
  }
41
53
 
42
- declare function DocstraProvider({ children, docstraConfig }: {
54
+ declare function DocstraProvider({ children, docstraConfig, mdxData }: {
43
55
  children: React$1.ReactNode;
44
56
  docstraConfig: DocstraConfig;
57
+ mdxData: mdxDataContent;
45
58
  }): react_jsx_runtime.JSX.Element;
46
59
  declare function useDocstra(): DocstraContextType;
47
60
 
@@ -55,10 +68,8 @@ declare function DocstraPage({ children }: {
55
68
 
56
69
  interface Props {
57
70
  children: React.ReactNode;
58
- metadata: any;
59
- mdxContent: string;
60
71
  }
61
- declare function DocstraBody({ children, metadata, mdxContent }: Props): react_jsx_runtime.JSX.Element;
72
+ declare function DocstraBody({ children }: Props): react_jsx_runtime.JSX.Element;
62
73
 
63
74
  declare function DocstraTOC({ mdxFilePath, rawMdxContent }: {
64
75
  mdxFilePath: string;
@@ -160,7 +160,8 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
160
160
  var DocstraContext = (0, import_react2.createContext)(null);
161
161
  function DocstraProvider({
162
162
  children,
163
- docstraConfig
163
+ docstraConfig,
164
+ mdxData
164
165
  }) {
165
166
  const [openSidebar, setOpenSidebar] = (0, import_react2.useState)(false);
166
167
  const [openSearchBox, setOpenSearchBox] = (0, import_react2.useState)(false);
@@ -172,7 +173,8 @@ function DocstraProvider({
172
173
  setOpenSidebar,
173
174
  docstraConfig,
174
175
  openSearchBox,
175
- setOpenSearchBox
176
+ setOpenSearchBox,
177
+ mdxData
176
178
  },
177
179
  children: [
178
180
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_toast_msg.ToastContainer, {}),
@@ -349,7 +351,8 @@ function DocstraBreadcrumbs() {
349
351
  var import_lucide_react5 = require("lucide-react");
350
352
  var import_react4 = require("react");
351
353
  var import_jsx_runtime8 = require("react/jsx-runtime");
352
- function DocstraPageButtons({ rawMdxContent }) {
354
+ function DocstraPageButtons() {
355
+ const { mdxData } = useDocstra();
353
356
  const [isCopied, setIsCopied] = (0, import_react4.useState)(false);
354
357
  const [href, setHref] = (0, import_react4.useState)(null);
355
358
  (0, import_react4.useEffect)(() => {
@@ -357,7 +360,7 @@ function DocstraPageButtons({ rawMdxContent }) {
357
360
  }, []);
358
361
  const prompt = `Read from this URL: ${href} and explain it to me.`;
359
362
  const handleCopy = () => {
360
- navigator.clipboard.writeText(rawMdxContent);
363
+ navigator.clipboard.writeText(mdxData?.rawMdxContent);
361
364
  setIsCopied(true);
362
365
  setTimeout(() => setIsCopied(false), 3e3);
363
366
  };
@@ -389,11 +392,12 @@ function DocstraPageButtons({ rawMdxContent }) {
389
392
 
390
393
  // src/client/docstra-page-head.tsx
391
394
  var import_jsx_runtime9 = require("react/jsx-runtime");
392
- function DocstraPageHead({ metadata, mdxContent }) {
395
+ function DocstraPageHead() {
396
+ const { mdxData } = useDocstra();
393
397
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
394
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "text-3xl font-bold", children: metadata.title }),
395
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "my-4 text-gray-500", children: metadata.description }),
396
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DocstraPageButtons, { rawMdxContent: mdxContent }),
398
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "text-3xl font-bold", children: mdxData?.metadata?.title }),
399
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "my-4 text-gray-500", children: mdxData?.metadata?.description }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DocstraPageButtons, {}),
397
401
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "my-10 border-gray-200" })
398
402
  ] });
399
403
  }
@@ -530,7 +534,7 @@ function DocstraFeedback() {
530
534
  "form",
531
535
  {
532
536
  className: "flex flex-col gap-2",
533
- action: `https://formsync.app/v1/s/${docstraConfig?.formSyncFormID || "your-form-id"}`,
537
+ action: `https://formsync.app/v1/s/${docstraConfig?.feedback?.formSyncFormID || ""}`,
534
538
  method: "POST",
535
539
  children: [
536
540
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -548,10 +552,17 @@ function DocstraFeedback() {
548
552
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "hidden", name: "page", value: window.location.href }),
549
553
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "hidden", name: "_redirect", value: window.location.href }),
550
554
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { label: "Submit", className: "w-max text-sm" }),
551
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-left text-sm text-gray-500 mt-6", children: [
555
+ docstraConfig?.feedback?.watermark !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-left text-sm text-gray-500 mt-6", children: [
552
556
  "Powered by",
553
557
  " ",
554
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: "https://www.formsync.app?utm_source=formsync-docs", className: "text-gray-800", children: "FormSync" })
558
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
559
+ "a",
560
+ {
561
+ href: `https://www.formsync.app?utm_source=${docstraConfig?.githubRepo}`,
562
+ className: "text-gray-800",
563
+ children: "FormSync"
564
+ }
565
+ )
555
566
  ] })
556
567
  ]
557
568
  }
@@ -605,12 +616,13 @@ function DocstraPagination() {
605
616
 
606
617
  // src/client/docs-body.tsx
607
618
  var import_jsx_runtime14 = require("react/jsx-runtime");
608
- function DocstraBody({ children, metadata, mdxContent }) {
619
+ function DocstraBody({ children }) {
620
+ const { docstraConfig } = useDocstra();
609
621
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("main", { className: "flex-1 px-4 md:px-8 py-10 max-w-full text-base/7", children: [
610
622
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraBreadcrumbs, {}),
611
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraPageHead, { metadata, mdxContent }),
623
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraPageHead, {}),
612
624
  children,
613
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraFeedback, {}),
625
+ docstraConfig?.feedback?.enabled && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraFeedback, {}),
614
626
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocstraPagination, {})
615
627
  ] });
616
628
  }
@@ -118,7 +118,8 @@ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
118
118
  var DocstraContext = createContext(null);
119
119
  function DocstraProvider({
120
120
  children,
121
- docstraConfig
121
+ docstraConfig,
122
+ mdxData
122
123
  }) {
123
124
  const [openSidebar, setOpenSidebar] = useState2(false);
124
125
  const [openSearchBox, setOpenSearchBox] = useState2(false);
@@ -130,7 +131,8 @@ function DocstraProvider({
130
131
  setOpenSidebar,
131
132
  docstraConfig,
132
133
  openSearchBox,
133
- setOpenSearchBox
134
+ setOpenSearchBox,
135
+ mdxData
134
136
  },
135
137
  children: [
136
138
  /* @__PURE__ */ jsx2(ToastContainer, {}),
@@ -307,7 +309,8 @@ function DocstraBreadcrumbs() {
307
309
  import { CheckIcon, CopyIcon } from "lucide-react";
308
310
  import { useEffect as useEffect3, useState as useState3 } from "react";
309
311
  import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
310
- function DocstraPageButtons({ rawMdxContent }) {
312
+ function DocstraPageButtons() {
313
+ const { mdxData } = useDocstra();
311
314
  const [isCopied, setIsCopied] = useState3(false);
312
315
  const [href, setHref] = useState3(null);
313
316
  useEffect3(() => {
@@ -315,7 +318,7 @@ function DocstraPageButtons({ rawMdxContent }) {
315
318
  }, []);
316
319
  const prompt = `Read from this URL: ${href} and explain it to me.`;
317
320
  const handleCopy = () => {
318
- navigator.clipboard.writeText(rawMdxContent);
321
+ navigator.clipboard.writeText(mdxData?.rawMdxContent);
319
322
  setIsCopied(true);
320
323
  setTimeout(() => setIsCopied(false), 3e3);
321
324
  };
@@ -347,11 +350,12 @@ function DocstraPageButtons({ rawMdxContent }) {
347
350
 
348
351
  // src/client/docstra-page-head.tsx
349
352
  import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
350
- function DocstraPageHead({ metadata, mdxContent }) {
353
+ function DocstraPageHead() {
354
+ const { mdxData } = useDocstra();
351
355
  return /* @__PURE__ */ jsxs7(Fragment3, { children: [
352
- /* @__PURE__ */ jsx9("h1", { className: "text-3xl font-bold", children: metadata.title }),
353
- /* @__PURE__ */ jsx9("p", { className: "my-4 text-gray-500", children: metadata.description }),
354
- /* @__PURE__ */ jsx9(DocstraPageButtons, { rawMdxContent: mdxContent }),
356
+ /* @__PURE__ */ jsx9("h1", { className: "text-3xl font-bold", children: mdxData?.metadata?.title }),
357
+ /* @__PURE__ */ jsx9("p", { className: "my-4 text-gray-500", children: mdxData?.metadata?.description }),
358
+ /* @__PURE__ */ jsx9(DocstraPageButtons, {}),
355
359
  /* @__PURE__ */ jsx9("hr", { className: "my-10 border-gray-200" })
356
360
  ] });
357
361
  }
@@ -488,7 +492,7 @@ function DocstraFeedback() {
488
492
  "form",
489
493
  {
490
494
  className: "flex flex-col gap-2",
491
- action: `https://formsync.app/v1/s/${docstraConfig?.formSyncFormID || "your-form-id"}`,
495
+ action: `https://formsync.app/v1/s/${docstraConfig?.feedback?.formSyncFormID || ""}`,
492
496
  method: "POST",
493
497
  children: [
494
498
  /* @__PURE__ */ jsx12(
@@ -506,10 +510,17 @@ function DocstraFeedback() {
506
510
  /* @__PURE__ */ jsx12("input", { type: "hidden", name: "page", value: window.location.href }),
507
511
  /* @__PURE__ */ jsx12("input", { type: "hidden", name: "_redirect", value: window.location.href }),
508
512
  /* @__PURE__ */ jsx12(Button, { label: "Submit", className: "w-max text-sm" }),
509
- /* @__PURE__ */ jsxs9("p", { className: "text-left text-sm text-gray-500 mt-6", children: [
513
+ docstraConfig?.feedback?.watermark !== false && /* @__PURE__ */ jsxs9("p", { className: "text-left text-sm text-gray-500 mt-6", children: [
510
514
  "Powered by",
511
515
  " ",
512
- /* @__PURE__ */ jsx12("a", { href: "https://www.formsync.app?utm_source=formsync-docs", className: "text-gray-800", children: "FormSync" })
516
+ /* @__PURE__ */ jsx12(
517
+ "a",
518
+ {
519
+ href: `https://www.formsync.app?utm_source=${docstraConfig?.githubRepo}`,
520
+ className: "text-gray-800",
521
+ children: "FormSync"
522
+ }
523
+ )
513
524
  ] })
514
525
  ]
515
526
  }
@@ -563,12 +574,13 @@ function DocstraPagination() {
563
574
 
564
575
  // src/client/docs-body.tsx
565
576
  import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
566
- function DocstraBody({ children, metadata, mdxContent }) {
577
+ function DocstraBody({ children }) {
578
+ const { docstraConfig } = useDocstra();
567
579
  return /* @__PURE__ */ jsxs11("main", { className: "flex-1 px-4 md:px-8 py-10 max-w-full text-base/7", children: [
568
580
  /* @__PURE__ */ jsx14(DocstraBreadcrumbs, {}),
569
- /* @__PURE__ */ jsx14(DocstraPageHead, { metadata, mdxContent }),
581
+ /* @__PURE__ */ jsx14(DocstraPageHead, {}),
570
582
  children,
571
- /* @__PURE__ */ jsx14(DocstraFeedback, {}),
583
+ docstraConfig?.feedback?.enabled && /* @__PURE__ */ jsx14(DocstraFeedback, {}),
572
584
  /* @__PURE__ */ jsx14(DocstraPagination, {})
573
585
  ] });
574
586
  }
@@ -3,6 +3,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  interface DocstraConfig {
4
4
  siteName?: string;
5
5
  editOnGithub?: boolean;
6
+ feedback?: {
7
+ enabled?: boolean;
8
+ formSyncFormID?: string;
9
+ watermark?: boolean;
10
+ };
6
11
  formSyncFormID?: string;
7
12
  githubRepo?: string;
8
13
  navbar?: {
@@ -3,6 +3,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  interface DocstraConfig {
4
4
  siteName?: string;
5
5
  editOnGithub?: boolean;
6
+ feedback?: {
7
+ enabled?: boolean;
8
+ formSyncFormID?: string;
9
+ watermark?: boolean;
10
+ };
6
11
  formSyncFormID?: string;
7
12
  githubRepo?: string;
8
13
  navbar?: {
@@ -101,9 +101,6 @@ function CreateHeading({ children, level }) {
101
101
  let fontSize;
102
102
  let iconSize;
103
103
  switch (level) {
104
- case 1:
105
- fontSize = "text-3xl";
106
- break;
107
104
  case 2:
108
105
  fontSize = "text-2xl";
109
106
  iconSize = "size-5";
@@ -124,7 +121,7 @@ function CreateHeading({ children, level }) {
124
121
  fontSize = "text-base";
125
122
  iconSize = "size-3.5";
126
123
  }
127
- return level === 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-3xl font-bold text-gray-900 mb-4", children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
124
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
128
125
  Heading,
129
126
  {
130
127
  id,
@@ -140,7 +137,7 @@ function CreateHeading({ children, level }) {
140
137
  // src/client/mdx-components.tsx
141
138
  var import_jsx_runtime2 = require("react/jsx-runtime");
142
139
  var defaultMdxComponents = {
143
- h1: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CreateHeading, { ...props, level: 1 }),
140
+ h1: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { className: "text-3xl font-bold text-gray-900 mb-4", children: props.children }),
144
141
  h2: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CreateHeading, { ...props, level: 2 }),
145
142
  h3: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CreateHeading, { ...props, level: 3 }),
146
143
  h4: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CreateHeading, { ...props, level: 4 }),
@@ -62,9 +62,6 @@ function CreateHeading({ children, level }) {
62
62
  let fontSize;
63
63
  let iconSize;
64
64
  switch (level) {
65
- case 1:
66
- fontSize = "text-3xl";
67
- break;
68
65
  case 2:
69
66
  fontSize = "text-2xl";
70
67
  iconSize = "size-5";
@@ -85,7 +82,7 @@ function CreateHeading({ children, level }) {
85
82
  fontSize = "text-base";
86
83
  iconSize = "size-3.5";
87
84
  }
88
- return level === 1 ? /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold text-gray-900 mb-4", children }) : /* @__PURE__ */ jsxs(
85
+ return /* @__PURE__ */ jsxs(
89
86
  Heading,
90
87
  {
91
88
  id,
@@ -101,7 +98,7 @@ function CreateHeading({ children, level }) {
101
98
  // src/client/mdx-components.tsx
102
99
  import { jsx as jsx2 } from "react/jsx-runtime";
103
100
  var defaultMdxComponents = {
104
- h1: (props) => /* @__PURE__ */ jsx2(CreateHeading, { ...props, level: 1 }),
101
+ h1: (props) => /* @__PURE__ */ jsx2("h1", { className: "text-3xl font-bold text-gray-900 mb-4", children: props.children }),
105
102
  h2: (props) => /* @__PURE__ */ jsx2(CreateHeading, { ...props, level: 2 }),
106
103
  h3: (props) => /* @__PURE__ */ jsx2(CreateHeading, { ...props, level: 3 }),
107
104
  h4: (props) => /* @__PURE__ */ jsx2(CreateHeading, { ...props, level: 4 }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docstra",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A Modern Documentation Framework for Next.js",
5
5
  "keywords": [
6
6
  "next",