mintlify 1.0.2 → 1.0.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "mintlify",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=14.16"
package/src/index.ts CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  import { writeFileSync } from "fs";
4
4
  import inquirer from "inquirer";
5
- import { MintConfig } from "./templates.js";
5
+ import { MintConfig, Page } from "./templates.js";
6
+ import { toFilename } from "./util.js";
6
7
 
7
8
  const args = process.argv.slice(2);
8
9
 
@@ -13,7 +14,9 @@ if (args.length === 0) {
13
14
  process.exit(1); //an error occurred
14
15
  }
15
16
 
16
- if (args[0] === "init") {
17
+ const command = args[0];
18
+
19
+ if (command === "init") {
17
20
  inquirer
18
21
  .prompt([
19
22
  {
@@ -51,11 +54,41 @@ if (args[0] === "init") {
51
54
  writeFileSync(
52
55
  "mint.config.json",
53
56
  JSON.stringify(
54
- MintConfig(name, color, ctaName, ctaUrl, title),
57
+ MintConfig(name, color, ctaName, ctaUrl, toFilename(title)),
55
58
  null,
56
59
  "\t"
57
60
  )
58
61
  );
62
+ console.log("🌱 Created initial files for Mintlify docs");
63
+ process.exit(1);
64
+ })
65
+ .catch((error) => {
66
+ console.error(error);
67
+ process.exit(1);
68
+ });
69
+ }
70
+
71
+ if (command === "page") {
72
+ inquirer
73
+ .prompt([
74
+ {
75
+ type: "input",
76
+ name: "title",
77
+ message: "What is the title of the new page?",
78
+ },
79
+ {
80
+ type: "input",
81
+ name: "description",
82
+ message: "What is the description?",
83
+ default: "",
84
+ },
85
+ ])
86
+ .then((answers) => {
87
+ const { title, description } = answers;
88
+
89
+ writeFileSync(toFilename(title), Page(title, description));
90
+ console.log("🌱 Created initial files for Mintlify docs");
91
+ process.exit(1);
59
92
  })
60
93
  .catch((error) => {
61
94
  console.error(error);
package/src/templates.ts CHANGED
@@ -3,7 +3,7 @@ export const MintConfig = (
3
3
  color: string,
4
4
  ctaName: string,
5
5
  ctaUrl: string,
6
- title: string
6
+ filename: string
7
7
  ) => {
8
8
  return {
9
9
  name,
@@ -21,9 +21,14 @@ export const MintConfig = (
21
21
  navigation: [
22
22
  {
23
23
  group: "Home",
24
- pages: [title],
24
+ pages: [filename],
25
25
  },
26
26
  ],
27
27
  // footerSocials: {}, // support object type for footer tyoes
28
28
  };
29
29
  };
30
+
31
+ export const Page = (title: string, description?: string) => {
32
+ const optionalDescription = description ? `\n${description}` : "";
33
+ return `---\ntitle:${title}${optionalDescription}\n---`;
34
+ };
package/src/util.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const toFilename = (title: string) => {
2
+ return title.replace(/[^a-z0-9]/gi, "-").toLowerCase();
3
+ };