@sillsdev/docu-notion 0.14.0-alpha.13 → 0.14.0-alpha.14

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 CHANGED
@@ -90,7 +90,9 @@ One of the big attractions of Notion for large documentation projects is that yo
90
90
 
91
91
  ## Slugs
92
92
 
93
- By default, pages will be given a slug based on the Notion id. For a human-readable URL, add a notion property named `Slug` to your database pages and enter a value in there that will work well in a URL. That is, no spaces, ?, #, /, etc.
93
+ By default, pages will be given a slug based on the Notion ID. For a human-readable URL, add a notion property named `Slug` to your database pages and enter a value in there that will work well in a URL. That is, no spaces, ?, #, /, etc.
94
+
95
+ See `Options` to require slugs in Notion.
94
96
 
95
97
  ## Known Limitations
96
98
 
@@ -130,7 +132,8 @@ Options:
130
132
  | -l, --log-level <level> | | Log level (choices: `info`, `verbose`, `debug`) |
131
133
  | -i, --img-output-path <string> | | Path to directory where images will be stored. If this is not included, images will be placed in the same directory as the document that uses them, which then allows for localization of screenshots. |
132
134
  | -p, --img-prefix-in-markdown <string> | | When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path. |
133
- | -h, --help | | display help for command |
135
+ | --require-slugs | | If set, docu-notion will fail if any pages it would otherwise publish are missing a slug in Notion. |
136
+ | -h, --help | | display help for command |
134
137
 
135
138
  # Plugins
136
139
 
package/dist/pull.d.ts CHANGED
@@ -8,6 +8,7 @@ export type DocuNotionOptions = {
8
8
  imgOutputPath: string;
9
9
  imgPrefixInMarkdown: string;
10
10
  statusTag: string;
11
+ requireSlugs?: boolean;
11
12
  };
12
13
  export declare function notionPull(options: DocuNotionOptions): Promise<void>;
13
14
  export declare function executeWithRateLimitAndRetries<T>(label: string, asyncFunction: () => Promise<T>): Promise<T>;
package/dist/pull.js CHANGED
@@ -54,6 +54,7 @@ const counts = {
54
54
  skipped_because_empty: 0,
55
55
  skipped_because_status: 0,
56
56
  skipped_because_level_cannot_have_content: 0,
57
+ error_because_no_slug: 0,
57
58
  };
58
59
  function notionPull(options) {
59
60
  return __awaiter(this, void 0, void 0, function* () {
@@ -127,10 +128,16 @@ function outputPages(options, config, pages) {
127
128
  ++context.counts.skipped_because_status;
128
129
  }
129
130
  else {
131
+ if (options.requireSlugs && !page.hasExplicitSlug) {
132
+ (0, log_1.error)(`Page "${page.nameOrTitle}" is missing a required slug. (--require-slugs is set.)`);
133
+ ++counts.error_because_no_slug;
134
+ }
130
135
  const markdown = yield (0, transform_1.getMarkdownForPage)(config, context, page);
131
136
  writePage(page, markdown);
132
137
  }
133
138
  }
139
+ if (counts.error_because_no_slug > 0)
140
+ (0, process_1.exit)(1);
134
141
  (0, log_1.info)(`Finished processing ${pages.length} pages`);
135
142
  (0, log_1.info)(JSON.stringify(counts));
136
143
  });
package/dist/run.js CHANGED
@@ -61,7 +61,8 @@ function run() {
61
61
  "debug",
62
62
  ]))
63
63
  .option("-i, --img-output-path <string>", "Path to directory where images will be stored. If this is not included, images will be placed in the same directory as the document that uses them, which then allows for localization of screenshots.")
64
- .option("-p, --img-prefix-in-markdown <string>", "When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path.");
64
+ .option("-p, --img-prefix-in-markdown <string>", "When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path.")
65
+ .option("--require-slugs", "If set, docu-notion will fail if any pages it would otherwise publish are missing a slug in Notion.", false);
65
66
  commander_1.program.showHelpAfterError();
66
67
  commander_1.program.parse();
67
68
  (0, log_1.setLogLevel)(commander_1.program.opts().logLevel);
package/package.json CHANGED
@@ -90,5 +90,5 @@
90
90
  "volta": {
91
91
  "node": "18.16.0"
92
92
  },
93
- "version": "0.14.0-alpha.13"
93
+ "version": "0.14.0-alpha.14"
94
94
  }