@qualcomm-ui/mdx-vite 2.2.0 → 2.3.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
@@ -5672,8 +5672,8 @@ function cleanDefaultValue(defaultValue) {
5672
5672
  }
5673
5673
  async function scanPages(routesFolder, verbose, excludePatterns = [], baseUrl) {
5674
5674
  const components = [];
5675
- function shouldExclude(dirPath) {
5676
- const dirName = basename(dirPath);
5675
+ function shouldExclude(fileOrDir) {
5676
+ const dirName = basename(fileOrDir);
5677
5677
  return excludePatterns.some((pattern) => {
5678
5678
  if (pattern.includes("*")) {
5679
5679
  const regex = new RegExp(`^${pattern.replace(/\*/g, ".*")}$`);
@@ -5690,7 +5690,9 @@ async function scanPages(routesFolder, verbose, excludePatterns = [], baseUrl) {
5690
5690
  return;
5691
5691
  }
5692
5692
  const entries = await readdir(dirPath, { withFileTypes: true });
5693
- const mdxFiles = entries.filter((f) => f.name.endsWith(".mdx")) ?? [];
5693
+ const mdxFiles = entries.filter(
5694
+ (f) => f.name.endsWith(".mdx") && !shouldExclude(f.name)
5695
+ ) ?? [];
5694
5696
  for (const mdxFile of mdxFiles) {
5695
5697
  const demosFolder = entries.find((f) => f.name === "demos");
5696
5698
  const demosFolderPath = demosFolder ? join3(dirPath, demosFolder.name) : void 0;
@@ -5701,7 +5703,7 @@ async function scanPages(routesFolder, verbose, excludePatterns = [], baseUrl) {
5701
5703
  const url = getPathnameFromPathSegments(segments);
5702
5704
  components.push({
5703
5705
  demosFolder: demosFolderPath,
5704
- id: segments.join("-"),
5706
+ id: segments.join("-").trim(),
5705
5707
  mdxFile: join3(dirPath, mdxFile.name),
5706
5708
  name: segments.at(-1),
5707
5709
  path: dirPath,
@@ -5780,12 +5782,20 @@ async function generateLlmsTxt(pages, projectName, description, baseUrl) {
5780
5782
  const lines = [
5781
5783
  getIntroLines(pages, projectName, description, baseUrl)
5782
5784
  ];
5783
- lines.push("## Documentation Content");
5784
5785
  lines.push("");
5785
5786
  for (const page of pages) {
5786
- lines.push(`# ${page.title}`);
5787
+ const content = page.content.split("\n").map((line) => {
5788
+ if (line.startsWith("#")) {
5789
+ return `#${line}`;
5790
+ }
5791
+ return line;
5792
+ });
5793
+ if (content.every((line) => !line.trim())) {
5794
+ continue;
5795
+ }
5796
+ lines.push(`## ${page.title}`);
5787
5797
  lines.push("");
5788
- lines.push(page.content);
5798
+ lines.push(content.join("\n"));
5789
5799
  lines.push("");
5790
5800
  }
5791
5801
  return lines.join("\n");
@@ -6157,7 +6167,7 @@ async function generatePerPageExports({
6157
6167
  }
6158
6168
  }
6159
6169
  }
6160
- const outfile = `${resolve5(outputPath)}/${kebabCase(page.id)}.md`;
6170
+ const outfile = `${resolve5(outputPath)}/${kebabCase(page.id || page.name)}.md`;
6161
6171
  await writeFile3(outfile, lines.join("\n"), "utf-8");
6162
6172
  const stats = await stat(outfile);
6163
6173
  totalSize += stats.size / 1024;
@@ -6252,7 +6262,7 @@ function addGenerateKnowledgeCommand() {
6252
6262
  "Project description for llms.txt"
6253
6263
  ).option("-v, --verbose", "Enable verbose logging", false).option(
6254
6264
  "--exclude <patterns...>",
6255
- "Exclude folder patterns (supports * wildcards)",
6265
+ "Exclude file or folder patterns (supports * wildcards)",
6256
6266
  []
6257
6267
  ).option("--base-url <url>", "Base URL for component documentation links").option("--metadata <pairs...>", "metadata key-value pairs").option("--clean", "Clean the output path before generating").option("--include-imports", "Include relative import source files", true).action(async (options) => {
6258
6268
  loadEnv();