docstra 1.0.0 → 1.1.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.
- package/README.md +43 -0
- package/dist/client/index.js +5 -2
- package/dist/client/index.mjs +5 -2
- package/dist/server/index.d.mts +9 -3
- package/dist/server/index.d.ts +9 -3
- package/dist/server/index.js +11 -9
- package/dist/server/index.mjs +11 -9
- package/dist/styles.css +0 -28
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# **Docstra**
|
|
2
|
+
|
|
3
|
+
Docstra is a modern documentation framework for Next.js. It's built with Tailwind CSS and MDX, making it easy to create beautiful and responsive documentation sites.
|
|
4
|
+
|
|
5
|
+
> Documentation of Docstra is coming soon. Stay tuned!
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- MDX support
|
|
10
|
+
- Custom content directories
|
|
11
|
+
- Works in monorepos
|
|
12
|
+
- Beautiful sidebar + TOC
|
|
13
|
+
- Edit-on-GitHub links
|
|
14
|
+
- Search coming soon
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install docstra
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// docstra.config.ts
|
|
26
|
+
export default defineDocstraConfig({
|
|
27
|
+
siteName: 'Docstra Site',
|
|
28
|
+
githubRepo: 'https://github.com/sudhucodes/test',
|
|
29
|
+
editOnGithub: true,
|
|
30
|
+
formSyncFormID: 'FORM_ID',
|
|
31
|
+
navbar: {
|
|
32
|
+
logo: {
|
|
33
|
+
link: '/docs'
|
|
34
|
+
},
|
|
35
|
+
links: [{ name: 'Guides', href: '/docs/guides' }]
|
|
36
|
+
},
|
|
37
|
+
sidebar: {
|
|
38
|
+
// sidebar links
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> Created and maintained with 💙 by [SudhuCodes](https://github.com/sudhucodes)
|
package/dist/client/index.js
CHANGED
|
@@ -663,8 +663,11 @@ function DocstraTOC({ mdxFilePath, rawMdxContent }) {
|
|
|
663
663
|
const lastScrollY = (0, import_react6.useRef)(0);
|
|
664
664
|
const observerRef = (0, import_react6.useRef)(null);
|
|
665
665
|
const pathname = (0, import_navigation5.usePathname)();
|
|
666
|
-
const baseUrlOfGithub = docstraConfig?.githubRepo || "https://github.com/sudhucodes/docstra
|
|
667
|
-
const
|
|
666
|
+
const baseUrlOfGithub = docstraConfig?.githubRepo || "https://github.com/sudhucodes/docstra";
|
|
667
|
+
const normalized = mdxFilePath.replace(/\\/g, "/");
|
|
668
|
+
const match = normalized.match(/\/docs\/(.+)$/);
|
|
669
|
+
const relativePath = match ? match[1] : "";
|
|
670
|
+
const githubLink = `${baseUrlOfGithub}/edit/main/docs/${relativePath}`;
|
|
668
671
|
(0, import_react6.useEffect)(() => {
|
|
669
672
|
const onScroll = () => {
|
|
670
673
|
const currentY = window.scrollY;
|
package/dist/client/index.mjs
CHANGED
|
@@ -621,8 +621,11 @@ function DocstraTOC({ mdxFilePath, rawMdxContent }) {
|
|
|
621
621
|
const lastScrollY = useRef(0);
|
|
622
622
|
const observerRef = useRef(null);
|
|
623
623
|
const pathname = usePathname5();
|
|
624
|
-
const baseUrlOfGithub = docstraConfig?.githubRepo || "https://github.com/sudhucodes/docstra
|
|
625
|
-
const
|
|
624
|
+
const baseUrlOfGithub = docstraConfig?.githubRepo || "https://github.com/sudhucodes/docstra";
|
|
625
|
+
const normalized = mdxFilePath.replace(/\\/g, "/");
|
|
626
|
+
const match = normalized.match(/\/docs\/(.+)$/);
|
|
627
|
+
const relativePath = match ? match[1] : "";
|
|
628
|
+
const githubLink = `${baseUrlOfGithub}/edit/main/docs/${relativePath}`;
|
|
626
629
|
useEffect4(() => {
|
|
627
630
|
const onScroll = () => {
|
|
628
631
|
const currentY = window.scrollY;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -38,10 +38,16 @@ interface FileContent {
|
|
|
38
38
|
mdxFilePath: string;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
declare function getFilePath(slug
|
|
42
|
-
|
|
41
|
+
declare function getFilePath({ slug, CONTENT_DIR }: {
|
|
42
|
+
slug: Slug;
|
|
43
|
+
CONTENT_DIR?: string;
|
|
44
|
+
}): string;
|
|
45
|
+
declare function getFileContents({ slug, CONTENT_DIR }: {
|
|
46
|
+
slug: Slug;
|
|
47
|
+
CONTENT_DIR?: string;
|
|
48
|
+
}): FileContent;
|
|
43
49
|
|
|
44
|
-
declare function defineDocstraConfig(config:
|
|
50
|
+
declare function defineDocstraConfig<T extends DocstraConfig>(config: T): T;
|
|
45
51
|
|
|
46
52
|
declare function DocstraMDXCompiler({ mdxContent, components }: {
|
|
47
53
|
mdxContent: string;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -38,10 +38,16 @@ interface FileContent {
|
|
|
38
38
|
mdxFilePath: string;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
declare function getFilePath(slug
|
|
42
|
-
|
|
41
|
+
declare function getFilePath({ slug, CONTENT_DIR }: {
|
|
42
|
+
slug: Slug;
|
|
43
|
+
CONTENT_DIR?: string;
|
|
44
|
+
}): string;
|
|
45
|
+
declare function getFileContents({ slug, CONTENT_DIR }: {
|
|
46
|
+
slug: Slug;
|
|
47
|
+
CONTENT_DIR?: string;
|
|
48
|
+
}): FileContent;
|
|
43
49
|
|
|
44
|
-
declare function defineDocstraConfig(config:
|
|
50
|
+
declare function defineDocstraConfig<T extends DocstraConfig>(config: T): T;
|
|
45
51
|
|
|
46
52
|
declare function DocstraMDXCompiler({ mdxContent, components }: {
|
|
47
53
|
mdxContent: string;
|
package/dist/server/index.js
CHANGED
|
@@ -41,24 +41,26 @@ module.exports = __toCommonJS(server_exports);
|
|
|
41
41
|
var import_fs = __toESM(require("fs"));
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_gray_matter = __toESM(require("gray-matter"));
|
|
44
|
-
var
|
|
45
|
-
function getFilePath(slug) {
|
|
44
|
+
var DEFAULT_CONTENT_DIR = import_path.default.join(process.cwd(), "app", "docs", "content");
|
|
45
|
+
function getFilePath({ slug, CONTENT_DIR }) {
|
|
46
46
|
const slugArray = Array.isArray(slug) && slug.length > 0 ? slug : ["index"];
|
|
47
|
+
const USER_CONTENT_DIR = process.cwd() + CONTENT_DIR;
|
|
48
|
+
const DIR = USER_CONTENT_DIR || DEFAULT_CONTENT_DIR;
|
|
47
49
|
const possiblePaths = [
|
|
48
|
-
import_path.default.join(
|
|
49
|
-
import_path.default.join(
|
|
50
|
-
import_path.default.join(
|
|
51
|
-
import_path.default.join(
|
|
50
|
+
import_path.default.join(DIR, ...slugArray) + ".mdx",
|
|
51
|
+
import_path.default.join(DIR, ...slugArray) + ".md",
|
|
52
|
+
import_path.default.join(DIR, ...slugArray, "index.mdx"),
|
|
53
|
+
import_path.default.join(DIR, ...slugArray, "index.md")
|
|
52
54
|
];
|
|
53
55
|
for (const filePath of possiblePaths) {
|
|
54
56
|
if (import_fs.default.existsSync(filePath)) {
|
|
55
57
|
return filePath;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
throw new Error(`\u274C MDX file not found
|
|
60
|
+
throw new Error(`\u274C MDX file not found in: ${DIR} `);
|
|
59
61
|
}
|
|
60
|
-
function getFileContents(slug) {
|
|
61
|
-
const filePath = getFilePath(slug);
|
|
62
|
+
function getFileContents({ slug, CONTENT_DIR }) {
|
|
63
|
+
const filePath = getFilePath({ slug, CONTENT_DIR: CONTENT_DIR || DEFAULT_CONTENT_DIR });
|
|
62
64
|
const rawFile = import_fs.default.readFileSync(filePath, "utf-8");
|
|
63
65
|
const { data, content } = (0, import_gray_matter.default)(rawFile);
|
|
64
66
|
return {
|
package/dist/server/index.mjs
CHANGED
|
@@ -2,24 +2,26 @@
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import matter from "gray-matter";
|
|
5
|
-
var
|
|
6
|
-
function getFilePath(slug) {
|
|
5
|
+
var DEFAULT_CONTENT_DIR = path.join(process.cwd(), "app", "docs", "content");
|
|
6
|
+
function getFilePath({ slug, CONTENT_DIR }) {
|
|
7
7
|
const slugArray = Array.isArray(slug) && slug.length > 0 ? slug : ["index"];
|
|
8
|
+
const USER_CONTENT_DIR = process.cwd() + CONTENT_DIR;
|
|
9
|
+
const DIR = USER_CONTENT_DIR || DEFAULT_CONTENT_DIR;
|
|
8
10
|
const possiblePaths = [
|
|
9
|
-
path.join(
|
|
10
|
-
path.join(
|
|
11
|
-
path.join(
|
|
12
|
-
path.join(
|
|
11
|
+
path.join(DIR, ...slugArray) + ".mdx",
|
|
12
|
+
path.join(DIR, ...slugArray) + ".md",
|
|
13
|
+
path.join(DIR, ...slugArray, "index.mdx"),
|
|
14
|
+
path.join(DIR, ...slugArray, "index.md")
|
|
13
15
|
];
|
|
14
16
|
for (const filePath of possiblePaths) {
|
|
15
17
|
if (fs.existsSync(filePath)) {
|
|
16
18
|
return filePath;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
throw new Error(`\u274C MDX file not found
|
|
21
|
+
throw new Error(`\u274C MDX file not found in: ${DIR} `);
|
|
20
22
|
}
|
|
21
|
-
function getFileContents(slug) {
|
|
22
|
-
const filePath = getFilePath(slug);
|
|
23
|
+
function getFileContents({ slug, CONTENT_DIR }) {
|
|
24
|
+
const filePath = getFilePath({ slug, CONTENT_DIR: CONTENT_DIR || DEFAULT_CONTENT_DIR });
|
|
23
25
|
const rawFile = fs.readFileSync(filePath, "utf-8");
|
|
24
26
|
const { data, content } = matter(rawFile);
|
|
25
27
|
return {
|
package/dist/styles.css
CHANGED
|
@@ -448,9 +448,6 @@
|
|
|
448
448
|
--tw-translate-y: calc(calc(1/2 * 100%) * -1);
|
|
449
449
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
450
450
|
}
|
|
451
|
-
.transform {
|
|
452
|
-
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
|
|
453
|
-
}
|
|
454
451
|
.animate-spin {
|
|
455
452
|
animation: var(--animate-spin);
|
|
456
453
|
}
|
|
@@ -1071,26 +1068,6 @@
|
|
|
1071
1068
|
inherits: false;
|
|
1072
1069
|
initial-value: 0;
|
|
1073
1070
|
}
|
|
1074
|
-
@property --tw-rotate-x {
|
|
1075
|
-
syntax: "*";
|
|
1076
|
-
inherits: false;
|
|
1077
|
-
}
|
|
1078
|
-
@property --tw-rotate-y {
|
|
1079
|
-
syntax: "*";
|
|
1080
|
-
inherits: false;
|
|
1081
|
-
}
|
|
1082
|
-
@property --tw-rotate-z {
|
|
1083
|
-
syntax: "*";
|
|
1084
|
-
inherits: false;
|
|
1085
|
-
}
|
|
1086
|
-
@property --tw-skew-x {
|
|
1087
|
-
syntax: "*";
|
|
1088
|
-
inherits: false;
|
|
1089
|
-
}
|
|
1090
|
-
@property --tw-skew-y {
|
|
1091
|
-
syntax: "*";
|
|
1092
|
-
inherits: false;
|
|
1093
|
-
}
|
|
1094
1071
|
@property --tw-space-y-reverse {
|
|
1095
1072
|
syntax: "*";
|
|
1096
1073
|
inherits: false;
|
|
@@ -1231,11 +1208,6 @@
|
|
|
1231
1208
|
--tw-translate-x: 0;
|
|
1232
1209
|
--tw-translate-y: 0;
|
|
1233
1210
|
--tw-translate-z: 0;
|
|
1234
|
-
--tw-rotate-x: initial;
|
|
1235
|
-
--tw-rotate-y: initial;
|
|
1236
|
-
--tw-rotate-z: initial;
|
|
1237
|
-
--tw-skew-x: initial;
|
|
1238
|
-
--tw-skew-y: initial;
|
|
1239
1211
|
--tw-space-y-reverse: 0;
|
|
1240
1212
|
--tw-space-x-reverse: 0;
|
|
1241
1213
|
--tw-divide-x-reverse: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstra",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Modern Documentation Framework for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"next",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"./styles.css": "./dist/styles.css"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "npm run
|
|
35
|
+
"build": "npm run build:ts && npm run build:css",
|
|
36
36
|
"build:ts": "tsup",
|
|
37
37
|
"build:css": "npx @tailwindcss/cli -i ./src/styles/input.css -o ./dist/styles.css",
|
|
38
38
|
"prettier": "prettier --write src"
|