vitepress-allyouneed 0.3.0-beta.1 → 0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
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.0] - 2026-05-20
6
+
7
+ 正式版。汇集 v0.3 全部新功能(Obsidian 语法 6 模块、sidebar 自动生成全套、DocHeader banner、i18n 集成、`_sidebar.md` 覆盖等),并修两个 deploy 关键 bug。
8
+
9
+ ### Fixed(0.3.0-beta.0 → 0.3.0)
10
+ - **build-mode base 双重 prefix → 404**:`entry.url` 之前**包含 base**(`/<base>/foo`),VitePress render 时**再** prepend base → `/<base>/<base>/foo` → GitHub Pages 等子路径部署全部 404。现 `computeUrl` 始终输出**不带 base 的 site-root 相对 URL**(`/foo`),VitePress 统一 prepend。影响 wikilink `<a href>`、sidebar/nav link、per-folder Record key、`_perspectives_/` fallback 等所有内部 URL。
11
+ - **i18n nav 注入丢失**:VitePress i18n 下 `themeConfig.locales[lang].themeConfig.nav` 覆盖顶层 nav,Perspectives 下拉在 EN locale 消失。wrapper 现在给**所有 locale 的 nav** 都注入。
12
+ - **跨 locale nav 链接 404**:EN locale 写 `link: '/test/'` 被解释为 locale-relative `/en/test/`。example 配置已修正(EN nav 只列已翻译 page)。
13
+ - **Perspectives 视图页 sidebar 显示扁平 fallback 列表**(用户反馈不够有用)→ 视图页自动 frontmatter `sidebar: false`,只剩中间 graph/stats/tags 组件全屏展示。
14
+
15
+ ### Added(0.3.0-beta.0 → 0.3.0)
16
+ - 11 篇 EN 翻译文档(`en/guide/{overview, docs×6, advanced×4}`)
17
+ - VitePress 原生 i18n 集成:wrapper 自动识别 `themeConfig.locales`,给每个 non-root locale 用 `includePrefix` 生成独立 sidebar
18
+ - `sidebarAuto.includePrefix` / `excludePrefixes` 公开选项
19
+
5
20
  ## [0.3.0-beta.1] - 2026-05-20
6
21
 
7
22
  ### Fixed
package/dist/index.cjs CHANGED
@@ -570,7 +570,7 @@ function computeUrl(rel, options) {
570
570
  const pathPart = isIndex ? noExt.replace(/(^|\/)(index|README)$/i, "$1") : noExt;
571
571
  const segments = pathPart.split("/").filter(Boolean);
572
572
  if (segments.length === 0) {
573
- return options.base;
573
+ return "/";
574
574
  }
575
575
  const last = segments[segments.length - 1];
576
576
  if (!isIndex) {
@@ -578,7 +578,7 @@ function computeUrl(rel, options) {
578
578
  } else if (!options.cleanUrls) {
579
579
  segments.push("index.html");
580
580
  }
581
- return buildUrl(options.base, segments);
581
+ return buildUrl("/", segments);
582
582
  }
583
583
  function pushToArrayMap(m, k, v) {
584
584
  const arr = m.get(k);
@@ -2067,6 +2067,7 @@ function renderTemplate(v) {
2067
2067
  "---",
2068
2068
  `title: ${v.title}`,
2069
2069
  "layout: doc",
2070
+ "sidebar: false",
2070
2071
  "aside: false",
2071
2072
  "outline: false",
2072
2073
  "---",
@@ -2426,12 +2427,15 @@ function injectViewsSidebar(sidebar, options) {
2426
2427
  }
2427
2428
  }
2428
2429
  }
2429
- const base = options.base.endsWith("/") ? options.base : options.base + "/";
2430
2430
  const prefix = options.views.urlPrefix ? options.views.urlPrefix.replace(/^\/+|\/+$/g, "") : "";
2431
2431
  if (prefix) {
2432
- const persPath = `${base}${prefix}/`;
2432
+ const persPath = `/${prefix}/`;
2433
2433
  if (!sidebar[persPath]) {
2434
- sidebar[persPath] = buildPerspectivesFallbackSidebar(sidebar, group, base);
2434
+ sidebar[persPath] = buildPerspectivesFallbackSidebar(
2435
+ sidebar,
2436
+ group,
2437
+ options.base.endsWith("/") ? options.base : options.base + "/"
2438
+ );
2435
2439
  }
2436
2440
  }
2437
2441
  return sidebar;
@@ -2439,40 +2443,32 @@ function injectViewsSidebar(sidebar, options) {
2439
2443
  return [group];
2440
2444
  }
2441
2445
  function buildPerspectivesFallbackSidebar(allSidebars, group, base) {
2442
- const out = [{ text: "Home", link: base }];
2446
+ const out = [{ text: "Home", link: "/" }];
2443
2447
  const topPaths = Object.keys(allSidebars).filter(
2444
2448
  (p) => p !== base && !p.endsWith("/_perspectives_/")
2445
2449
  );
2446
2450
  for (const p of topPaths) {
2447
2451
  const seg = p.replace(/^\/|\/$/g, "").split("/").filter(Boolean).pop() ?? p;
2448
2452
  const text = seg.charAt(0).toUpperCase() + seg.slice(1);
2449
- out.push({ text, link: p });
2453
+ const b = base.endsWith("/") ? base : base + "/";
2454
+ const stripped = b !== "/" && p.startsWith(b) ? "/" + p.slice(b.length) : p;
2455
+ out.push({ text, link: stripped });
2450
2456
  }
2451
2457
  out.push(group);
2452
2458
  return out;
2453
2459
  }
2454
2460
  function buildViewsGroup(options) {
2455
2461
  const { enabled, names, sidebarText, urlPrefix } = options.views;
2456
- const base = options.base.endsWith("/") ? options.base.slice(0, -1) : options.base;
2457
2462
  const prefixSeg = urlPrefix ? `/${urlPrefix}` : "";
2458
2463
  const items = [];
2459
2464
  if (enabled.graph) {
2460
- items.push({
2461
- text: sidebarText.graph,
2462
- link: `${base}${prefixSeg}/${names.graph}`
2463
- });
2465
+ items.push({ text: sidebarText.graph, link: `${prefixSeg}/${names.graph}` });
2464
2466
  }
2465
2467
  if (enabled.stats) {
2466
- items.push({
2467
- text: sidebarText.stats,
2468
- link: `${base}${prefixSeg}/${names.stats}`
2469
- });
2468
+ items.push({ text: sidebarText.stats, link: `${prefixSeg}/${names.stats}` });
2470
2469
  }
2471
2470
  if (enabled.tags) {
2472
- items.push({
2473
- text: sidebarText.tags,
2474
- link: `${base}${prefixSeg}/${names.tags}`
2475
- });
2471
+ items.push({ text: sidebarText.tags, link: `${prefixSeg}/${names.tags}` });
2476
2472
  }
2477
2473
  if (items.length === 0) return null;
2478
2474
  return {
@@ -2698,13 +2694,34 @@ function generateSidebar(index, options, autoOptions = {}) {
2698
2694
  }
2699
2695
  const root = buildTree2(visible);
2700
2696
  const layout = autoOptions.layout ?? "tree";
2697
+ let result;
2701
2698
  if (layout === "per-folder") {
2702
- return toPerFolderSidebar(root, opts, options, index);
2699
+ result = toPerFolderSidebar(root, opts, options, index);
2700
+ } else if (layout === "flat") {
2701
+ result = toFlatSidebar(root, opts);
2702
+ } else {
2703
+ result = toTreeSidebar(root, opts, index, options);
2703
2704
  }
2704
- if (layout === "flat") {
2705
- return toFlatSidebar(root, opts);
2705
+ stripBaseFromConfig(result, options.base);
2706
+ return result;
2707
+ }
2708
+ function stripBaseFromConfig(cfg, base) {
2709
+ if (Array.isArray(cfg)) {
2710
+ stripBaseFromItems(cfg, base);
2711
+ } else {
2712
+ for (const k of Object.keys(cfg)) {
2713
+ stripBaseFromItems(cfg[k], base);
2714
+ }
2715
+ }
2716
+ }
2717
+ function stripBaseFromItems(items, base) {
2718
+ const b = base.endsWith("/") ? base : base + "/";
2719
+ for (const it of items) {
2720
+ if (it.link && b !== "/" && it.link.startsWith(b)) {
2721
+ it.link = "/" + it.link.slice(b.length);
2722
+ }
2723
+ if (it.items) stripBaseFromItems(it.items, base);
2706
2724
  }
2707
- return toTreeSidebar(root, opts, index, options);
2708
2725
  }
2709
2726
  function buildTree2(files) {
2710
2727
  const root = newNode("");
@@ -2905,7 +2922,6 @@ function walkDirs(node, out) {
2905
2922
  }
2906
2923
  function toPerFolderSidebar(root, opts, options, index) {
2907
2924
  const out = {};
2908
- const base = options.base.endsWith("/") ? options.base : options.base + "/";
2909
2925
  const rootItems = [];
2910
2926
  const sortedRootFiles = [...root.files].sort((a, b) => compareEntries(a, b, opts));
2911
2927
  for (const f of sortedRootFiles) {
@@ -2923,13 +2939,13 @@ function toPerFolderSidebar(root, opts, options, index) {
2923
2939
  /* isTopLevel */
2924
2940
  true
2925
2941
  )) {
2926
- const firstUrl = child.dirIndex && !child.dirIndexEmpty ? child.dirIndex.url : findFirstPageUrl(child, opts) ?? `${base}${key}/`;
2942
+ const firstUrl = child.dirIndex && !child.dirIndexEmpty ? child.dirIndex.url : findFirstPageUrl(child, opts) ?? `/${key}/`;
2927
2943
  rootItems.push({ text: labelText, link: firstUrl });
2928
2944
  } else {
2929
2945
  rootItems.push({ text: labelText });
2930
2946
  }
2931
2947
  }
2932
- if (rootItems.length > 0) out[base] = rootItems;
2948
+ if (rootItems.length > 0) out["/"] = rootItems;
2933
2949
  for (const key of topKeys) {
2934
2950
  const child = root.children.get(key);
2935
2951
  const items = renderNode(
@@ -2956,7 +2972,7 @@ function toPerFolderSidebar(root, opts, options, index) {
2956
2972
  });
2957
2973
  }
2958
2974
  sidebar.push(...items);
2959
- out[`${base}${key}/`] = sidebar;
2975
+ out[`/${key}/`] = sidebar;
2960
2976
  }
2961
2977
  return out;
2962
2978
  }
@@ -2970,7 +2986,7 @@ function generateNav(index, options, autoOptions = {}) {
2970
2986
  }
2971
2987
  const root = buildTree2(visible);
2972
2988
  const base = options.base.endsWith("/") ? options.base : options.base + "/";
2973
- const out = [{ text: opts.homeNavText, link: base }];
2989
+ const out = [{ text: opts.homeNavText, link: "/" }];
2974
2990
  const topKeys = [...root.children.keys()].sort();
2975
2991
  for (const key of topKeys) {
2976
2992
  const child = root.children.get(key);
@@ -2978,16 +2994,22 @@ function generateNav(index, options, autoOptions = {}) {
2978
2994
  continue;
2979
2995
  }
2980
2996
  const text = computeGroupText(child.path, child.dirIndex, opts);
2981
- const link = child.dirIndex?.url ?? `${base}${key}/`;
2982
- const escapedPrefix = `${base}${key}/`.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2983
- out.push({
2984
- text,
2985
- link,
2986
- activeMatch: "^" + escapedPrefix
2987
- });
2997
+ let link;
2998
+ if (child.dirIndex) {
2999
+ link = stripBase(child.dirIndex.url, base);
3000
+ } else {
3001
+ link = `/${key}/`;
3002
+ }
3003
+ const escapedPrefix = `/${key}/`.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3004
+ out.push({ text, link, activeMatch: "^" + escapedPrefix });
2988
3005
  }
2989
3006
  return out;
2990
3007
  }
3008
+ function stripBase(url, base) {
3009
+ const b = base.endsWith("/") ? base : base + "/";
3010
+ if (b === "/" || !url.startsWith(b)) return url;
3011
+ return "/" + url.slice(b.length);
3012
+ }
2991
3013
  function compareEntries(a, b, opts) {
2992
3014
  if (opts.sortBy === "title") {
2993
3015
  return opts.formatItemTitle(a).localeCompare(opts.formatItemTitle(b));