sequoia-cli 0.2.1-beta.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -38
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -67261,32 +67261,18 @@ function parseFrontmatter(content, mapping) {
67261
67261
  rawFrontmatter: raw
67262
67262
  };
67263
67263
  }
67264
- function getSlugFromFilename(filename) {
67265
- return filename.replace(/\.mdx?$/, "").toLowerCase().replace(/\s+/g, "-");
67266
- }
67267
67264
  function getSlugFromOptions(relativePath, rawFrontmatter, options = {}) {
67268
- const {
67269
- slugSource = "filename",
67270
- slugField = "slug",
67271
- removeIndexFromSlug = false
67272
- } = options;
67265
+ const { slugField, removeIndexFromSlug = false } = options;
67273
67266
  let slug;
67274
- switch (slugSource) {
67275
- case "path":
67267
+ if (slugField) {
67268
+ const frontmatterValue = rawFrontmatter[slugField];
67269
+ if (frontmatterValue && typeof frontmatterValue === "string") {
67270
+ slug = frontmatterValue.replace(/^\//, "").toLowerCase().replace(/\s+/g, "-");
67271
+ } else {
67276
67272
  slug = relativePath.replace(/\.mdx?$/, "").toLowerCase().replace(/\s+/g, "-");
67277
- break;
67278
- case "frontmatter": {
67279
- const frontmatterValue = rawFrontmatter[slugField] || rawFrontmatter.slug || rawFrontmatter.url;
67280
- if (frontmatterValue && typeof frontmatterValue === "string") {
67281
- slug = frontmatterValue.replace(/^\//, "").toLowerCase().replace(/\s+/g, "-");
67282
- } else {
67283
- slug = getSlugFromFilename(path2.basename(relativePath));
67284
- }
67285
- break;
67286
67273
  }
67287
- default:
67288
- slug = getSlugFromFilename(path2.basename(relativePath));
67289
- break;
67274
+ } else {
67275
+ slug = relativePath.replace(/\.mdx?$/, "").toLowerCase().replace(/\s+/g, "-");
67290
67276
  }
67291
67277
  if (removeIndexFromSlug) {
67292
67278
  slug = slug.replace(/\/_?index$/, "");
@@ -67310,7 +67296,7 @@ function shouldIgnore(relativePath, ignorePatterns) {
67310
67296
  }
67311
67297
  async function scanContentDirectory(contentDir, frontmatterMappingOrOptions, ignorePatterns = []) {
67312
67298
  let options;
67313
- if (frontmatterMappingOrOptions && (("slugSource" in frontmatterMappingOrOptions) || ("frontmatterMapping" in frontmatterMappingOrOptions) || ("ignorePatterns" in frontmatterMappingOrOptions))) {
67299
+ if (frontmatterMappingOrOptions && (("frontmatterMapping" in frontmatterMappingOrOptions) || ("ignorePatterns" in frontmatterMappingOrOptions) || ("slugField" in frontmatterMappingOrOptions))) {
67314
67300
  options = frontmatterMappingOrOptions;
67315
67301
  } else {
67316
67302
  options = {
@@ -67321,7 +67307,6 @@ async function scanContentDirectory(contentDir, frontmatterMappingOrOptions, ign
67321
67307
  const {
67322
67308
  frontmatterMapping,
67323
67309
  ignorePatterns: ignore = [],
67324
- slugSource,
67325
67310
  slugField,
67326
67311
  removeIndexFromSlug
67327
67312
  } = options;
@@ -67341,7 +67326,6 @@ async function scanContentDirectory(contentDir, frontmatterMappingOrOptions, ign
67341
67326
  try {
67342
67327
  const { frontmatter, body, rawFrontmatter } = parseFrontmatter(rawContent, frontmatterMapping);
67343
67328
  const slug = getSlugFromOptions(relativePath, rawFrontmatter, {
67344
- slugSource,
67345
67329
  slugField,
67346
67330
  removeIndexFromSlug
67347
67331
  });
@@ -68066,12 +68050,6 @@ function generateConfigTemplate(options) {
68066
68050
  if (options.ignore && options.ignore.length > 0) {
68067
68051
  config.ignore = options.ignore;
68068
68052
  }
68069
- if (options.slugSource && options.slugSource !== "filename") {
68070
- config.slugSource = options.slugSource;
68071
- }
68072
- if (options.slugField && options.slugField !== "slug") {
68073
- config.slugField = options.slugField;
68074
- }
68075
68053
  if (options.removeIndexFromSlug) {
68076
68054
  config.removeIndexFromSlug = options.removeIndexFromSlug;
68077
68055
  }
@@ -68412,8 +68390,8 @@ var injectCommand = import_cmd_ts3.command({
68412
68390
  slugToAtUri.set(lastSegment, postState.atUri);
68413
68391
  }
68414
68392
  } else if (postState.atUri) {
68415
- const basename4 = path7.basename(filePath, path7.extname(filePath));
68416
- slugToAtUri.set(basename4.toLowerCase(), postState.atUri);
68393
+ const basename3 = path7.basename(filePath, path7.extname(filePath));
68394
+ slugToAtUri.set(basename3.toLowerCase(), postState.atUri);
68417
68395
  }
68418
68396
  }
68419
68397
  if (slugToAtUri.size === 0) {
@@ -68551,8 +68529,7 @@ var publishCommand = import_cmd_ts4.command({
68551
68529
  const posts = await scanContentDirectory(contentDir, {
68552
68530
  frontmatterMapping: config.frontmatter,
68553
68531
  ignorePatterns: config.ignore,
68554
- slugSource: config.slugSource,
68555
- slugField: config.slugField,
68532
+ slugField: config.frontmatter?.slugField,
68556
68533
  removeIndexFromSlug: config.removeIndexFromSlug
68557
68534
  });
68558
68535
  s.stop(`Found ${posts.length} posts`);
@@ -68806,8 +68783,7 @@ var syncCommand = import_cmd_ts5.command({
68806
68783
  const localPosts = await scanContentDirectory(contentDir, {
68807
68784
  frontmatterMapping: config.frontmatter,
68808
68785
  ignorePatterns: config.ignore,
68809
- slugSource: config.slugSource,
68810
- slugField: config.slugField,
68786
+ slugField: config.frontmatter?.slugField,
68811
68787
  removeIndexFromSlug: config.removeIndexFromSlug
68812
68788
  });
68813
68789
  s.stop(`Found ${localPosts.length} local posts`);
@@ -68912,7 +68888,7 @@ Publish evergreen content to the ATmosphere
68912
68888
 
68913
68889
  > https://tangled.org/stevedylan.dev/sequoia
68914
68890
  `,
68915
- version: "0.2.1-beta.0",
68891
+ version: "0.2.0",
68916
68892
  cmds: {
68917
68893
  auth: authCommand,
68918
68894
  init: initCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sequoia-cli",
3
- "version": "0.2.1-beta.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sequoia": "dist/index.js"