@c4a/context-cli 0.7.62 → 0.7.64

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) => {
@@ -87738,8 +87750,11 @@ export default {
87738
87750
  tags.map(tag => h('span', { 'data-context-locales': tag, lang: next(tag) }, shortLabel(next(tag))))),
87739
87751
  ]);
87740
87752
  };
87753
+ // Origin links become absolute URLs, which VitePress never marks active.
87741
87754
  const navLink = item => ({ text: item.text,
87742
- ...(item.origin ? { link: mounted.value ? window.location.origin + item.link : item.link, target: '_self', noIcon: true } : { link: item.link }) });
87755
+ ...(item.origin ? { link: mounted.value ? window.location.origin + item.link : item.link, target: '_self', noIcon: true,
87756
+ activeMatch: [item.link, item.link + 'index.html'].includes(route.path) ||
87757
+ (inHome.value && item.link === data.site.value.base) ? '^' : '(?!)' } : { link: item.link }) });
87743
87758
  const href = value => value.startsWith('/') ? data.site.value.base + value.slice(1) : value;
87744
87759
  const external = value => /^https?:\/\//.test(value) || value.startsWith('mailto:');
87745
87760
  const copyCommand = async value => {
@@ -87827,10 +87842,13 @@ export default {
87827
87842
  return part('year') + '-' + part('month') + '-' + part('day') + ' ' +
87828
87843
  part('hour') + ':' + part('minute') + ':' + part('second') + ' ' + part('timeZoneName');
87829
87844
  });
87845
+ const sitePath = () => {
87846
+ const base = data.site.value.base;
87847
+ return route.path.startsWith(base) ? '/' + route.path.slice(base.length) : route.path;
87848
+ };
87830
87849
  watch(() => route.path, () => {
87831
87850
  allSources.value = false;
87832
- const base = data.site.value.base;
87833
- const path = route.path.startsWith(base) ? '/' + route.path.slice(base.length) : route.path;
87851
+ const path = sitePath();
87834
87852
  const direct = sections.value.find(section => section.href === path);
87835
87853
  const current = sections.value.find(section => section.key === selected.value);
87836
87854
  selected.value = (direct || (current?.pages.includes(path) ? current :
@@ -87840,6 +87858,12 @@ export default {
87840
87858
  const inLlms = computed(() => route.path.startsWith(data.site.value.base + 'llms/'));
87841
87859
  const inHistory = computed(() => route.path === data.site.value.base + 'changelog.html');
87842
87860
  const inHome = computed(() => data.frontmatter.value.layout === 'home');
87861
+ // Articles outside the knowledge map, such as More menu targets, belong to no section.
87862
+ const inMore = computed(() => (data.theme.value.contextMore || []).some(item => !item.origin && item.link === sitePath()));
87863
+ const outsideSections = computed(() => inLlms.value || inHistory.value || inMore.value || (!inHome.value &&
87864
+ !sections.value.some(section => section.href === sitePath() || section.pages.includes(sitePath()))));
87865
+ const userNav = position => (data.theme.value.contextNav || [])
87866
+ .filter(item => (item.position === 'start') === (position === 'start')).map(navLink);
87843
87867
  // Descendants, including site extensions, read the reader language as lang.
87844
87868
  // The frontmatter carries it too so the content refreshes its outline on a switch.
87845
87869
  provide(dataSymbol, { ...data, lang: computed(() => locale.value), frontmatter: computed(() => {
@@ -87848,15 +87872,15 @@ export default {
87848
87872
  return { ...value, contextLocale: locale.value, ...(actions ? { hero: { ...value.hero, actions } } : {}) };
87849
87873
  }), theme: computed(() => ({ ...data.theme.value,
87850
87874
  ...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),
87875
+ sidebar: outsideSections.value ? [] : active.value?.items || [],
87876
+ nav: [...userNav('start'), ...sections.value.map(section => ({ text: section.label, link: section.href,
87877
+ activeMatch: !inHome.value && !outsideSections.value && section.key === selected.value ? '^' : '(?!)' })),
87878
+ ...userNav('end'),
87855
87879
  { text: bothHtml('更多', 'More'), items: [
87856
87880
  ...(data.theme.value.contextMore || []).map(navLink),
87857
87881
  { text: 'LLM Docs', link: '/llms/index.html' },
87858
87882
  { text: 'Changelog', link: '/changelog.html' }],
87859
- activeMatch: inLlms.value || inHistory.value ? '^' : '(?!)' }],
87883
+ activeMatch: inLlms.value || inHistory.value || inMore.value ? '^' : '(?!)' }],
87860
87884
  })) });
87861
87885
  const slots = {
87862
87886
  'nav-bar-title-before': () => extensions.brand ? h('span', { class: 'context-brand' }, custom('brand')) : null,
@@ -87924,7 +87948,7 @@ export default {
87924
87948
  };
87925
87949
  // History belongs between the page heading and footer metadata.
87926
87950
  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,
87951
+ outsideSections.value ? 'context-empty-sidebar' : undefined }, { ...slots, 'doc-after': undefined,
87928
87952
  'doc-footer-before': () => [slots['doc-after'](), slots['doc-footer-before']()] });
87929
87953
  }
87930
87954
  },
@@ -87948,14 +87972,20 @@ export default {
87948
87972
  `;
87949
87973
  siteThemeCss = `
87950
87974
  .context-business-floating { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100vw - 40px); }
87951
- .context-history-cards { display: grid; gap: 16px; margin: 24px 0; }
87952
- .context-history-card { border: 1px solid var(--vp-c-divider); border-radius: 12px; background: var(--vp-c-bg-soft); }
87953
- .context-history-card summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 20px; cursor: pointer; }
87975
+ .context-history-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 24px 0; }
87976
+ .context-history-card { min-width: 0; border: 1px solid var(--vp-c-divider); border-radius: 12px; background: var(--vp-c-bg-soft); }
87977
+ .context-history-card summary { display: flex; align-items: baseline; gap: 12px; padding: 20px; cursor: pointer; }
87954
87978
  .context-history-card summary::before { content: '▸'; }
87955
87979
  .context-history-card[open] summary::before { content: '▾'; }
87956
87980
  .context-history-card summary strong { color: var(--vp-c-brand-1); font-size: 13px; }
87957
- .context-history-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
87958
- .context-history-attribution { margin-left: auto; font-size: 13px; color: var(--vp-c-text-2); }
87981
+ .context-history-card summary strong, .context-history-card summary::before { flex-shrink: 0; }
87982
+ .context-history-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
87983
+ .context-history-card[open] .context-history-title { white-space: normal; overflow-wrap: anywhere; }
87984
+ .context-history-attribution { flex-shrink: 0; margin-left: auto; font-size: 13px; color: var(--vp-c-text-2); white-space: nowrap; }
87985
+ @media (max-width: 639px) {
87986
+ .context-history-card summary { flex-wrap: wrap; }
87987
+ .context-history-attribution { flex-basis: 100%; text-align: right; }
87988
+ }
87959
87989
  .context-history-body { padding: 0 24px 20px; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
87960
87990
  .context-history-body ul { list-style: disc; padding-left: 20px; }
87961
87991
  .context-history-meta { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--vp-c-divider); color: var(--vp-c-text-2); }
@@ -88203,6 +88233,19 @@ ${readerContentStyles(".vp-doc")}
88203
88233
  .context-sources li + li { margin-top: 6px; }
88204
88234
  .context-sources a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
88205
88235
  .context-sources a:hover { color: var(--vp-c-brand-1); border-color: currentColor; }
88236
+ /* Section landing pages: two cards per row, one on narrow screens. */
88237
+ .context-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
88238
+ .vp-doc .context-section-card { min-width: 0; padding: 18px 20px; border: 1px solid var(--vp-c-divider); border-radius: 12px;
88239
+ background: color-mix(in srgb, var(--vp-c-bg) 88%, var(--vp-c-bg-soft)); }
88240
+ .vp-doc .context-section-card:hover { border-color: color-mix(in srgb, var(--vp-c-brand-1) 42%, var(--vp-c-divider)); }
88241
+ .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; }
88242
+ .vp-doc .context-section-card h2 a { color: var(--vp-c-text-1); text-decoration: none; }
88243
+ .vp-doc .context-section-card > ul { margin: 0; padding: 0; list-style: none; }
88244
+ .vp-doc .context-section-card li { margin: 6px 0; font-size: 14px; line-height: 1.55; }
88245
+ .vp-doc .context-section-card li a { color: var(--vp-c-text-2); text-decoration: none; }
88246
+ .vp-doc .context-section-card li a:hover { color: var(--vp-c-brand-1); }
88247
+ .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; }
88248
+ @media (max-width: 719px) { .context-section-grid { grid-template-columns: 1fr; } }
88206
88249
  ${DIAGRAM_STYLES}
88207
88250
  `;
88208
88251
  });
@@ -89647,6 +89690,7 @@ function siteNavigationConfig(site, pages) {
89647
89690
  text: item.text,
89648
89691
  link: item.link,
89649
89692
  ...item.link.startsWith("/") ? { origin: true } : {},
89693
+ ...item.position === "start" ? { position: "start" } : {},
89650
89694
  ...item.locales ? { locales: item.locales } : {}
89651
89695
  }));
89652
89696
  return { nav, more };
@@ -89662,7 +89706,7 @@ function restoreOriginNavLinks(html, base, links) {
89662
89706
  const link = href === undefined ? undefined : prefixedHref.get(href);
89663
89707
  if (link === undefined)
89664
89708
  return tag;
89665
- return tag.replace(` href="${href}"`, ` href="${link}"`).replace(/\sclass="([^"]*)"/u, (_, classes) => ` class="${classes.split(/\s+/u).filter((name3) => name3 !== "active").join(" ")}"`);
89709
+ return tag.replace(` href="${href}"`, ` href="${link}"`);
89666
89710
  });
89667
89711
  }
89668
89712
  function translatedMarkdown(content3, from, pages, resources) {
@@ -90117,11 +90161,28 @@ ${localized.body}`);
90117
90161
  lines.push(`${" ".repeat(level)}- ${entry.href ? `[${title}](${entry.href})` : title}`);
90118
90162
  menu(lines, entry.children, level + 1, tag);
90119
90163
  });
90164
+ const card = (lines, heading, entries2, tag) => {
90165
+ lines.push('<div class="context-section-card">', "");
90166
+ if (heading !== undefined)
90167
+ lines.push(`## ${heading}`, "");
90168
+ menu(lines, entries2, 0, tag);
90169
+ lines.push("", "</div>", "");
90170
+ };
90120
90171
  await mkdir28(join75(temporary, "sections"), { recursive: true });
90121
90172
  for (const section of sections) {
90122
90173
  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);
90174
+ const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90175
+ const groups = section.entries.filter((entry) => entry.children.length > 0);
90176
+ const articles = section.entries.filter((entry) => entry.children.length === 0);
90177
+ for (const group of groups) {
90178
+ card(lines, group.href ? `[${mdLabel(localizer.entryTitle(tag, group))}](${group.href})` : mdLabel(localizer.entryTitle(tag, group)), group.children, tag);
90179
+ }
90180
+ if (groups.length === 0)
90181
+ for (const article of articles)
90182
+ card(lines, undefined, [article], tag);
90183
+ else if (articles.length)
90184
+ card(lines, undefined, articles, tag);
90185
+ lines.push("</div>");
90125
90186
  return lines.join(`
90126
90187
  `) + `
90127
90188
  `;