vitepress-allyouneed 0.3.1 → 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 +13 -0
- package/dist/index.cjs +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/dist/markdown-it.d.cts +1 -1
- package/dist/markdown-it.d.ts +1 -1
- package/dist/{types-Nx7d15xb.d.cts → types-BLbN9Pg6.d.cts} +9 -0
- package/dist/{types-Nx7d15xb.d.ts → types-BLbN9Pg6.d.ts} +9 -0
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vitepress.cjs +17 -12
- package/dist/vitepress.cjs.map +1 -1
- package/dist/vitepress.d.cts +1 -1
- package/dist/vitepress.d.ts +1 -1
- package/dist/vitepress.js +17 -12
- package/dist/vitepress.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
2805
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2832
|
+
folderItems.push(group);
|
|
2830
2833
|
}
|
|
2831
|
-
|
|
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;
|
|
@@ -3103,10 +3109,9 @@ function generateFolderIndexes(options, folderOpts = {}) {
|
|
|
3103
3109
|
const strip = folderOpts.stripNumericPrefix ?? true;
|
|
3104
3110
|
const exclude = folderOpts.exclude ?? [];
|
|
3105
3111
|
const template = folderOpts.template ?? defaultTemplate;
|
|
3106
|
-
const dirsToProcess = collectDirs(srcDir, srcDir, viewsPrefix, exclude, mode);
|
|
3112
|
+
const dirsToProcess = [srcDir, ...collectDirs(srcDir, srcDir, viewsPrefix, exclude, mode)];
|
|
3107
3113
|
for (const dirAbs of dirsToProcess) {
|
|
3108
3114
|
const dirRel = import_node_path9.default.relative(srcDir, dirAbs).split(import_node_path9.default.sep).join("/");
|
|
3109
|
-
if (dirRel === "") continue;
|
|
3110
3115
|
const entries = safeReaddir(dirAbs);
|
|
3111
3116
|
if (entries.length === 0) continue;
|
|
3112
3117
|
const dirName = import_node_path9.default.basename(dirAbs).toLowerCase();
|
|
@@ -3169,11 +3174,11 @@ function generateFolderIndexes(options, folderOpts = {}) {
|
|
|
3169
3174
|
}
|
|
3170
3175
|
files.sort((a, b) => a.title.localeCompare(b.title));
|
|
3171
3176
|
subDirs.sort((a, b) => a.title.localeCompare(b.title));
|
|
3172
|
-
const lastSeg = dirRel.split("/").pop() ?? "";
|
|
3177
|
+
const lastSeg = dirRel === "" ? import_node_path9.default.basename(srcDir) : dirRel.split("/").pop() ?? "";
|
|
3173
3178
|
const ctx = {
|
|
3174
3179
|
dirAbsPath: dirAbs,
|
|
3175
3180
|
dirRelPath: dirRel,
|
|
3176
|
-
title: humanize2(lastSeg, strip),
|
|
3181
|
+
title: humanize2(lastSeg, strip) || "Home",
|
|
3177
3182
|
files,
|
|
3178
3183
|
subDirs
|
|
3179
3184
|
};
|