storybook-addon-design-system-docs 1.0.1 → 1.0.2

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/preset.cjs CHANGED
@@ -301,10 +301,19 @@ function validateAssetConfig(configs) {
301
301
  }
302
302
  }
303
303
  function normalizeAssetGroup(config, sidebarGroup = "Assets/", configDir) {
304
- let storyPath = config.path ?? sidebarGroup;
305
- if (storyPath.endsWith("/")) {
306
- storyPath = `${storyPath}${config.name}`;
304
+ const rawPath = config.path;
305
+ let titlePrefix;
306
+ if (rawPath?.startsWith("/")) {
307
+ titlePrefix = rawPath.slice(1);
308
+ } else if (rawPath) {
309
+ titlePrefix = sidebarGroup ? `${sidebarGroup}/${rawPath}` : rawPath;
310
+ } else {
311
+ titlePrefix = sidebarGroup;
312
+ }
313
+ if (titlePrefix && !titlePrefix.endsWith("/")) {
314
+ titlePrefix += "/";
307
315
  }
316
+ const storyPath = titlePrefix ? `${titlePrefix}${config.name}` : config.name;
308
317
  const source = path2__default.default.isAbsolute(config.source) ? config.source : configDir ? path2__default.default.resolve(configDir, config.source) : config.source;
309
318
  const variants = {
310
319
  ...DEFAULT_VARIANT_CONFIG,
@@ -550,6 +559,11 @@ function generateAssetStories(options) {
550
559
  if (!assets || !Array.isArray(assets) || assets.length === 0) {
551
560
  return [];
552
561
  }
562
+ const normalizedAssets = normalizeAssetConfigs(
563
+ assets,
564
+ addonOptions.sidebarGroup,
565
+ configDir
566
+ );
553
567
  const assetsDir = path2__default.default.resolve(configDir, "design-system/assets");
554
568
  if (!fs2__namespace.default.existsSync(assetsDir)) {
555
569
  fs2__namespace.default.mkdirSync(assetsDir, { recursive: true });
@@ -568,13 +582,36 @@ function generateAssetStories(options) {
568
582
  return [];
569
583
  }
570
584
  const validFiles = /* @__PURE__ */ new Set();
571
- assets.forEach((group) => {
585
+ normalizedAssets.forEach((group) => {
572
586
  const groupName = group.name;
573
587
  const groupTitle = group.title || groupName;
574
588
  const cleanName = groupName.replace(/[^a-zA-Z0-9]/g, "");
575
589
  const filename = `${cleanName}.mdx`;
576
590
  const filePath = path2__default.default.join(assetsDir, filename);
577
- const fileContent = templateContent.replace(/\{\{group\.name\}\}/g, groupName).replace(/\{\{group\.title\}\}/g, groupTitle);
591
+ let fileContent = templateContent.replace(
592
+ /^\s*<Meta\s+title="[^"]*"\s*\/>/m,
593
+ `<Meta title="${group.path}" />`
594
+ ).replace(/\{\{group\.name\}\}/g, groupName).replace(/\{\{group\.title\}\}/g, groupTitle);
595
+ if (!fileContent.match(/^export\s+(const|function|class)/m)) {
596
+ const lines = fileContent.split("\n");
597
+ let lastImportIndex = -1;
598
+ for (let i = 0; i < lines.length; i++) {
599
+ if (lines[i].trim().startsWith("import ")) {
600
+ lastImportIndex = i;
601
+ }
602
+ }
603
+ if (lastImportIndex !== -1) {
604
+ lines.splice(
605
+ lastImportIndex + 1,
606
+ 0,
607
+ "",
608
+ "// Required for Storybook indexer",
609
+ "export const __ignore = {};",
610
+ ""
611
+ );
612
+ fileContent = lines.join("\n");
613
+ }
614
+ }
578
615
  try {
579
616
  fs2__namespace.default.writeFileSync(filePath, fileContent);
580
617
  validFiles.add(filename);
@@ -654,8 +691,8 @@ function normalizeAddonOptions(options) {
654
691
  };
655
692
  }
656
693
  function validateSidebarGroup(sidebarGroup) {
657
- if (typeof sidebarGroup !== "string" || !sidebarGroup.trim()) {
658
- throw new Error("sidebarGroup must be a non-empty string");
694
+ if (typeof sidebarGroup !== "string") {
695
+ throw new Error("sidebarGroup must be a string");
659
696
  }
660
697
  }
661
698
  function validateSections(sections) {
@@ -678,27 +715,24 @@ function isValidSectionName(name) {
678
715
  return typeof name === "string" && VALID_SECTIONS.includes(name);
679
716
  }
680
717
  function isValidSectionObject(section) {
681
- return typeof section === "object" && section !== null && isValidSectionName(section.name) && (section.path === void 0 || typeof section.path === "string" && section.path.trim().length > 0);
718
+ return typeof section === "object" && section !== null && isValidSectionName(section.name) && (section.path === void 0 || typeof section.path === "string");
682
719
  }
683
720
  function normalizeSection(section, sidebarGroup) {
684
721
  const name = typeof section === "string" ? section : section.name;
685
- let path8 = typeof section === "string" ? sidebarGroup : section.path ?? sidebarGroup;
686
- if (path8 === "/") {
687
- return { name, path: name };
688
- }
689
- if (typeof section === "object" && section.path !== void 0) {
690
- if (section.path === "/") {
691
- return { name, path: name };
692
- }
693
- if (!path8.endsWith("/")) {
694
- return { name, path: `${path8}/${name}` };
695
- }
696
- return { name, path: `${path8}${name}` };
722
+ const rawPath = typeof section === "string" ? void 0 : section.path;
723
+ let titlePrefix;
724
+ if (rawPath?.startsWith("/")) {
725
+ titlePrefix = rawPath.slice(1);
726
+ } else if (rawPath) {
727
+ titlePrefix = sidebarGroup ? `${sidebarGroup}/${rawPath}` : rawPath;
728
+ } else {
729
+ titlePrefix = sidebarGroup;
697
730
  }
698
- if (!path8.endsWith("/")) {
699
- path8 = `${path8}/`;
731
+ if (titlePrefix && !titlePrefix.endsWith("/")) {
732
+ titlePrefix += "/";
700
733
  }
701
- return { name, path: `${path8}${name}` };
734
+ const path9 = titlePrefix ? `${titlePrefix}${name}` : name;
735
+ return { name, path: path9 };
702
736
  }
703
737
  function normalizeSections(sections, sidebarGroup) {
704
738
  return sections.map((section) => normalizeSection(section, sidebarGroup));
@@ -1318,6 +1352,71 @@ async function loadTheme(options) {
1318
1352
  `Could not determine how to load Tailwind config from '${options.tailwindConfig}'. File must be either a Tailwind config file (tailwind.config.{js,cjs,mjs,ts}) or a CSS file containing @theme.`
1319
1353
  );
1320
1354
  }
1355
+ var logger3 = new Logger("SectionGenerator");
1356
+ function generateSectionStories(options) {
1357
+ const { configDir, sections, addonOptions } = options;
1358
+ const generatedStories = [];
1359
+ const sectionsDir = path2__default.default.resolve(configDir, "design-system/sections");
1360
+ if (!fs2__namespace.default.existsSync(sectionsDir)) {
1361
+ fs2__namespace.default.mkdirSync(sectionsDir, { recursive: true });
1362
+ }
1363
+ const validFiles = /* @__PURE__ */ new Set();
1364
+ sections.forEach((section) => {
1365
+ const templatePath = resolveTemplate(section.name, addonOptions);
1366
+ if (!templatePath || !fs2__namespace.default.existsSync(templatePath)) {
1367
+ logger3.warn(`Could not find template for section: ${section.name}`);
1368
+ return;
1369
+ }
1370
+ try {
1371
+ const templateContent = fs2__namespace.default.readFileSync(templatePath, "utf-8");
1372
+ let newContent = templateContent.replace(
1373
+ /^\s*<Meta\s+title="[^"]*"\s*\/>/m,
1374
+ `<Meta title="${section.path}" />`
1375
+ );
1376
+ if (!newContent.match(/^export\s+(const|function|class)/m)) {
1377
+ const lines = newContent.split("\n");
1378
+ let lastImportIndex = -1;
1379
+ for (let i = 0; i < lines.length; i++) {
1380
+ if (lines[i].trim().startsWith("import ")) {
1381
+ lastImportIndex = i;
1382
+ }
1383
+ }
1384
+ if (lastImportIndex !== -1) {
1385
+ lines.splice(
1386
+ lastImportIndex + 1,
1387
+ 0,
1388
+ "",
1389
+ "// Required for Storybook indexer",
1390
+ "export const __ignore = {};",
1391
+ ""
1392
+ );
1393
+ newContent = lines.join("\n");
1394
+ }
1395
+ }
1396
+ const cleanName = section.name.replace(/[^a-zA-Z0-9]/g, "");
1397
+ const filename = `${cleanName}.mdx`;
1398
+ const filePath = path2__default.default.join(sectionsDir, filename);
1399
+ fs2__namespace.default.writeFileSync(filePath, newContent);
1400
+ validFiles.add(filename);
1401
+ generatedStories.push(filePath);
1402
+ } catch (error) {
1403
+ logger3.error(`Failed to generate section MDX for ${section.name}`, error);
1404
+ }
1405
+ });
1406
+ if (fs2__namespace.default.existsSync(sectionsDir)) {
1407
+ try {
1408
+ const files = fs2__namespace.default.readdirSync(sectionsDir);
1409
+ files.forEach((file) => {
1410
+ if (file.endsWith(".mdx") && !validFiles.has(file)) {
1411
+ fs2__namespace.default.unlinkSync(path2__default.default.join(sectionsDir, file));
1412
+ }
1413
+ });
1414
+ } catch (e) {
1415
+ logger3.warn("Failed to cleanup orphaned section files", e);
1416
+ }
1417
+ }
1418
+ return generatedStories;
1419
+ }
1321
1420
 
1322
1421
  // node_modules/glob/node_modules/minimatch/dist/esm/index.js
1323
1422
  var import_brace_expansion = __toESM(require_brace_expansion());
@@ -1990,11 +2089,11 @@ var qmarksTestNoExtDot = ([$0]) => {
1990
2089
  return (f) => f.length === len && f !== "." && f !== "..";
1991
2090
  };
1992
2091
  var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
1993
- var path4 = {
2092
+ var path5 = {
1994
2093
  win32: { sep: "\\" },
1995
2094
  posix: { sep: "/" }
1996
2095
  };
1997
- var sep = defaultPlatform === "win32" ? path4.win32.sep : path4.posix.sep;
2096
+ var sep = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
1998
2097
  minimatch.sep = sep;
1999
2098
  var GLOBSTAR = Symbol("globstar **");
2000
2099
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -5153,12 +5252,12 @@ var PathBase = class {
5153
5252
  /**
5154
5253
  * Get the Path object referenced by the string path, resolved from this Path
5155
5254
  */
5156
- resolve(path8) {
5157
- if (!path8) {
5255
+ resolve(path9) {
5256
+ if (!path9) {
5158
5257
  return this;
5159
5258
  }
5160
- const rootPath = this.getRootString(path8);
5161
- const dir = path8.substring(rootPath.length);
5259
+ const rootPath = this.getRootString(path9);
5260
+ const dir = path9.substring(rootPath.length);
5162
5261
  const dirParts = dir.split(this.splitSep);
5163
5262
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
5164
5263
  return result;
@@ -5910,8 +6009,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
5910
6009
  /**
5911
6010
  * @internal
5912
6011
  */
5913
- getRootString(path8) {
5914
- return path2.win32.parse(path8).root;
6012
+ getRootString(path9) {
6013
+ return path2.win32.parse(path9).root;
5915
6014
  }
5916
6015
  /**
5917
6016
  * @internal
@@ -5957,8 +6056,8 @@ var PathPosix = class _PathPosix extends PathBase {
5957
6056
  /**
5958
6057
  * @internal
5959
6058
  */
5960
- getRootString(path8) {
5961
- return path8.startsWith("/") ? "/" : "";
6059
+ getRootString(path9) {
6060
+ return path9.startsWith("/") ? "/" : "";
5962
6061
  }
5963
6062
  /**
5964
6063
  * @internal
@@ -6007,8 +6106,8 @@ var PathScurryBase = class {
6007
6106
  *
6008
6107
  * @internal
6009
6108
  */
6010
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs3 = defaultFS } = {}) {
6011
- this.#fs = fsFromOption(fs3);
6109
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
6110
+ this.#fs = fsFromOption(fs4);
6012
6111
  if (cwd instanceof URL || cwd.startsWith("file://")) {
6013
6112
  cwd = url.fileURLToPath(cwd);
6014
6113
  }
@@ -6047,11 +6146,11 @@ var PathScurryBase = class {
6047
6146
  /**
6048
6147
  * Get the depth of a provided path, string, or the cwd
6049
6148
  */
6050
- depth(path8 = this.cwd) {
6051
- if (typeof path8 === "string") {
6052
- path8 = this.cwd.resolve(path8);
6149
+ depth(path9 = this.cwd) {
6150
+ if (typeof path9 === "string") {
6151
+ path9 = this.cwd.resolve(path9);
6053
6152
  }
6054
- return path8.depth();
6153
+ return path9.depth();
6055
6154
  }
6056
6155
  /**
6057
6156
  * Return the cache of child entries. Exposed so subclasses can create
@@ -6538,9 +6637,9 @@ var PathScurryBase = class {
6538
6637
  process2();
6539
6638
  return results;
6540
6639
  }
6541
- chdir(path8 = this.cwd) {
6640
+ chdir(path9 = this.cwd) {
6542
6641
  const oldCwd = this.cwd;
6543
- this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
6642
+ this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
6544
6643
  this.cwd[setAsCwd](oldCwd);
6545
6644
  }
6546
6645
  };
@@ -6566,8 +6665,8 @@ var PathScurryWin32 = class extends PathScurryBase {
6566
6665
  /**
6567
6666
  * @internal
6568
6667
  */
6569
- newRoot(fs3) {
6570
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs3 });
6668
+ newRoot(fs4) {
6669
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
6571
6670
  }
6572
6671
  /**
6573
6672
  * Return true if the provided path string is an absolute path
@@ -6595,8 +6694,8 @@ var PathScurryPosix = class extends PathScurryBase {
6595
6694
  /**
6596
6695
  * @internal
6597
6696
  */
6598
- newRoot(fs3) {
6599
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs3 });
6697
+ newRoot(fs4) {
6698
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
6600
6699
  }
6601
6700
  /**
6602
6701
  * Return true if the provided path string is an absolute path
@@ -6896,8 +6995,8 @@ var MatchRecord = class {
6896
6995
  }
6897
6996
  // match, absolute, ifdir
6898
6997
  entries() {
6899
- return [...this.store.entries()].map(([path8, n]) => [
6900
- path8,
6998
+ return [...this.store.entries()].map(([path9, n]) => [
6999
+ path9,
6901
7000
  !!(n & 2),
6902
7001
  !!(n & 1)
6903
7002
  ]);
@@ -7102,9 +7201,9 @@ var GlobUtil = class {
7102
7201
  signal;
7103
7202
  maxDepth;
7104
7203
  includeChildMatches;
7105
- constructor(patterns, path8, opts) {
7204
+ constructor(patterns, path9, opts) {
7106
7205
  this.patterns = patterns;
7107
- this.path = path8;
7206
+ this.path = path9;
7108
7207
  this.opts = opts;
7109
7208
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
7110
7209
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -7123,11 +7222,11 @@ var GlobUtil = class {
7123
7222
  });
7124
7223
  }
7125
7224
  }
7126
- #ignored(path8) {
7127
- return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
7225
+ #ignored(path9) {
7226
+ return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
7128
7227
  }
7129
- #childrenIgnored(path8) {
7130
- return !!this.#ignore?.childrenIgnored?.(path8);
7228
+ #childrenIgnored(path9) {
7229
+ return !!this.#ignore?.childrenIgnored?.(path9);
7131
7230
  }
7132
7231
  // backpressure mechanism
7133
7232
  pause() {
@@ -7342,8 +7441,8 @@ var GlobUtil = class {
7342
7441
  };
7343
7442
  var GlobWalker = class extends GlobUtil {
7344
7443
  matches = /* @__PURE__ */ new Set();
7345
- constructor(patterns, path8, opts) {
7346
- super(patterns, path8, opts);
7444
+ constructor(patterns, path9, opts) {
7445
+ super(patterns, path9, opts);
7347
7446
  }
7348
7447
  matchEmit(e) {
7349
7448
  this.matches.add(e);
@@ -7380,8 +7479,8 @@ var GlobWalker = class extends GlobUtil {
7380
7479
  };
7381
7480
  var GlobStream = class extends GlobUtil {
7382
7481
  results;
7383
- constructor(patterns, path8, opts) {
7384
- super(patterns, path8, opts);
7482
+ constructor(patterns, path9, opts) {
7483
+ super(patterns, path9, opts);
7385
7484
  this.results = new Minipass({
7386
7485
  signal: this.signal,
7387
7486
  objectMode: true
@@ -7870,9 +7969,15 @@ function createAssetManager(groups) {
7870
7969
  }
7871
7970
 
7872
7971
  // src/addon/unplugin.ts
7873
- var logger3 = new Logger("unplugin");
7972
+ var logger4 = new Logger("unplugin");
7874
7973
  var unplugin = unplugin$1.createUnplugin((options) => {
7875
7974
  const assetManager = options.assetOptions?.groups && options.assetOptions.groups.length > 0 ? createAssetManager(options.assetOptions.groups) : void 0;
7975
+ const sectionPathMap = /* @__PURE__ */ new Map();
7976
+ if (options.addonOptions?.sections) {
7977
+ options.addonOptions.sections.forEach((section) => {
7978
+ sectionPathMap.set(section.name.toLowerCase(), section.path);
7979
+ });
7980
+ }
7876
7981
  return {
7877
7982
  name: "unplugin-design-system-docs",
7878
7983
  enforce: "pre",
@@ -7892,12 +7997,15 @@ var unplugin = unplugin$1.createUnplugin((options) => {
7892
7997
  loadInclude(id) {
7893
7998
  return id === DESIGN_SYSTEM_DATA_ID || id === ASSET_DATA_ID || id.startsWith(ASSET_GROUP_ID_PREFIX);
7894
7999
  },
8000
+ transformInclude(id) {
8001
+ return id.includes("/templates/") && id.endsWith(".mdx");
8002
+ },
7895
8003
  async load(id) {
7896
8004
  try {
7897
8005
  if (id === DESIGN_SYSTEM_DATA_ID) {
7898
8006
  if (!options.configPath) {
7899
8007
  const errorMsg = "No Tailwind config path found. Cannot load theme data. This is likely a bug in the addon setup.";
7900
- logger3.error(errorMsg);
8008
+ logger4.error(errorMsg);
7901
8009
  throw new Error(errorMsg);
7902
8010
  }
7903
8011
  if (this.addWatchFile && options.configPath) {
@@ -7926,24 +8034,56 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
7926
8034
  }
7927
8035
  if (id.startsWith(ASSET_GROUP_ID_PREFIX)) {
7928
8036
  const groupName = id.slice(ASSET_GROUP_ID_PREFIX.length);
7929
- logger3.info(`Loading asset group data: ${groupName}`);
8037
+ logger4.info(`Loading asset group data: ${groupName}`);
7930
8038
  if (!assetManager) {
7931
- logger3.warn(`No asset manager available for group: ${groupName}`);
8039
+ logger4.warn(`No asset manager available for group: ${groupName}`);
7932
8040
  return "export default {}";
7933
8041
  }
7934
8042
  const group = await assetManager.getGroup(groupName);
7935
8043
  if (!group) {
7936
- logger3.warn(`Asset group not found: ${groupName}`);
8044
+ logger4.warn(`Asset group not found: ${groupName}`);
7937
8045
  return "export default {}";
7938
8046
  }
7939
8047
  return `export default ${JSON.stringify(group)}`;
7940
8048
  }
7941
8049
  } catch (error) {
7942
8050
  const errorMessage = error instanceof Error ? error.message : String(error);
7943
- logger3.error(`Failed to load virtual module: ${id}`, error);
8051
+ logger4.error(`Failed to load virtual module: ${id}`, error);
7944
8052
  throw new Error(`[storybook-addon-design-system-docs] ${errorMessage}`);
7945
8053
  }
7946
8054
  },
8055
+ transform(code, id) {
8056
+ if (!id.includes("/templates/") || !id.endsWith(".mdx")) {
8057
+ return null;
8058
+ }
8059
+ logger4.debug(`Transform called for template: ${id}`);
8060
+ const match2 = id.match(/\/templates\/([^/]+)\.mdx$/);
8061
+ if (!match2) {
8062
+ logger4.debug(`No match found for template path pattern in: ${id}`);
8063
+ return null;
8064
+ }
8065
+ const templateName = match2[1];
8066
+ const sectionName = templateName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
8067
+ logger4.debug(`Template: ${templateName}, Section: ${sectionName}`);
8068
+ const configuredPath = sectionPathMap.get(sectionName.toLowerCase());
8069
+ if (!configuredPath) {
8070
+ logger4.debug(
8071
+ `No configured path found for section: ${sectionName.toLowerCase()}`
8072
+ );
8073
+ logger4.debug(
8074
+ `Available sections: ${Array.from(sectionPathMap.keys()).join(", ")}`
8075
+ );
8076
+ return null;
8077
+ }
8078
+ logger4.info(
8079
+ `Replacing Meta title in ${templateName}.mdx with path: ${configuredPath}`
8080
+ );
8081
+ const transformedCode = code.replace(
8082
+ /(<Meta\s+title=")[^"]*(")/,
8083
+ `$1${configuredPath}$2`
8084
+ );
8085
+ return { code: transformedCode };
8086
+ },
7947
8087
  vite: {
7948
8088
  handleHotUpdate({ file, server }) {
7949
8089
  if (isTwConfigPath(file) || isTwCssPath(file)) {
@@ -7956,7 +8096,7 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
7956
8096
  if (!assetManager) return;
7957
8097
  const matchingGroup = assetManager.findMatchingGroup(filePath);
7958
8098
  if (!matchingGroup) return;
7959
- logger3.info(`Asset changed in group ${matchingGroup}: ${filePath}`);
8099
+ logger4.info(`Asset changed in group ${matchingGroup}: ${filePath}`);
7960
8100
  assetManager.invalidateGroup(matchingGroup);
7961
8101
  const groupModule = server2.moduleGraph.getModuleById(
7962
8102
  ASSET_GROUP_ID_PREFIX + matchingGroup
@@ -7974,10 +8114,10 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
7974
8114
  var { vite } = unplugin;
7975
8115
 
7976
8116
  // src/addon/preset.ts
7977
- var logger4 = new Logger("Preset");
8117
+ var logger5 = new Logger("Preset");
7978
8118
  function createAddonOptions(options) {
7979
8119
  if (!options.tailwindConfig) {
7980
- logger4.error("tailwindConfig missing from options:", options);
8120
+ logger5.error("tailwindConfig missing from options:", options);
7981
8121
  throw new Error(
7982
8122
  'tailwindConfig option is required. Please specify the path to your Tailwind config file. Example: { tailwindConfig: "../tailwind.config.js" }'
7983
8123
  );
@@ -8039,14 +8179,14 @@ var staticDirs = async (existingStaticDirs, options) => {
8039
8179
  }
8040
8180
  });
8041
8181
  if (newStaticDirs.length > 0) {
8042
- logger4.info("Registering asset directories as staticDirs:", {
8182
+ logger5.debug("Registering asset directories as staticDirs:", {
8043
8183
  staticDirs: newStaticDirs
8044
8184
  });
8045
8185
  return [...existingStaticDirs, ...newStaticDirs];
8046
8186
  }
8047
8187
  return existingStaticDirs;
8048
8188
  } catch (error) {
8049
- logger4.error("Failed to configure static directories", error);
8189
+ logger5.error("Failed to configure static directories", error);
8050
8190
  return existingStaticDirs;
8051
8191
  }
8052
8192
  };
@@ -8054,18 +8194,12 @@ var stories = async (entry = [], options) => {
8054
8194
  try {
8055
8195
  const addonOptions = createAddonOptions(options);
8056
8196
  const newStories = [];
8057
- if (addonOptions.forceSingleDoc) {
8058
- const templatePath = resolveTemplate(
8059
- addonOptions.forceSingleDoc.name,
8060
- addonOptions
8061
- );
8062
- newStories.push(templatePath);
8063
- } else {
8064
- addonOptions.sections.forEach((section) => {
8065
- const templatePath = resolveTemplate(section.name, addonOptions);
8066
- newStories.push(templatePath);
8067
- });
8068
- }
8197
+ const sectionStories = generateSectionStories({
8198
+ configDir: options.configDir,
8199
+ sections: addonOptions.forceSingleDoc ? [addonOptions.forceSingleDoc] : addonOptions.sections,
8200
+ addonOptions
8201
+ });
8202
+ newStories.push(...sectionStories);
8069
8203
  const assetStories = generateAssetStories({
8070
8204
  configDir: options.configDir,
8071
8205
  assets: options.assets,
@@ -8074,7 +8208,7 @@ var stories = async (entry = [], options) => {
8074
8208
  newStories.push(...assetStories);
8075
8209
  return [...entry, ...newStories];
8076
8210
  } catch (error) {
8077
- logger4.error("Failed to inject config into stories", error);
8211
+ logger5.error("Failed to inject config into stories", error);
8078
8212
  return entry;
8079
8213
  }
8080
8214
  };