@farming-labs/next 0.1.63 → 0.1.64

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/config.mjs +41 -4
  2. package/package.json +3 -3
package/dist/config.mjs CHANGED
@@ -229,6 +229,7 @@ function createDocsWorkspaceAliases() {
229
229
  "@farming-labs/theme/client-hooks": "./packages/fumadocs/src/docs-client-hooks.tsx",
230
230
  "@farming-labs/theme/concrete": "./packages/fumadocs/src/concrete/index.ts",
231
231
  "@farming-labs/theme/hardline": "./packages/fumadocs/src/hardline/index.ts",
232
+ "@farming-labs/theme/ledger": "./packages/fumadocs/src/ledger/index.ts",
232
233
  "@farming-labs/theme/mdx": "./packages/fumadocs/src/mdx.ts",
233
234
  "@farming-labs/theme/search": "./packages/fumadocs/src/search.ts"
234
235
  };
@@ -566,6 +567,43 @@ function toImportPath(fromFile, toFile) {
566
567
  const relativePath = relative(dirname(fromFile), toFile).replaceAll("\\", "/");
567
568
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
568
569
  }
570
+ function toObjectKeySource(key) {
571
+ return /^[A-Za-z_$][\w$]*$/.test(key) ? key : JSON.stringify(key);
572
+ }
573
+ function toInlineValueSource(value) {
574
+ if (typeof value === "string") return JSON.stringify(value);
575
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
576
+ if (typeof value === "boolean") return String(value);
577
+ if (value === null) return "null";
578
+ return JSON.stringify(value) ?? "undefined";
579
+ }
580
+ function toObjectPropertySource(key, value, depth) {
581
+ const childIndent = " ".repeat(depth + 2);
582
+ const wrappedValueIndent = " ".repeat(depth + 4);
583
+ const valueSource = toChangelogMetadataSource(value, depth + 2);
584
+ const inlineSource = `${childIndent}${toObjectKeySource(key)}: ${valueSource},`;
585
+ if (!valueSource.includes("\n") && inlineSource.length > 100) return `${childIndent}${toObjectKeySource(key)}:\n${wrappedValueIndent}${valueSource},`;
586
+ return inlineSource;
587
+ }
588
+ function toChangelogMetadataSource(value, depth = 0) {
589
+ const indent = " ".repeat(depth);
590
+ const childIndent = " ".repeat(depth + 2);
591
+ if (Array.isArray(value)) {
592
+ if (value.length === 0) return "[]";
593
+ if (value.every((item) => item === null || typeof item === "string" || typeof item === "number" || typeof item === "boolean")) return `[${value.map(toInlineValueSource).join(", ")}]`;
594
+ return `[
595
+ ${value.map((item) => `${childIndent}${toChangelogMetadataSource(item, depth + 2)},`).join("\n")}
596
+ ${indent}]`;
597
+ }
598
+ if (value && typeof value === "object") {
599
+ const entries = Object.entries(value).filter((entry) => entry[1] !== void 0);
600
+ if (entries.length === 0) return "{}";
601
+ return `{
602
+ ${entries.map(([key, item]) => toObjectPropertySource(key, item, depth)).join("\n")}
603
+ ${indent}}`;
604
+ }
605
+ return toInlineValueSource(value);
606
+ }
569
607
  function buildInlineChangelogEntriesSource(root, pagePath, entryPath, routePath, entries) {
570
608
  const imports = [];
571
609
  const records = [];
@@ -578,16 +616,15 @@ function buildInlineChangelogEntriesSource(root, pagePath, entryPath, routePath,
578
616
  url: ${JSON.stringify(`/${entryPath}/${routePath}/${entry.slug}`)},
579
617
  sourcePath: ${JSON.stringify(relative(root, entry.sourceFile).replaceAll("\\", "/"))},
580
618
  Component: ${importName},
581
- metadata: ${JSON.stringify(entry.metadata)},
619
+ metadata: ${toChangelogMetadataSource(entry.metadata, 4)},
582
620
  }`);
583
621
  });
584
622
  return {
585
623
  importsSource: `import type { GeneratedChangelogEntry } from "@farming-labs/next/changelog";
586
624
  ${imports.join("\n")}`.trimEnd(),
587
625
  entriesSource: `export const changelogEntries: GeneratedChangelogEntry[] = [
588
- ${records.join(",\n")}
589
- ];
590
- `
626
+ ${records.length > 0 ? `${records.join(",\n")},` : ""}
627
+ ];`
591
628
  };
592
629
  }
593
630
  function buildChangelogIndexPageSource(root, pagePath, entryPath, routePath, entries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/next",
3
- "version": "0.1.63",
3
+ "version": "0.1.64",
4
4
  "description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
5
5
  "keywords": [
6
6
  "docs",
@@ -95,8 +95,8 @@
95
95
  "tsdown": "^0.20.3",
96
96
  "typescript": "^5.9.3",
97
97
  "vitest": "^3.2.4",
98
- "@farming-labs/docs": "0.1.63",
99
- "@farming-labs/theme": "0.1.63"
98
+ "@farming-labs/docs": "0.1.64",
99
+ "@farming-labs/theme": "0.1.64"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@farming-labs/docs": ">=0.0.1",