hdoc-tools 0.20.0 → 0.21.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/hdoc-build.js CHANGED
@@ -45,6 +45,8 @@
45
45
 
46
46
  const built_file_hashes = [];
47
47
  const css_templates = [];
48
+ const draft_links = [];
49
+ const draft_files_removed = [];
48
50
  const errors_filename = [];
49
51
  const index_records = [];
50
52
  const md_files = [];
@@ -971,6 +973,15 @@
971
973
 
972
974
  // File callback for build scan
973
975
  const build_file_callback = (element) => {
976
+ let rel_path = element.relativePath.replace(path.extname(element.relativePath), '');
977
+ if (rel_path.endsWith('/index')) rel_path = rel_path.substring(0, rel_path.length - 6);
978
+
979
+ if (draft_links.indexOf(rel_path) !== -1) {
980
+ draft_files_removed.push(element.relativePath);
981
+ fs.rmSync(element.path);
982
+ return;
983
+ }
984
+
974
985
  if (element.extension === "md") {
975
986
  element.hb_source_path = path.join(
976
987
  global_source_path,
@@ -1269,6 +1280,10 @@
1269
1280
  }
1270
1281
  console.log("Processing navigation breadcrumbs...");
1271
1282
  const bc_build = hdoc.build_breadcrumbs(hdocbook_config.navigation.items);
1283
+
1284
+ console.log("Getting list of draft links to exclude from the build...");
1285
+ draft_links.push(...hdoc.get_draft_links(hdocbook_config.navigation.items));
1286
+
1272
1287
  if (bc_build.errors.length > 0) {
1273
1288
  console.log("\r\n-----------------------");
1274
1289
  console.log(" Validation Output ");
@@ -1282,6 +1297,7 @@
1282
1297
  }
1283
1298
  bc = bc_build.bc;
1284
1299
  console.log("Processing content...");
1300
+
1285
1301
  // Get a list of MD files in work_path
1286
1302
  dree.scan(work_path, dreeOptions, build_file_callback);
1287
1303
 
@@ -1327,6 +1343,7 @@
1327
1343
 
1328
1344
  // Output to console
1329
1345
  console.log(`\n MD files found: ${conversion_attempted}`);
1346
+ console.log(` Draft Files Excluded: ${draft_files_removed.length}`);
1330
1347
  console.log(`Successfully converted to HTML: ${conversion_success}`);
1331
1348
  if (conversion_failed > 0)
1332
1349
  console.error(` Failed to convert: ${conversion_failed}\n`);
@@ -1355,6 +1372,7 @@
1355
1372
  prods_supported,
1356
1373
  gen_exclude,
1357
1374
  redirects,
1375
+ draft_links,
1358
1376
  );
1359
1377
  if (!validation_success) {
1360
1378
  const end_time = Date.now();