@qualcomm-ui/mdx-vite 2.5.4 → 2.6.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/dist/cli.js CHANGED
@@ -3565,6 +3565,11 @@ var configSchema = implement().with({
3565
3565
  hotUpdateIgnore: z2.instanceof(RegExp).optional(),
3566
3566
  navConfig: z2.array(z2.union([routeMetaSchema, navMetaSchema])).optional(),
3567
3567
  pageDirectory: z2.string().optional(),
3568
+ pageTimestampMetadata: z2.union([
3569
+ z2.literal("off"),
3570
+ z2.literal("timestamp"),
3571
+ z2.literal("user-and-timestamp")
3572
+ ]).optional(),
3568
3573
  routingStrategy: z2.union([
3569
3574
  z2.literal("vite-generouted"),
3570
3575
  z2.function(z2.tuple([z2.string()]), z2.array(z2.string()))
@@ -3590,7 +3595,9 @@ var frontmatterSchema = implement().with({
3590
3595
  id: z3.string().optional(),
3591
3596
  restricted: z3.boolean().optional(),
3592
3597
  sideNavTitle: z3.string().optional(),
3593
- title: z3.string()
3598
+ title: z3.string(),
3599
+ updatedBy: z3.string().optional(),
3600
+ updatedOn: z3.string().optional()
3594
3601
  });
3595
3602
  function fixPath(str) {
3596
3603
  return str.replaceAll("\\", "/");
@@ -3866,6 +3873,7 @@ var DocPropsIndexer = class {
3866
3873
 
3867
3874
  // src/docs-plugin/internal/services/markdown/markdown-file-reader.ts
3868
3875
  import chalk from "chalk";
3876
+ import { execSync } from "node:child_process";
3869
3877
  import { createHash } from "node:crypto";
3870
3878
  import { readFileSync } from "node:fs";
3871
3879
  import remarkFrontmatter from "remark-frontmatter";
@@ -3873,9 +3881,32 @@ import remarkParse2 from "remark-parse";
3873
3881
  import remarkParseFrontmatter from "remark-parse-frontmatter";
3874
3882
  import remarkStringify2 from "remark-stringify";
3875
3883
  import { unified as unified2 } from "unified";
3884
+ function getGitMetadata(filePath, mode) {
3885
+ if (mode === "off") {
3886
+ return {};
3887
+ }
3888
+ try {
3889
+ const format = mode === "user-and-timestamp" ? "%cI%n%aN" : "%cI";
3890
+ const result = execSync(`git log -1 --format=${format} -- "${filePath}"`, {
3891
+ encoding: "utf-8",
3892
+ stdio: ["pipe", "pipe", "pipe"]
3893
+ }).trim();
3894
+ if (!result) {
3895
+ return {};
3896
+ }
3897
+ if (mode === "user-and-timestamp") {
3898
+ const [updatedOn, updatedBy] = result.split("\n");
3899
+ return { updatedBy, updatedOn };
3900
+ }
3901
+ return { updatedOn: result };
3902
+ } catch {
3903
+ return {};
3904
+ }
3905
+ }
3876
3906
  var MarkdownFileReader = class {
3877
- constructor(enabled) {
3907
+ constructor(enabled, pageTimestampMetadata = "off") {
3878
3908
  this.enabled = enabled;
3909
+ this.pageTimestampMetadata = pageTimestampMetadata;
3879
3910
  }
3880
3911
  cachedFileCount = 0;
3881
3912
  logWarnings = true;
@@ -3941,6 +3972,15 @@ var MarkdownFileReader = class {
3941
3972
  console.debug(`- ${issue.path.join(".")}`);
3942
3973
  });
3943
3974
  }
3975
+ if (!frontmatter.updatedOn || !frontmatter.updatedBy) {
3976
+ const gitMetadata = getGitMetadata(filepath, this.pageTimestampMetadata);
3977
+ if (!frontmatter.updatedOn && gitMetadata.updatedOn) {
3978
+ frontmatter.updatedOn = gitMetadata.updatedOn;
3979
+ }
3980
+ if (!frontmatter.updatedBy && gitMetadata.updatedBy) {
3981
+ frontmatter.updatedBy = gitMetadata.updatedBy;
3982
+ }
3983
+ }
3944
3984
  return { cached, fileContents, frontmatter };
3945
3985
  }
3946
3986
  updateCache(filepath, fileContents, cacheData) {
@@ -4897,7 +4937,8 @@ var SearchIndexer = class {
4897
4937
  this.navBuilder = addons.navBuilder || new NavBuilder(this.metaJson, this.routeMetaNav);
4898
4938
  this.docPropsIndexer = addons.docPropsIndexer || new DocPropsIndexer(this.config.typeDocProps ?? {});
4899
4939
  this.fileCache = addons.fileCache || new MarkdownFileReader(
4900
- process.env.NODE_ENV === "development" && !this.config.disableCache
4940
+ process.env.NODE_ENV === "development" && !this.config.disableCache,
4941
+ this.config.pageTimestampMetadata
4901
4942
  );
4902
4943
  }
4903
4944
  docPropsIndexer;
@@ -4966,7 +5007,9 @@ var SearchIndexer = class {
4966
5007
  pathname,
4967
5008
  pathSegments,
4968
5009
  restricted: defined(routeMeta.restricted) ? routeMeta.restricted : frontmatter.restricted,
4969
- title: defined(routeMeta.title) ? routeMeta.title || "" : frontmatter.title || ""
5010
+ title: defined(routeMeta.title) ? routeMeta.title || "" : frontmatter.title || "",
5011
+ updatedBy: frontmatter.updatedBy,
5012
+ updatedOn: frontmatter.updatedOn
4970
5013
  };
4971
5014
  }
4972
5015
  /**