vitepress-allyouneed 0.3.2 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.3.3] - 2026-05-20
6
+
7
+ ### Added
8
+ - **`sidebarAuto.foldersFirst`** — 控制同一层级内"普通文件 vs 子目录 group"的相对位置。
9
+ - `false`(默认)`files → virtualGroups → folders`(老行为,兼容)
10
+ - `true` `folders → virtualGroups → files`(Finder / Obsidian 风格)
11
+ - 仅影响相对位置;段内排序仍由 `sortBy` / `orderKey` / `groupOrder` 决定。
12
+
13
+ ## [0.3.2] - 2026-05-20
14
+
15
+ ### Fixed
16
+ - **根目录无 `index.md` 时 404**:`autoFolderIndex: 'top-level' / 'all'` 模式之前只为 srcDir **下**的目录生成 index,根本身被漏。现在 `dirsToProcess` 把 srcDir 根也加进去,根索引页用 `srcDir` basename 当 H1(fallback `Home`)。
17
+
5
18
  ## [0.3.1] - 2026-05-20
6
19
 
7
20
  ### Fixed
package/dist/index.cjs CHANGED
@@ -2663,7 +2663,8 @@ function resolveSidebarAutoOptions(user = {}) {
2663
2663
  maxDepth: user.maxDepth,
2664
2664
  groupLink: user.groupLink ?? "all",
2665
2665
  includePrefix: user.includePrefix,
2666
- excludePrefixes: user.excludePrefixes ?? []
2666
+ excludePrefixes: user.excludePrefixes ?? [],
2667
+ foldersFirst: user.foldersFirst ?? false
2667
2668
  };
2668
2669
  }
2669
2670
  function defaultItemTitle(entry, strip) {
@@ -2787,7 +2788,6 @@ function renderNode(node, opts, depth, isRoot, index, options) {
2787
2788
  const override = parseSidebarOverride(node.sidebarOverride, index, options);
2788
2789
  if (override) return override;
2789
2790
  }
2790
- const out = [];
2791
2791
  const virtualGroups = /* @__PURE__ */ new Map();
2792
2792
  const normalFiles = [];
2793
2793
  for (const f of node.files) {
@@ -2801,18 +2801,21 @@ function renderNode(node, opts, depth, isRoot, index, options) {
2801
2801
  }
2802
2802
  }
2803
2803
  normalFiles.sort((a, b) => compareEntries(a, b, opts));
2804
- for (const f of normalFiles) {
2805
- out.push({ text: opts.formatItemTitle(f), link: f.url });
2806
- }
2804
+ const fileItems = normalFiles.map((f) => ({
2805
+ text: opts.formatItemTitle(f),
2806
+ link: f.url
2807
+ }));
2807
2808
  const virtualKeys = [...virtualGroups.keys()].sort();
2809
+ const virtualItems = [];
2808
2810
  for (const name of virtualKeys) {
2809
2811
  const items = virtualGroups.get(name).sort((a, b) => compareEntries(a, b, opts));
2810
- out.push({
2812
+ virtualItems.push({
2811
2813
  text: name,
2812
2814
  collapsed: opts.collapsed,
2813
2815
  items: items.map((f) => ({ text: opts.formatItemTitle(f), link: f.url }))
2814
2816
  });
2815
2817
  }
2818
+ const folderItems = [];
2816
2819
  const childKeys = sortChildKeys(node, opts, isRoot);
2817
2820
  for (const key of childKeys) {
2818
2821
  const child = node.children.get(key);
@@ -2826,9 +2829,12 @@ function renderNode(node, opts, depth, isRoot, index, options) {
2826
2829
  if (child.dirIndex && !child.dirIndexEmpty && shouldLinkGroup(opts, isRoot)) {
2827
2830
  group.link = child.dirIndex.url;
2828
2831
  }
2829
- out.push(group);
2832
+ folderItems.push(group);
2830
2833
  }
2831
- return out;
2834
+ if (opts.foldersFirst) {
2835
+ return [...folderItems, ...virtualItems, ...fileItems];
2836
+ }
2837
+ return [...fileItems, ...virtualItems, ...folderItems];
2832
2838
  }
2833
2839
  function findFirstPageUrl(node, opts) {
2834
2840
  if (node.dirIndex && !node.dirIndexEmpty) return node.dirIndex.url;