doccupine 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +245 -35
- package/dist/templates/accordion.mdx.d.ts +1 -0
- package/dist/templates/accordion.mdx.js +41 -0
- package/dist/templates/callouts.mdx.d.ts +1 -0
- package/dist/templates/callouts.mdx.js +57 -0
- package/dist/templates/cards.mdx.d.ts +1 -0
- package/dist/templates/cards.mdx.js +25 -0
- package/dist/templates/code.js +11 -1
- package/dist/templates/code.mdx.d.ts +1 -0
- package/dist/templates/code.mdx.js +46 -0
- package/dist/templates/commands.mdx.d.ts +1 -1
- package/dist/templates/commands.mdx.js +4 -4
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +19 -218
- package/dist/templates/components/DocsSideBar.d.ts +1 -0
- package/dist/templates/components/DocsSideBar.js +120 -0
- package/dist/templates/components/MDXComponents.d.ts +1 -0
- package/dist/templates/components/MDXComponents.js +124 -0
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +28 -30
- package/dist/templates/components/layout/Accordion.d.ts +1 -0
- package/dist/templates/components/layout/Accordion.js +87 -0
- package/dist/templates/components/layout/Callout.d.ts +1 -0
- package/dist/templates/components/layout/Callout.js +114 -0
- package/dist/templates/components/layout/Card.d.ts +1 -0
- package/dist/templates/components/layout/Card.js +41 -0
- package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -0
- package/dist/templates/components/layout/CherryThemeProvider.js +51 -0
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +11 -2
- package/dist/templates/components/layout/Columns.d.ts +1 -0
- package/dist/templates/components/layout/Columns.js +25 -0
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +51 -4
- package/dist/templates/components/layout/Field.d.ts +1 -0
- package/dist/templates/components/layout/Field.js +61 -0
- package/dist/templates/components/layout/GlobalStyles.d.ts +1 -0
- package/dist/templates/components/layout/GlobalStyles.js +93 -0
- package/dist/templates/components/layout/Icon.d.ts +1 -1
- package/dist/templates/components/layout/Icon.js +9 -1
- package/dist/templates/components/layout/Pictograms.d.ts +1 -1
- package/dist/templates/components/layout/Pictograms.js +0 -2
- package/dist/templates/components/layout/RenderMarkdown.d.ts +1 -0
- package/dist/templates/components/layout/RenderMarkdown.js +61 -0
- package/dist/templates/components/layout/Tabs.d.ts +1 -0
- package/dist/templates/components/layout/Tabs.js +129 -0
- package/dist/templates/components/layout/ThemeToggle.d.ts +1 -1
- package/dist/templates/components/layout/ThemeToggle.js +33 -24
- package/dist/templates/components/layout/Update.d.ts +1 -0
- package/dist/templates/components/layout/Update.js +70 -0
- package/dist/templates/fields.mdx.d.ts +1 -0
- package/dist/templates/fields.mdx.js +42 -0
- package/dist/templates/icons.mdx.d.ts +1 -0
- package/dist/templates/icons.mdx.js +44 -0
- package/dist/templates/image-embeds.mdx.d.ts +1 -0
- package/dist/templates/image-embeds.mdx.js +103 -0
- package/dist/templates/layout.js +5 -2
- package/dist/templates/list-table.mdx.d.ts +1 -0
- package/dist/templates/list-table.mdx.js +85 -0
- package/dist/templates/mdx/accordion.mdx.d.ts +1 -0
- package/dist/templates/mdx/accordion.mdx.js +51 -0
- package/dist/templates/mdx/callouts.mdx.d.ts +1 -0
- package/dist/templates/mdx/callouts.mdx.js +67 -0
- package/dist/templates/mdx/cards.mdx.d.ts +1 -0
- package/dist/templates/mdx/cards.mdx.js +41 -0
- package/dist/templates/mdx/code.mdx.d.ts +1 -0
- package/dist/templates/mdx/code.mdx.js +46 -0
- package/dist/templates/mdx/commands.mdx.d.ts +1 -0
- package/dist/templates/mdx/commands.mdx.js +48 -0
- package/dist/templates/mdx/config.mdx.d.ts +1 -0
- package/dist/templates/mdx/config.mdx.js +51 -0
- package/dist/templates/mdx/fields.mdx.d.ts +1 -0
- package/dist/templates/mdx/fields.mdx.js +42 -0
- package/dist/templates/mdx/icons.mdx.d.ts +1 -0
- package/dist/templates/mdx/icons.mdx.js +44 -0
- package/dist/templates/mdx/image-embeds.mdx.d.ts +1 -0
- package/dist/templates/mdx/image-embeds.mdx.js +103 -0
- package/dist/templates/mdx/index.mdx.d.ts +1 -0
- package/dist/templates/mdx/index.mdx.js +44 -0
- package/dist/templates/mdx/list-table.mdx.d.ts +1 -0
- package/dist/templates/mdx/list-table.mdx.js +85 -0
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -0
- package/dist/templates/mdx/navigation.mdx.js +96 -0
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -0
- package/dist/templates/mdx/tabs.mdx.js +69 -0
- package/dist/templates/mdx/text.mdx.d.ts +1 -0
- package/dist/templates/mdx/text.mdx.js +142 -0
- package/dist/templates/mdx/update.mdx.d.ts +1 -0
- package/dist/templates/mdx/update.mdx.js +57 -0
- package/dist/templates/package.js +5 -4
- package/dist/templates/tabs.mdx.d.ts +1 -0
- package/dist/templates/tabs.mdx.js +59 -0
- package/dist/templates/text.mdx.d.ts +1 -0
- package/dist/templates/text.mdx.js +142 -0
- package/dist/templates/theme.d.ts +1 -1
- package/dist/templates/theme.js +1 -1
- package/dist/templates/update.mdx.d.ts +1 -0
- package/dist/templates/update.mdx.js +58 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -16,18 +16,42 @@ import { themeTemplate } from "./templates/theme.js";
|
|
|
16
16
|
import { iconTemplate } from "./templates/components/layout/Icon.js";
|
|
17
17
|
import { pictogramsTemplate } from "./templates/components/layout/Pictograms.js";
|
|
18
18
|
import { typographyTemplate } from "./templates/components/layout/Typography.js";
|
|
19
|
+
import { updateTemplate } from "./templates/components/layout/Update.js";
|
|
19
20
|
import { headerTemplate } from "./templates/components/layout/Header.js";
|
|
20
21
|
import { footerTemplate } from "./templates/components/layout/Footer.js";
|
|
22
|
+
import { globalStylesTemplate } from "./templates/components/layout/GlobalStyles.js";
|
|
21
23
|
import { themeToggleTemplate } from "./templates/components/layout/ThemeToggle.js";
|
|
22
24
|
import { sharedStyledTemplate } from "./templates/components/layout/SharedStyles.js";
|
|
25
|
+
import { accordionTemplate } from "./templates/components/layout/Accordion.js";
|
|
26
|
+
import { calloutTemplate } from "./templates/components/layout/Callout.js";
|
|
23
27
|
import { codeTemplate } from "./templates/components/layout/Code.js";
|
|
28
|
+
import { columnsTemplate } from "./templates/components/layout/Columns.js";
|
|
29
|
+
import { cardTemplate } from "./templates/components/layout/Card.js";
|
|
30
|
+
import { fieldTemplate } from "./templates/components/layout/Field.js";
|
|
31
|
+
import { cherryThemeProviderTemplate } from "./templates/components/layout/CherryThemeProvider.js";
|
|
32
|
+
import { tabsTemplate } from "./templates/components/layout/Tabs.js";
|
|
24
33
|
import { docsComponentsTemplate } from "./templates/components/layout/DocsComponents.js";
|
|
25
34
|
import { clickOutsideTemplate } from "./templates/components/ClickOutside.js";
|
|
26
35
|
import { docsTemplate } from "./templates/components/Docs.js";
|
|
36
|
+
import { docsSideBarTemplate } from "./templates/components/DocsSideBar.js";
|
|
37
|
+
import { mdxComponentsTemplate } from "./templates/components/MDXComponents.js";
|
|
27
38
|
import { orderNavItemsTemplate } from "./templates/utils/orderNavItems.js";
|
|
28
39
|
import { sideBarTemplate } from "./templates/components/SideBar.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
40
|
+
import { accordionMdxTemplate } from "./templates/mdx/accordion.mdx.js";
|
|
41
|
+
import { calloutsMdxTemplate } from "./templates/mdx/callouts.mdx.js";
|
|
42
|
+
import { cardsMdxTemplate } from "./templates/mdx/cards.mdx.js";
|
|
43
|
+
import { codeMdxTemplate } from "./templates/mdx/code.mdx.js";
|
|
44
|
+
import { commandsMdxTemplate } from "./templates/mdx/commands.mdx.js";
|
|
45
|
+
import { configMdxTemplate } from "./templates/mdx/config.mdx.js";
|
|
46
|
+
import { fieldsMdxTemplate } from "./templates/mdx/fields.mdx.js";
|
|
47
|
+
import { iconsMdxTemplate } from "./templates/mdx/icons.mdx.js";
|
|
48
|
+
import { imageEmbedsMdxTemplate } from "./templates/mdx/image-embeds.mdx.js";
|
|
49
|
+
import { indexMdxTemplate } from "./templates/mdx/index.mdx.js";
|
|
50
|
+
import { listTableMdxTemplate } from "./templates/mdx/list-table.mdx.js";
|
|
51
|
+
import { navigationMdxTemplate } from "./templates/mdx/navigation.mdx.js";
|
|
52
|
+
import { tabsMdxTemplate } from "./templates/mdx/tabs.mdx.js";
|
|
53
|
+
import { textMdxTemplate } from "./templates/mdx/text.mdx.js";
|
|
54
|
+
import { updateMdxTemplate } from "./templates/mdx/update.mdx.js";
|
|
31
55
|
class ConfigManager {
|
|
32
56
|
configPath;
|
|
33
57
|
constructor(configPath = "doccupine.json") {
|
|
@@ -98,10 +122,14 @@ class ConfigManager {
|
|
|
98
122
|
class MDXToNextJSGenerator {
|
|
99
123
|
watchDir;
|
|
100
124
|
outputDir;
|
|
125
|
+
rootDir;
|
|
101
126
|
watcher = null;
|
|
127
|
+
configWatcher = null;
|
|
128
|
+
configFiles = ["theme.json", "navigation.json", "config.json"];
|
|
102
129
|
constructor(watchDir, outputDir) {
|
|
103
130
|
this.watchDir = path.resolve(watchDir);
|
|
104
131
|
this.outputDir = path.resolve(outputDir);
|
|
132
|
+
this.rootDir = process.cwd();
|
|
105
133
|
}
|
|
106
134
|
async init() {
|
|
107
135
|
console.log(chalk.blue("🚀 Initializing MDX to Next.js generator..."));
|
|
@@ -109,14 +137,62 @@ class MDXToNextJSGenerator {
|
|
|
109
137
|
await fs.ensureDir(this.outputDir);
|
|
110
138
|
await this.createNextJSStructure();
|
|
111
139
|
await this.createStartingDocs();
|
|
140
|
+
await this.copyCustomConfigFiles();
|
|
112
141
|
await this.processAllMDXFiles();
|
|
113
142
|
console.log(chalk.green("✅ Initial setup complete!"));
|
|
114
143
|
console.log(chalk.cyan("💡 To start the Next.js dev server:"));
|
|
115
144
|
console.log(chalk.white(` cd ${path.relative(process.cwd(), this.outputDir)}`));
|
|
116
145
|
console.log(chalk.white(" npm install && npm run dev"));
|
|
117
146
|
}
|
|
147
|
+
async copyCustomConfigFiles() {
|
|
148
|
+
console.log(chalk.blue(`🔍 Checking for config files in: ${this.watchDir}`));
|
|
149
|
+
for (const configFile of this.configFiles) {
|
|
150
|
+
const sourcePath = path.join(this.rootDir, configFile);
|
|
151
|
+
const destPath = path.join(this.outputDir, configFile);
|
|
152
|
+
console.log(chalk.gray(` Checking ${configFile}...`));
|
|
153
|
+
if (await fs.pathExists(sourcePath)) {
|
|
154
|
+
await fs.copy(sourcePath, destPath);
|
|
155
|
+
console.log(chalk.green(` ✓ Copied ${configFile} to Next.js app`));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.log(chalk.gray(` ✗ ${configFile} not found, skipping`));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async handleConfigFileChange(filePath) {
|
|
163
|
+
const fileName = path.basename(filePath);
|
|
164
|
+
if (this.configFiles.includes(fileName)) {
|
|
165
|
+
const sourcePath = path.join(this.rootDir, fileName);
|
|
166
|
+
const destPath = path.join(this.outputDir, fileName);
|
|
167
|
+
try {
|
|
168
|
+
await fs.copy(sourcePath, destPath);
|
|
169
|
+
console.log(chalk.green(`📋 Updated ${fileName} in Next.js app`));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error(chalk.red(`❌ Error copying ${fileName}:`), error);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async handleConfigFileDelete(filePath) {
|
|
177
|
+
const fileName = path.basename(filePath);
|
|
178
|
+
if (this.configFiles.includes(fileName)) {
|
|
179
|
+
const destPath = path.join(this.outputDir, fileName);
|
|
180
|
+
try {
|
|
181
|
+
if (await fs.pathExists(destPath)) {
|
|
182
|
+
await fs.remove(destPath);
|
|
183
|
+
console.log(chalk.yellow(`🗑️ Removed ${fileName} from Next.js app`));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.error(chalk.red(`❌ Error removing ${fileName}:`), error);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
118
191
|
async createNextJSStructure() {
|
|
119
192
|
const structure = {
|
|
193
|
+
"theme.json": this.generateThemeConfig(),
|
|
194
|
+
"navigation.json": this.generateNavigationConfig(),
|
|
195
|
+
"config.json": this.generateConfig(),
|
|
120
196
|
".gitignore": this.generateGitIgnore(),
|
|
121
197
|
"package.json": this.generatePackageJson(),
|
|
122
198
|
"next.config.ts": this.generateNextConfig(),
|
|
@@ -127,14 +203,25 @@ class MDXToNextJSGenerator {
|
|
|
127
203
|
"components/layout/Icon.tsx": this.generateIcon(),
|
|
128
204
|
"components/layout/Pictograms.tsx": this.generatePictograms(),
|
|
129
205
|
"components/layout/Typography.ts": this.generateTypography(),
|
|
206
|
+
"components/layout/Update.tsx": this.generateUpdate(),
|
|
130
207
|
"components/layout/Header.tsx": this.generateHeader(),
|
|
131
208
|
"components/layout/Footer.tsx": this.generateFooter(),
|
|
209
|
+
"components/layout/GlobalStyles.ts": this.generateGlobalStyles(),
|
|
132
210
|
"components/layout/ThemeToggle.tsx": this.generateThemeToggle(),
|
|
133
211
|
"components/layout/SharedStyled.ts": this.generateSharedStyled(),
|
|
212
|
+
"components/layout/Accordion.tsx": this.generateAccordion(),
|
|
213
|
+
"components/layout/Callout.tsx": this.generateCallout(),
|
|
134
214
|
"components/layout/Code.tsx": this.generateCode(),
|
|
215
|
+
"components/layout/Columns.tsx": this.generateColumns(),
|
|
216
|
+
"components/layout/Card.tsx": this.generateCard(),
|
|
217
|
+
"components/layout/Field.tsx": this.generateField(),
|
|
218
|
+
"components/layout/CherryThemeProvider.tsx": this.generateCherryThemeProvider(),
|
|
219
|
+
"components/layout/Tabs.tsx": this.generateTabs(),
|
|
135
220
|
"components/layout/DocsComponents.tsx": this.generateDocsComponents(),
|
|
136
221
|
"components/ClickOutside.ts": this.generateClickOutside(),
|
|
137
222
|
"components/Docs.tsx": this.generateDocs(),
|
|
223
|
+
"components/DocsSideBar.tsx": this.generateDocsSideBar(),
|
|
224
|
+
"components/MDXComponents.tsx": this.generateMDXComponents(),
|
|
138
225
|
"components/SideBar.tsx": this.generateSideBar(),
|
|
139
226
|
"utils/orderNavItems.ts": this.generateOrderNavItems(),
|
|
140
227
|
};
|
|
@@ -146,8 +233,21 @@ class MDXToNextJSGenerator {
|
|
|
146
233
|
}
|
|
147
234
|
async createStartingDocs() {
|
|
148
235
|
const structure = {
|
|
149
|
-
"
|
|
236
|
+
"accordion.mdx": this.generateAccordionMdx(),
|
|
237
|
+
"callouts.mdx": this.generateCalloutsMdx(),
|
|
238
|
+
"cards.mdx": this.generateCardsMdx(),
|
|
239
|
+
"code.mdx": this.generateCodeMdx(),
|
|
150
240
|
"commands.mdx": this.generateCommandsMdx(),
|
|
241
|
+
"config.mdx": this.generateConfigMdx(),
|
|
242
|
+
"fields.mdx": this.generateFieldsMdx(),
|
|
243
|
+
"icons.mdx": this.generateIconsMdx(),
|
|
244
|
+
"image-embeds.mdx": this.generateImageEmbedsMdx(),
|
|
245
|
+
"index.mdx": this.generateIndexMdx(),
|
|
246
|
+
"list-table.mdx": this.generateListTableMdx(),
|
|
247
|
+
"navigation.mdx": this.generateNavigationMdx(),
|
|
248
|
+
"tabs.mdx": this.generateTabsMdx(),
|
|
249
|
+
"text.mdx": this.generateTextMdx(),
|
|
250
|
+
"update.mdx": this.generateUpdateMdx(),
|
|
151
251
|
};
|
|
152
252
|
const indexMdxExists = await fs.pathExists(path.join(this.watchDir, "index.mdx"));
|
|
153
253
|
if (!indexMdxExists) {
|
|
@@ -165,6 +265,10 @@ class MDXToNextJSGenerator {
|
|
|
165
265
|
ignoreInitial: true,
|
|
166
266
|
ignored: (filePath, stats) => {
|
|
167
267
|
const isFile = stats?.isFile() ?? path.extname(filePath) !== "";
|
|
268
|
+
const fileName = path.basename(filePath);
|
|
269
|
+
if (this.configFiles.includes(fileName)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
168
272
|
if (isFile && !filePath.endsWith(".mdx")) {
|
|
169
273
|
return true;
|
|
170
274
|
}
|
|
@@ -190,6 +294,27 @@ class MDXToNextJSGenerator {
|
|
|
190
294
|
.on("error", (error) => {
|
|
191
295
|
console.error(chalk.red("❌ Watcher error:"), error);
|
|
192
296
|
});
|
|
297
|
+
const configPaths = this.configFiles.map((f) => path.join(this.rootDir, f));
|
|
298
|
+
this.configWatcher = chokidar.watch(configPaths, {
|
|
299
|
+
persistent: true,
|
|
300
|
+
ignoreInitial: true,
|
|
301
|
+
});
|
|
302
|
+
this.configWatcher
|
|
303
|
+
.on("add", (filePath) => {
|
|
304
|
+
console.log(chalk.cyan(`📝 Config file added: ${path.basename(filePath)}`));
|
|
305
|
+
this.handleConfigFileChange(filePath);
|
|
306
|
+
})
|
|
307
|
+
.on("change", (filePath) => {
|
|
308
|
+
console.log(chalk.cyan(`📝 Config file changed: ${path.basename(filePath)}`));
|
|
309
|
+
this.handleConfigFileChange(filePath);
|
|
310
|
+
})
|
|
311
|
+
.on("unlink", (filePath) => {
|
|
312
|
+
console.log(chalk.red(`🗑️ Config file deleted: ${path.basename(filePath)}`));
|
|
313
|
+
this.handleConfigFileDelete(filePath);
|
|
314
|
+
})
|
|
315
|
+
.on("error", (error) => {
|
|
316
|
+
console.error(chalk.red("❌ Config watcher error:"), error);
|
|
317
|
+
});
|
|
193
318
|
}
|
|
194
319
|
async handleFileChange(action, filePath) {
|
|
195
320
|
console.log(chalk.cyan(`📝 File ${action}: ${filePath}`));
|
|
@@ -294,25 +419,25 @@ class MDXToNextJSGenerator {
|
|
|
294
419
|
}
|
|
295
420
|
const pageContent = `import { Metadata } from "next";
|
|
296
421
|
import { Docs } from "@/components/Docs";
|
|
422
|
+
import config from "@/config.json";
|
|
297
423
|
|
|
298
424
|
const content = \`${mdxFile.content.replace(/`/g, "\\`")}\`;
|
|
299
425
|
|
|
300
426
|
export const metadata: Metadata = {
|
|
301
|
-
title:
|
|
302
|
-
description:
|
|
303
|
-
icons:
|
|
427
|
+
title: \`${mdxFile.frontmatter.title || "Generated with Doccupine"} \${config.name ? "- " + config.name : "- Doccupine"}\`,
|
|
428
|
+
description: \`${mdxFile.frontmatter.description ? mdxFile.frontmatter.description : '${config.description ? config.description : "Generated with Doccupine"}'}\`,
|
|
429
|
+
icons: \`${mdxFile.frontmatter.icon ? mdxFile.frontmatter.icon : "\${config.icon || 'https://doccupine.com/favicon.ico'}"}\`,
|
|
304
430
|
openGraph: {
|
|
305
|
-
title:
|
|
306
|
-
description:
|
|
307
|
-
images:
|
|
308
|
-
}
|
|
431
|
+
title: \`${mdxFile.frontmatter.title || "Generated with Doccupine"} \${config.name ? "- " + config.name : "- Doccupine"}\`,
|
|
432
|
+
description: \`${mdxFile.frontmatter.description ? mdxFile.frontmatter.description : '${config.description ? config.description : "Generated with Doccupine"}'}\`,
|
|
433
|
+
images: \`${mdxFile.frontmatter.image ? mdxFile.frontmatter.image : "\${config.preview || 'https://doccupine.com/preview.png'}"}\`,
|
|
434
|
+
},
|
|
309
435
|
};
|
|
310
436
|
|
|
311
437
|
export default function Page() {
|
|
312
|
-
return
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}`;
|
|
438
|
+
return <Docs content={content} />;
|
|
439
|
+
}
|
|
440
|
+
`;
|
|
316
441
|
const pagePath = path.join(this.outputDir, "app", mdxFile.slug, "page.tsx");
|
|
317
442
|
await fs.ensureDir(path.dirname(pagePath));
|
|
318
443
|
await fs.writeFile(pagePath, pageContent, "utf8");
|
|
@@ -340,38 +465,47 @@ export default function Page() {
|
|
|
340
465
|
}
|
|
341
466
|
const indexContent = `import { Metadata } from "next";
|
|
342
467
|
import { Docs } from "@/components/Docs";
|
|
468
|
+
import config from "@/config.json";
|
|
343
469
|
|
|
344
470
|
${indexMDX ? `const indexContent = \`${indexMDX.content.replace(/`/g, "\\`")}\`;` : `const indexContent = null;`}
|
|
345
471
|
|
|
346
472
|
${indexMDX
|
|
347
473
|
? `export const metadata: Metadata = {
|
|
348
|
-
title: "${indexMDX.title}
|
|
349
|
-
description:
|
|
350
|
-
icons:
|
|
474
|
+
title: \`\${config.name ? config.name + " -" : "Doccupine -"} ${indexMDX.title}\`,
|
|
475
|
+
description: \`${indexMDX.description ? indexMDX.description : '${config.description ? config.description : "Generated with Doccupine"}'}\`,
|
|
476
|
+
icons: \`${indexMDX.icon ? indexMDX.icon : "\${config.icon || 'https://doccupine.com/favicon.ico'}"}\`,
|
|
351
477
|
openGraph: {
|
|
352
|
-
title: "${indexMDX.title}
|
|
353
|
-
description:
|
|
354
|
-
images:
|
|
355
|
-
}
|
|
478
|
+
title: \`\${config.name ? config.name + " -" : "Doccupine -"} ${indexMDX.title}\`,
|
|
479
|
+
description: \`${indexMDX.description ? indexMDX.description : '${config.description ? config.description : "Generated with Doccupine"}'}\`,
|
|
480
|
+
images: \`${indexMDX.image ? indexMDX.image : "\${config.preview || 'https://doccupine.com/preview.png'}"}\`,
|
|
481
|
+
},
|
|
356
482
|
};`
|
|
357
483
|
: `export const metadata: Metadata = {
|
|
358
|
-
title: "
|
|
359
|
-
description: "
|
|
484
|
+
title: "Doccupine",
|
|
485
|
+
description: "Generated with Doccupine",
|
|
360
486
|
icons: "https://doccupine.com/favicon.ico",
|
|
361
487
|
openGraph: {
|
|
362
|
-
title: "
|
|
363
|
-
description: "
|
|
488
|
+
title: "Doccupine",
|
|
489
|
+
description: "Generated with Doccupine",
|
|
364
490
|
images: "https://doccupine.com/preview.png",
|
|
365
|
-
}
|
|
366
|
-
};`}
|
|
491
|
+
},
|
|
492
|
+
};`}
|
|
367
493
|
|
|
368
494
|
export default function Home() {
|
|
369
|
-
return
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}`;
|
|
495
|
+
return <Docs content={indexContent} />;
|
|
496
|
+
}
|
|
497
|
+
`;
|
|
373
498
|
await fs.writeFile(path.join(this.outputDir, "app", "page.tsx"), indexContent, "utf8");
|
|
374
499
|
}
|
|
500
|
+
generateThemeConfig() {
|
|
501
|
+
return `{}`;
|
|
502
|
+
}
|
|
503
|
+
generateNavigationConfig() {
|
|
504
|
+
return `[]`;
|
|
505
|
+
}
|
|
506
|
+
generateConfig() {
|
|
507
|
+
return `{}`;
|
|
508
|
+
}
|
|
375
509
|
generateGitIgnore() {
|
|
376
510
|
return gitignoreTemplate;
|
|
377
511
|
}
|
|
@@ -408,12 +542,51 @@ export default function Home() {
|
|
|
408
542
|
const layoutContent = await this.generateRootLayout();
|
|
409
543
|
await fs.writeFile(path.join(this.outputDir, "app", "layout.tsx"), layoutContent, "utf8");
|
|
410
544
|
}
|
|
411
|
-
|
|
412
|
-
return
|
|
545
|
+
generateAccordionMdx() {
|
|
546
|
+
return accordionMdxTemplate;
|
|
547
|
+
}
|
|
548
|
+
generateCalloutsMdx() {
|
|
549
|
+
return calloutsMdxTemplate;
|
|
550
|
+
}
|
|
551
|
+
generateCardsMdx() {
|
|
552
|
+
return cardsMdxTemplate;
|
|
553
|
+
}
|
|
554
|
+
generateCodeMdx() {
|
|
555
|
+
return codeMdxTemplate;
|
|
413
556
|
}
|
|
414
557
|
generateCommandsMdx() {
|
|
415
558
|
return commandsMdxTemplate;
|
|
416
559
|
}
|
|
560
|
+
generateConfigMdx() {
|
|
561
|
+
return configMdxTemplate;
|
|
562
|
+
}
|
|
563
|
+
generateFieldsMdx() {
|
|
564
|
+
return fieldsMdxTemplate;
|
|
565
|
+
}
|
|
566
|
+
generateIconsMdx() {
|
|
567
|
+
return iconsMdxTemplate;
|
|
568
|
+
}
|
|
569
|
+
generateImageEmbedsMdx() {
|
|
570
|
+
return imageEmbedsMdxTemplate;
|
|
571
|
+
}
|
|
572
|
+
generateIndexMdx() {
|
|
573
|
+
return indexMdxTemplate;
|
|
574
|
+
}
|
|
575
|
+
generateListTableMdx() {
|
|
576
|
+
return listTableMdxTemplate;
|
|
577
|
+
}
|
|
578
|
+
generateNavigationMdx() {
|
|
579
|
+
return navigationMdxTemplate;
|
|
580
|
+
}
|
|
581
|
+
generateTabsMdx() {
|
|
582
|
+
return tabsMdxTemplate;
|
|
583
|
+
}
|
|
584
|
+
generateTextMdx() {
|
|
585
|
+
return textMdxTemplate;
|
|
586
|
+
}
|
|
587
|
+
generateUpdateMdx() {
|
|
588
|
+
return updateMdxTemplate;
|
|
589
|
+
}
|
|
417
590
|
generateNotFoundPage() {
|
|
418
591
|
return notFoundTemplate;
|
|
419
592
|
}
|
|
@@ -432,27 +605,60 @@ export default function Home() {
|
|
|
432
605
|
generateTypography() {
|
|
433
606
|
return typographyTemplate;
|
|
434
607
|
}
|
|
608
|
+
generateUpdate() {
|
|
609
|
+
return updateTemplate;
|
|
610
|
+
}
|
|
435
611
|
generateHeader() {
|
|
436
612
|
return headerTemplate;
|
|
437
613
|
}
|
|
438
614
|
generateFooter() {
|
|
439
615
|
return footerTemplate;
|
|
440
616
|
}
|
|
617
|
+
generateGlobalStyles() {
|
|
618
|
+
return globalStylesTemplate;
|
|
619
|
+
}
|
|
441
620
|
generateThemeToggle() {
|
|
442
621
|
return themeToggleTemplate;
|
|
443
622
|
}
|
|
444
623
|
generateSharedStyled() {
|
|
445
624
|
return sharedStyledTemplate;
|
|
446
625
|
}
|
|
626
|
+
generateAccordion() {
|
|
627
|
+
return accordionTemplate;
|
|
628
|
+
}
|
|
629
|
+
generateCallout() {
|
|
630
|
+
return calloutTemplate;
|
|
631
|
+
}
|
|
447
632
|
generateCode() {
|
|
448
633
|
return codeTemplate;
|
|
449
634
|
}
|
|
635
|
+
generateColumns() {
|
|
636
|
+
return columnsTemplate;
|
|
637
|
+
}
|
|
638
|
+
generateCard() {
|
|
639
|
+
return cardTemplate;
|
|
640
|
+
}
|
|
641
|
+
generateField() {
|
|
642
|
+
return fieldTemplate;
|
|
643
|
+
}
|
|
644
|
+
generateCherryThemeProvider() {
|
|
645
|
+
return cherryThemeProviderTemplate;
|
|
646
|
+
}
|
|
647
|
+
generateTabs() {
|
|
648
|
+
return tabsTemplate;
|
|
649
|
+
}
|
|
450
650
|
generateDocsComponents() {
|
|
451
651
|
return docsComponentsTemplate;
|
|
452
652
|
}
|
|
453
653
|
generateDocs() {
|
|
454
654
|
return docsTemplate;
|
|
455
655
|
}
|
|
656
|
+
generateDocsSideBar() {
|
|
657
|
+
return docsSideBarTemplate;
|
|
658
|
+
}
|
|
659
|
+
generateMDXComponents() {
|
|
660
|
+
return mdxComponentsTemplate;
|
|
661
|
+
}
|
|
456
662
|
generateSideBar() {
|
|
457
663
|
return sideBarTemplate;
|
|
458
664
|
}
|
|
@@ -462,14 +668,18 @@ export default function Home() {
|
|
|
462
668
|
async stop() {
|
|
463
669
|
if (this.watcher) {
|
|
464
670
|
await this.watcher.close();
|
|
465
|
-
console.log(chalk.yellow("👋 Stopped watching for changes"));
|
|
671
|
+
console.log(chalk.yellow("👋 Stopped watching for MDX changes"));
|
|
672
|
+
}
|
|
673
|
+
if (this.configWatcher) {
|
|
674
|
+
await this.configWatcher.close();
|
|
675
|
+
console.log(chalk.yellow("👋 Stopped watching for config changes"));
|
|
466
676
|
}
|
|
467
677
|
}
|
|
468
678
|
}
|
|
469
679
|
program
|
|
470
680
|
.name("doccupine")
|
|
471
681
|
.description("Watch MDX files and generate Next.js documentation pages automatically")
|
|
472
|
-
.version("0.0.
|
|
682
|
+
.version("0.0.11");
|
|
473
683
|
program
|
|
474
684
|
.command("watch", { isDefault: true })
|
|
475
685
|
.description("Watch a directory for MDX changes and generate Next.js app")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const accordionMdxTemplate = "---\ntitle: \"Accordion\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 4\n---\n# Accordion\nInteractive panels for toggling visibility of content.\n\nAccordion elements help organize information by letting users show or hide sections as needed. They\u2019re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.\n\n## Accordion Usage\nYou can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java HelloWorld.java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n~~~\n\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java HelloWorld.java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const accordionMdxTemplate = `---
|
|
2
|
+
title: "Accordion"
|
|
3
|
+
description: "Doccupine CLI commands"
|
|
4
|
+
date: "2025-01-15"
|
|
5
|
+
category: "Components"
|
|
6
|
+
categoryOrder: 1
|
|
7
|
+
order: 4
|
|
8
|
+
---
|
|
9
|
+
# Accordion
|
|
10
|
+
Interactive panels for toggling visibility of content.
|
|
11
|
+
|
|
12
|
+
Accordion elements help organize information by letting users show or hide sections as needed. They’re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.
|
|
13
|
+
|
|
14
|
+
## Accordion Usage
|
|
15
|
+
You can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
+
|
|
17
|
+
~~~mdx
|
|
18
|
+
<Accordion title="What is MDX?">
|
|
19
|
+
You can put any content in here, including other components, like code:
|
|
20
|
+
|
|
21
|
+
\`\`\`java HelloWorld.java
|
|
22
|
+
class HelloWorld {
|
|
23
|
+
public static void main(String[] args) {
|
|
24
|
+
System.out.println("Hello, World!");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
\`\`\`
|
|
28
|
+
</Accordion>
|
|
29
|
+
~~~
|
|
30
|
+
|
|
31
|
+
<Accordion title="What is MDX?">
|
|
32
|
+
You can put any content in here, including other components, like code:
|
|
33
|
+
|
|
34
|
+
\`\`\`java HelloWorld.java
|
|
35
|
+
class HelloWorld {
|
|
36
|
+
public static void main(String[] args) {
|
|
37
|
+
System.out.println("Hello, World!");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
\`\`\`
|
|
41
|
+
</Accordion>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calloutsMdxTemplate = "---\ntitle: \"Callouts\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 7\n---\n# Callouts\nMake your content stand out by using callouts for extra emphasis.\n\nYou can format them as Note, Warning, Info, Danger and Success.\n\n## Callouts Usage\nYou can use the Callouts component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Callout type=\"note\">\n This is a note callout\n</Callout>\n\n<Callout type=\"warning\">\n This is a warning callout\n</Callout>\n\n<Callout type=\"info\">\n This is an info callout\n</Callout>\n\n<Callout type=\"danger\">\n This is a danger callout\n</Callout>\n\n<Callout type=\"success\">\n This is a success callout\n</Callout>\n~~~\n\n<Callout type=\"note\">\n This is a note callout\n</Callout>\n\n<Callout type=\"warning\">\n This is a warning callout\n</Callout>\n\n<Callout type=\"info\">\n This is an info callout\n</Callout>\n\n<Callout type=\"danger\">\n This is a danger callout\n</Callout>\n\n<Callout type=\"success\">\n This is a success callout\n</Callout>";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const calloutsMdxTemplate = `---
|
|
2
|
+
title: "Callouts"
|
|
3
|
+
description: "Doccupine CLI commands"
|
|
4
|
+
date: "2025-01-15"
|
|
5
|
+
category: "Components"
|
|
6
|
+
categoryOrder: 1
|
|
7
|
+
order: 7
|
|
8
|
+
---
|
|
9
|
+
# Callouts
|
|
10
|
+
Make your content stand out by using callouts for extra emphasis.
|
|
11
|
+
|
|
12
|
+
You can format them as Note, Warning, Info, Danger and Success.
|
|
13
|
+
|
|
14
|
+
## Callouts Usage
|
|
15
|
+
You can use the Callouts component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
+
|
|
17
|
+
~~~mdx
|
|
18
|
+
<Callout type="note">
|
|
19
|
+
This is a note callout
|
|
20
|
+
</Callout>
|
|
21
|
+
|
|
22
|
+
<Callout type="warning">
|
|
23
|
+
This is a warning callout
|
|
24
|
+
</Callout>
|
|
25
|
+
|
|
26
|
+
<Callout type="info">
|
|
27
|
+
This is an info callout
|
|
28
|
+
</Callout>
|
|
29
|
+
|
|
30
|
+
<Callout type="danger">
|
|
31
|
+
This is a danger callout
|
|
32
|
+
</Callout>
|
|
33
|
+
|
|
34
|
+
<Callout type="success">
|
|
35
|
+
This is a success callout
|
|
36
|
+
</Callout>
|
|
37
|
+
~~~
|
|
38
|
+
|
|
39
|
+
<Callout type="note">
|
|
40
|
+
This is a note callout
|
|
41
|
+
</Callout>
|
|
42
|
+
|
|
43
|
+
<Callout type="warning">
|
|
44
|
+
This is a warning callout
|
|
45
|
+
</Callout>
|
|
46
|
+
|
|
47
|
+
<Callout type="info">
|
|
48
|
+
This is an info callout
|
|
49
|
+
</Callout>
|
|
50
|
+
|
|
51
|
+
<Callout type="danger">
|
|
52
|
+
This is a danger callout
|
|
53
|
+
</Callout>
|
|
54
|
+
|
|
55
|
+
<Callout type="success">
|
|
56
|
+
This is a success callout
|
|
57
|
+
</Callout>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cardsMdxTemplate = "---\ntitle: \"Cards\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 6\n---\n# Cards\nDuplicate a page or section with ease, then emphasize important information or links using customizable layouts and icons.\n\nCards act as visual containers for your content, giving you flexibility to combine text, icons, images, and links in a clean and organized way.\n\n## Cards Usage\nYou can use the Cards component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Card title=\"Note\" icon=\"BadgeInfo\">\n Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.\n</Card>\n~~~\n\n<Card title=\"Note\" icon=\"BadgeInfo\">\n Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.\n</Card>";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const cardsMdxTemplate = `---
|
|
2
|
+
title: "Cards"
|
|
3
|
+
description: "Doccupine CLI commands"
|
|
4
|
+
date: "2025-01-15"
|
|
5
|
+
category: "Components"
|
|
6
|
+
categoryOrder: 1
|
|
7
|
+
order: 6
|
|
8
|
+
---
|
|
9
|
+
# Cards
|
|
10
|
+
Duplicate a page or section with ease, then emphasize important information or links using customizable layouts and icons.
|
|
11
|
+
|
|
12
|
+
Cards act as visual containers for your content, giving you flexibility to combine text, icons, images, and links in a clean and organized way.
|
|
13
|
+
|
|
14
|
+
## Cards Usage
|
|
15
|
+
You can use the Cards component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
+
|
|
17
|
+
~~~mdx
|
|
18
|
+
<Card title="Note" icon="BadgeInfo">
|
|
19
|
+
Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.
|
|
20
|
+
</Card>
|
|
21
|
+
~~~
|
|
22
|
+
|
|
23
|
+
<Card title="Note" icon="BadgeInfo">
|
|
24
|
+
Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.
|
|
25
|
+
</Card>`;
|
package/dist/templates/code.js
CHANGED
|
@@ -159,7 +159,17 @@ const Body = styled.div<{ theme: Theme }>\`
|
|
|
159
159
|
}
|
|
160
160
|
\`;
|
|
161
161
|
|
|
162
|
+
const escapeHtml = (unsafe: string): string => {
|
|
163
|
+
return unsafe
|
|
164
|
+
.replace(/&/g, "&")
|
|
165
|
+
.replace(/</g, "<")
|
|
166
|
+
.replace(/>/g, ">")
|
|
167
|
+
.replace(/"/g, """)
|
|
168
|
+
.replace(/'/g, "'");
|
|
169
|
+
};
|
|
170
|
+
|
|
162
171
|
const highlightCode = (code: string, language: string): string => {
|
|
172
|
+
const escapedCode = escapeHtml(code);
|
|
163
173
|
const result = unified()
|
|
164
174
|
.use(rehypeParse, { fragment: true })
|
|
165
175
|
.use(rehypeHighlight, {
|
|
@@ -168,7 +178,7 @@ const highlightCode = (code: string, language: string): string => {
|
|
|
168
178
|
})
|
|
169
179
|
.use(rehypeStringify)
|
|
170
180
|
.processSync(
|
|
171
|
-
\`<pre><code class="language-\${language}">\${
|
|
181
|
+
\`<pre><code class="language-\${language}">\${escapedCode}</code></pre>\`,
|
|
172
182
|
);
|
|
173
183
|
|
|
174
184
|
return String(result);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const codeMdxTemplate = "---\ntitle: \"Code\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 3\n---\n# Code\nLearn how to display inline code and code blocks in documentation.\n\n## Adding Code Samples\nBoth inline code snippets and full code blocks are supported. Code blocks offer customization for syntax highlighting and more to improve readability and user experience.\n\n### Inline Code\nHighlight code within text by wrapping it with backticks:\n\n```text\nEnclose any `word` or `phrase` in backticks to format it as code.\n```\n\nEnclose any `word` or `phrase` in backticks to format it as code.\n\n## Code Blocks\nTo present larger code samples, use triple backticks for fenced code blocks. Each block can be copied, and\u2014if assistant features are enabled\u2014users can request explanations.\n\nYou may specify the language for highlighting:\n\n~~~text\n```java\nclass HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n}\n```\n~~~\n\n\n```java\nclass HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n}\n```";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const codeMdxTemplate = `---
|
|
2
|
+
title: "Code"
|
|
3
|
+
description: "Doccupine CLI commands"
|
|
4
|
+
date: "2025-01-15"
|
|
5
|
+
category: "Components"
|
|
6
|
+
categoryOrder: 1
|
|
7
|
+
order: 3
|
|
8
|
+
---
|
|
9
|
+
# Code
|
|
10
|
+
Learn how to display inline code and code blocks in documentation.
|
|
11
|
+
|
|
12
|
+
## Adding Code Samples
|
|
13
|
+
Both inline code snippets and full code blocks are supported. Code blocks offer customization for syntax highlighting and more to improve readability and user experience.
|
|
14
|
+
|
|
15
|
+
### Inline Code
|
|
16
|
+
Highlight code within text by wrapping it with backticks:
|
|
17
|
+
|
|
18
|
+
\`\`\`text
|
|
19
|
+
Enclose any \`word\` or \`phrase\` in backticks to format it as code.
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
Enclose any \`word\` or \`phrase\` in backticks to format it as code.
|
|
23
|
+
|
|
24
|
+
## Code Blocks
|
|
25
|
+
To present larger code samples, use triple backticks for fenced code blocks. Each block can be copied, and—if assistant features are enabled—users can request explanations.
|
|
26
|
+
|
|
27
|
+
You may specify the language for highlighting:
|
|
28
|
+
|
|
29
|
+
~~~text
|
|
30
|
+
\`\`\`java
|
|
31
|
+
class HelloWorld {
|
|
32
|
+
public static void main(String[] args) {
|
|
33
|
+
System.out.println("Hello, World!");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
\`\`\`
|
|
37
|
+
~~~
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
\`\`\`java
|
|
41
|
+
class HelloWorld {
|
|
42
|
+
public static void main(String[] args) {
|
|
43
|
+
System.out.println("Hello, World!");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
\`\`\``;
|