@c4a/context-cli 0.7.81 → 0.7.82

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
@@ -89769,18 +89769,11 @@ function sidebar(entries2, label2 = (entry) => entry.title) {
89769
89769
  }));
89770
89770
  }
89771
89771
  function siteSections(entries2) {
89772
- const directoriesFirst = (siblings) => {
89773
- const ordered = [
89774
- ...siblings.filter((entry) => entry.children.length > 0),
89775
- ...siblings.filter((entry) => entry.children.length === 0)
89776
- ];
89777
- return ordered.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) }));
89778
- };
89779
89772
  const pageLinks = (entry) => [
89780
89773
  ...entry.href ? [entry.href.split("#")[0]] : [],
89781
89774
  ...entry.children.flatMap(pageLinks)
89782
89775
  ];
89783
- return entries2.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) })).map((entry) => ({
89776
+ return entries2.map((entry) => ({
89784
89777
  key: entry.key,
89785
89778
  title: entry.title,
89786
89779
  entry,
@@ -90008,16 +90001,24 @@ ${localized.body}`);
90008
90001
  for (const section of sections) {
90009
90002
  await writeFile22(join72(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
90010
90003
  const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90011
- const groups = section.entries.filter((entry) => entry.children.length > 0);
90012
- const articles = section.entries.filter((entry) => entry.children.length === 0);
90013
- for (const group of groups) {
90014
- card(lines, group.href ? `[${mdLabel(localizer.entryTitle(tag, group))}](${group.href})` : mdLabel(localizer.entryTitle(tag, group)), group.children, tag);
90015
- }
90016
- if (groups.length === 0)
90017
- for (const article of articles)
90018
- card(lines, undefined, [article], tag);
90019
- else if (articles.length)
90020
- card(lines, undefined, articles, tag);
90004
+ const grouped = section.entries.some((entry) => entry.children.length > 0);
90005
+ let articles = [];
90006
+ const flush = () => {
90007
+ if (articles.length)
90008
+ card(lines, undefined, articles, tag);
90009
+ articles = [];
90010
+ };
90011
+ for (const entry of section.entries) {
90012
+ if (entry.children.length === 0) {
90013
+ articles.push(entry);
90014
+ if (!grouped)
90015
+ flush();
90016
+ continue;
90017
+ }
90018
+ flush();
90019
+ card(lines, entry.href ? `[${mdLabel(localizer.entryTitle(tag, entry))}](${entry.href})` : mdLabel(localizer.entryTitle(tag, entry)), entry.children, tag);
90020
+ }
90021
+ flush();
90021
90022
  lines.push("</div>");
90022
90023
  return lines.join(`
90023
90024
  `) + `