@c4a/context-cli 0.7.62 → 0.7.63

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/cli.js CHANGED
@@ -32174,6 +32174,7 @@ var init_packageSite = __esm(() => {
32174
32174
  packageSiteNavLinkSchema = exports_external.object({
32175
32175
  text: exports_external.string().trim().min(1),
32176
32176
  link: siteHrefSchema,
32177
+ position: exports_external.enum(["start", "end"]).optional(),
32177
32178
  locales: localizedTextSchema.optional()
32178
32179
  }).strict();
32179
32180
  packageSiteMoreItemSchema = exports_external.object({
@@ -87601,6 +87602,17 @@ var init_packageSiteTheme = __esm(() => {
87601
87602
  return true;
87602
87603
  }, { alt: ['paragraph'] });
87603
87604
  md.renderer.rules.context_anchor = (tokens, index) => '<a id="' + md.utils.escapeHtml(tokens[index].content) + '"></a>\n';
87605
+ // Only the compiler writes section landing pages; accept exactly its card wrappers there.
87606
+ const sectionWrappers = new Set(['<div class="context-section-grid">', '<div class="context-section-card">', '</div>']);
87607
+ md.block.ruler.before('paragraph', 'context_section_card', (state, line, end, silent) => {
87608
+ if (!/(?:^|\/)sections\/[0-9a-f]+\.md$/.test(state.env.relativePath || '')) return false;
87609
+ const raw = state.src.slice(state.bMarks[line] + state.tShift[line], state.eMarks[line]);
87610
+ if (!sectionWrappers.has(raw)) return false;
87611
+ if (!silent) { const token = state.push('context_section_card', '', 0); token.content = raw; }
87612
+ state.line = line + 1;
87613
+ return true;
87614
+ }, { alt: ['paragraph'] });
87615
+ md.renderer.rules.context_section_card = (tokens, index) => tokens[index].content + '\n';
87604
87616
  // The generated website config declares contextLocaleMarker; null when the site has no translations.
87605
87617
  const contextLocale = typeof contextLocaleMarker === 'string' ? contextLocaleMarker : null;
87606
87618
  md.block.ruler.before('paragraph', 'context_locale', (state, line, end, silent) => {
@@ -87827,10 +87839,13 @@ export default {
87827
87839
  return part('year') + '-' + part('month') + '-' + part('day') + ' ' +
87828
87840
  part('hour') + ':' + part('minute') + ':' + part('second') + ' ' + part('timeZoneName');
87829
87841
  });
87842
+ const sitePath = () => {
87843
+ const base = data.site.value.base;
87844
+ return route.path.startsWith(base) ? '/' + route.path.slice(base.length) : route.path;
87845
+ };
87830
87846
  watch(() => route.path, () => {
87831
87847
  allSources.value = false;
87832
- const base = data.site.value.base;
87833
- const path = route.path.startsWith(base) ? '/' + route.path.slice(base.length) : route.path;
87848
+ const path = sitePath();
87834
87849
  const direct = sections.value.find(section => section.href === path);
87835
87850
  const current = sections.value.find(section => section.key === selected.value);
87836
87851
  selected.value = (direct || (current?.pages.includes(path) ? current :
@@ -87840,6 +87855,12 @@ export default {
87840
87855
  const inLlms = computed(() => route.path.startsWith(data.site.value.base + 'llms/'));
87841
87856
  const inHistory = computed(() => route.path === data.site.value.base + 'changelog.html');
87842
87857
  const inHome = computed(() => data.frontmatter.value.layout === 'home');
87858
+ // Articles outside the knowledge map, such as More menu targets, belong to no section.
87859
+ const inMore = computed(() => (data.theme.value.contextMore || []).some(item => !item.origin && item.link === sitePath()));
87860
+ const outsideSections = computed(() => inLlms.value || inHistory.value || inMore.value || (!inHome.value &&
87861
+ !sections.value.some(section => section.href === sitePath() || section.pages.includes(sitePath()))));
87862
+ const userNav = position => (data.theme.value.contextNav || [])
87863
+ .filter(item => (item.position === 'start') === (position === 'start')).map(navLink);
87843
87864
  // Descendants, including site extensions, read the reader language as lang.
87844
87865
  // The frontmatter carries it too so the content refreshes its outline on a switch.
87845
87866
  provide(dataSymbol, { ...data, lang: computed(() => locale.value), frontmatter: computed(() => {
@@ -87848,15 +87869,15 @@ export default {
87848
87869
  return { ...value, contextLocale: locale.value, ...(actions ? { hero: { ...value.hero, actions } } : {}) };
87849
87870
  }), theme: computed(() => ({ ...data.theme.value,
87850
87871
  ...data.theme.value.contextUiLabels?.[chinese.value ? 'zh' : 'en'],
87851
- sidebar: inLlms.value || inHistory.value ? [] : active.value?.items || [],
87852
- nav: [...sections.value.map(section => ({ text: section.label, link: section.href,
87853
- activeMatch: !inLlms.value && !inHistory.value && section.key === selected.value ? '^' : '(?!)' })),
87854
- ...(data.theme.value.contextNav || []).map(navLink),
87872
+ sidebar: outsideSections.value ? [] : active.value?.items || [],
87873
+ nav: [...userNav('start'), ...sections.value.map(section => ({ text: section.label, link: section.href,
87874
+ activeMatch: !outsideSections.value && section.key === selected.value ? '^' : '(?!)' })),
87875
+ ...userNav('end'),
87855
87876
  { text: bothHtml('更多', 'More'), items: [
87856
87877
  ...(data.theme.value.contextMore || []).map(navLink),
87857
87878
  { text: 'LLM Docs', link: '/llms/index.html' },
87858
87879
  { text: 'Changelog', link: '/changelog.html' }],
87859
- activeMatch: inLlms.value || inHistory.value ? '^' : '(?!)' }],
87880
+ activeMatch: inLlms.value || inHistory.value || inMore.value ? '^' : '(?!)' }],
87860
87881
  })) });
87861
87882
  const slots = {
87862
87883
  'nav-bar-title-before': () => extensions.brand ? h('span', { class: 'context-brand' }, custom('brand')) : null,
@@ -87924,7 +87945,7 @@ export default {
87924
87945
  };
87925
87946
  // History belongs between the page heading and footer metadata.
87926
87947
  return () => h(DefaultTheme.Layout, { class: inHome.value ? 'context-home' : data.page.value.isNotFound ? 'context-missing' :
87927
- inLlms.value || inHistory.value ? 'context-empty-sidebar' : undefined }, { ...slots, 'doc-after': undefined,
87948
+ outsideSections.value ? 'context-empty-sidebar' : undefined }, { ...slots, 'doc-after': undefined,
87928
87949
  'doc-footer-before': () => [slots['doc-after'](), slots['doc-footer-before']()] });
87929
87950
  }
87930
87951
  },
@@ -88203,6 +88224,19 @@ ${readerContentStyles(".vp-doc")}
88203
88224
  .context-sources li + li { margin-top: 6px; }
88204
88225
  .context-sources a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
88205
88226
  .context-sources a:hover { color: var(--vp-c-brand-1); border-color: currentColor; }
88227
+ /* Section landing pages: two cards per row, one on narrow screens. */
88228
+ .context-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
88229
+ .vp-doc .context-section-card { min-width: 0; padding: 18px 20px; border: 1px solid var(--vp-c-divider); border-radius: 12px;
88230
+ background: color-mix(in srgb, var(--vp-c-bg) 88%, var(--vp-c-bg-soft)); }
88231
+ .vp-doc .context-section-card:hover { border-color: color-mix(in srgb, var(--vp-c-brand-1) 42%, var(--vp-c-divider)); }
88232
+ .vp-doc .context-section-card h2 { margin: 0 0 10px; padding: 0 0 10px; border-top: 0; border-bottom: 1px solid var(--vp-c-divider); font-size: 17px; line-height: 1.45; letter-spacing: 0; }
88233
+ .vp-doc .context-section-card h2 a { color: var(--vp-c-text-1); text-decoration: none; }
88234
+ .vp-doc .context-section-card > ul { margin: 0; padding: 0; list-style: none; }
88235
+ .vp-doc .context-section-card li { margin: 6px 0; font-size: 14px; line-height: 1.55; }
88236
+ .vp-doc .context-section-card li a { color: var(--vp-c-text-2); text-decoration: none; }
88237
+ .vp-doc .context-section-card li a:hover { color: var(--vp-c-brand-1); }
88238
+ .vp-doc .context-section-card ul ul { margin: 4px 0 8px; padding-left: 14px; border-left: 1px solid var(--vp-c-divider); list-style: none; }
88239
+ @media (max-width: 719px) { .context-section-grid { grid-template-columns: 1fr; } }
88206
88240
  ${DIAGRAM_STYLES}
88207
88241
  `;
88208
88242
  });
@@ -89647,6 +89681,7 @@ function siteNavigationConfig(site, pages) {
89647
89681
  text: item.text,
89648
89682
  link: item.link,
89649
89683
  ...item.link.startsWith("/") ? { origin: true } : {},
89684
+ ...item.position === "start" ? { position: "start" } : {},
89650
89685
  ...item.locales ? { locales: item.locales } : {}
89651
89686
  }));
89652
89687
  return { nav, more };
@@ -90117,11 +90152,28 @@ ${localized.body}`);
90117
90152
  lines.push(`${" ".repeat(level)}- ${entry.href ? `[${title}](${entry.href})` : title}`);
90118
90153
  menu(lines, entry.children, level + 1, tag);
90119
90154
  });
90155
+ const card = (lines, heading, entries2, tag) => {
90156
+ lines.push('<div class="context-section-card">', "");
90157
+ if (heading !== undefined)
90158
+ lines.push(`## ${heading}`, "");
90159
+ menu(lines, entries2, 0, tag);
90160
+ lines.push("", "</div>", "");
90161
+ };
90120
90162
  await mkdir28(join75(temporary, "sections"), { recursive: true });
90121
90163
  for (const section of sections) {
90122
90164
  await writeFile23(join75(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
90123
- const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, ""];
90124
- menu(lines, section.entries, 0, tag);
90165
+ const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90166
+ const groups = section.entries.filter((entry) => entry.children.length > 0);
90167
+ const articles = section.entries.filter((entry) => entry.children.length === 0);
90168
+ for (const group of groups) {
90169
+ card(lines, group.href ? `[${mdLabel(localizer.entryTitle(tag, group))}](${group.href})` : mdLabel(localizer.entryTitle(tag, group)), group.children, tag);
90170
+ }
90171
+ if (groups.length === 0)
90172
+ for (const article of articles)
90173
+ card(lines, undefined, [article], tag);
90174
+ else if (articles.length)
90175
+ card(lines, undefined, articles, tag);
90176
+ lines.push("</div>");
90125
90177
  return lines.join(`
90126
90178
  `) + `
90127
90179
  `;