@brillout/docpress 0.5.6 → 0.5.8

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.
@@ -35,7 +35,7 @@ function RepoLink({ path, text, editMode }) {
35
35
  if (!path.startsWith("/")) {
36
36
  path = "/" + path;
37
37
  }
38
- const viewMode = editMode && "edit" || path.endsWith("/") && "tree" || "blob";
38
+ const viewMode = path.endsWith("/") || editMode ? "tree" : "blob";
39
39
  const { githubRepository } = pageContext.config.projectInfo;
40
40
  assert(githubRepository.startsWith("https://github.com/"));
41
41
  const href = `${githubRepository}/${viewMode}/main${path}`;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  isRepoLink,
4
4
  parseTitle,
5
5
  usePageContext
6
- } from "./chunk-5UXVGXHH.js";
6
+ } from "./chunk-SXKTLA5S.js";
7
7
  import {
8
8
  FeatureList
9
9
  } from "./chunk-NVJING6T.js";
@@ -64,22 +64,22 @@ function getTitle({
64
64
  assert(hrefWithoutHash || urlHash);
65
65
  }
66
66
  let heading;
67
- let linkIsOnSamePage = false;
67
+ let isLinkOnSamePage = false;
68
68
  if (hrefWithoutHash) {
69
69
  heading = findHeading(hrefWithoutHash, pageContext);
70
70
  if (heading.url === pageContext.urlPathname) {
71
- linkIsOnSamePage = true;
71
+ isLinkOnSamePage = true;
72
72
  heading = pageContext.activeHeading;
73
73
  }
74
74
  } else {
75
75
  assert(urlHash);
76
- linkIsOnSamePage = true;
76
+ isLinkOnSamePage = true;
77
77
  heading = pageContext.activeHeading;
78
78
  }
79
79
  assert(heading);
80
- assert(linkIsOnSamePage === (heading.url === pageContext.urlPathname));
81
- assert(linkIsOnSamePage === (heading.url === pageContext.activeHeading.url));
82
- assert(linkIsOnSamePage === (heading === pageContext.activeHeading));
80
+ assert(isLinkOnSamePage === (heading.url === pageContext.urlPathname));
81
+ assert(isLinkOnSamePage === (heading.url === pageContext.activeHeading.url));
82
+ assert(isLinkOnSamePage === (heading === pageContext.activeHeading));
83
83
  const breadcrumbs = [];
84
84
  if (heading.parentHeadings) {
85
85
  breadcrumbs.push(
@@ -90,8 +90,8 @@ function getTitle({
90
90
  if (urlHash) {
91
91
  let sectionTitle = void 0;
92
92
  assert(!urlHash.startsWith("#"));
93
- const pageHeading = linkIsOnSamePage && findHeading(`#${urlHash}`, pageContext);
94
- if (pageHeading) {
93
+ if (isLinkOnSamePage) {
94
+ const pageHeading = findHeading(`#${urlHash}`, pageContext);
95
95
  sectionTitle = pageHeading.title;
96
96
  } else if ("sectionTitles" in heading && heading.sectionTitles) {
97
97
  heading.sectionTitles.forEach((title) => {
@@ -112,7 +112,7 @@ function getTitle({
112
112
  breadcrumbs.push(sectionTitle);
113
113
  }
114
114
  {
115
- if (noBreadcrumb || linkIsOnSamePage) {
115
+ if (noBreadcrumb || isLinkOnSamePage) {
116
116
  return breadcrumbs[breadcrumbs.length - 1];
117
117
  }
118
118
  }
@@ -125,15 +125,13 @@ function getTitle({
125
125
  }
126
126
  function findHeading(href, pageContext) {
127
127
  assert(href.startsWith("/") || href.startsWith("#"));
128
- const { headingsProcessed, headingsDetachedProcessed } = pageContext;
129
- {
130
- const heading2 = headingsDetachedProcessed.find(({ url }) => href === url);
131
- if (heading2) {
132
- return heading2;
133
- }
128
+ const { headingsAll } = pageContext;
129
+ const heading = headingsAll.find(({ url }) => href === url);
130
+ if (href.startsWith("#")) {
131
+ assertUsage(heading, `Couldn't find ${href} in ${pageContext.urlPathname}, does it exist?`);
132
+ } else {
133
+ assertUsage(heading, `Couldn't find heading for ${href}, did you define the heading for ${href}?`);
134
134
  }
135
- const heading = headingsProcessed.find(({ url }) => href === url);
136
- assert(heading, `Could not find heading for ${href}. Did you define the heading for ${href}?`);
137
135
  return heading;
138
136
  }
139
137
 
@@ -4,7 +4,7 @@ import {
4
4
  getHeadingsWithProcessedTitle,
5
5
  parseTitle,
6
6
  usePageContext
7
- } from "../chunk-5UXVGXHH.js";
7
+ } from "../chunk-SXKTLA5S.js";
8
8
  import {
9
9
  Emoji,
10
10
  jsxToTextContent,
@@ -189,11 +189,11 @@ function Navigation({
189
189
  id: "navigation-container"
190
190
  }, /* @__PURE__ */ React3.createElement(NavigationHeader, null), pageContext.headingsOfDetachedPage && /* @__PURE__ */ React3.createElement(React3.Fragment, null, pageContext.headingsOfDetachedPage.length > 1 && /* @__PURE__ */ React3.createElement(NavigationContent, {
191
191
  id: "navigation-content-detached",
192
- headings: pageContext.headingsOfDetachedPage,
192
+ headingsProcessed: pageContext.headingsOfDetachedPage,
193
193
  currentUrl
194
194
  }), /* @__PURE__ */ React3.createElement(DetachedPageNote, null)), /* @__PURE__ */ React3.createElement(NavigationContent, {
195
195
  id: "navigation-content-main",
196
- headings: pageContext.headingsProcessed,
196
+ headingsProcessed: pageContext.headingsProcessed,
197
197
  currentUrl
198
198
  }), /* @__PURE__ */ React3.createElement(NavigationFullscreenClose, null)));
199
199
  }
@@ -203,7 +203,7 @@ function NavigationMask() {
203
203
  });
204
204
  }
205
205
  function NavigationContent(props) {
206
- const headings = getHeadingsWithComputedProps(props.headings, props.currentUrl);
206
+ const headings = getHeadingsWithComputedProps(props.headingsProcessed, props.currentUrl);
207
207
  const headingsGrouped = groupHeadings(headings);
208
208
  return /* @__PURE__ */ React3.createElement("div", {
209
209
  id: props.id,
@@ -435,8 +435,14 @@ function resolvePageContext(pageContext) {
435
435
  const processed = getHeadingsWithProcessedTitle(config);
436
436
  const { headingsDetachedProcessed } = processed;
437
437
  let { headingsProcessed } = processed;
438
- const { activeHeading, activeNavigationHeading } = findHeading(headingsProcessed, headingsDetachedProcessed, pageContext);
438
+ const { activeHeading, activeNavigationHeading } = findHeading(
439
+ headingsProcessed,
440
+ headingsDetachedProcessed,
441
+ pageContext
442
+ );
439
443
  let headingsOfDetachedPage = null;
444
+ let headingsAll = [...headingsProcessed, ...headingsDetachedProcessed];
445
+ headingsAll = getHeadingsWithSubHeadings(headingsAll, pageContext, activeHeading);
440
446
  if (activeNavigationHeading) {
441
447
  headingsProcessed = getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeNavigationHeading);
442
448
  } else {
@@ -462,6 +468,7 @@ function resolvePageContext(pageContext) {
462
468
  algolia
463
469
  },
464
470
  activeHeading,
471
+ headingsAll,
465
472
  headingsProcessed,
466
473
  headingsDetachedProcessed,
467
474
  headingsOfDetachedPage,
@@ -517,12 +524,10 @@ function findHeading(headingsProcessed, headingsDetachedProcessed, pageContext)
517
524
  }
518
525
  return { activeHeading, activeNavigationHeading };
519
526
  }
520
- function getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeNavigationHeading) {
527
+ function getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeHeading) {
521
528
  const headingsProcessedWithSubHeadings = headingsProcessed.slice();
522
- if (activeNavigationHeading === null)
523
- return headingsProcessedWithSubHeadings;
524
- const pageHeadings = getPageHeadings(pageContext, activeNavigationHeading);
525
- const activeHeadingIdx = headingsProcessedWithSubHeadings.indexOf(activeNavigationHeading);
529
+ const pageHeadings = getPageHeadings(pageContext, activeHeading);
530
+ const activeHeadingIdx = headingsProcessedWithSubHeadings.indexOf(activeHeading);
526
531
  assert(activeHeadingIdx >= 0);
527
532
  pageHeadings.forEach((pageHeading, i) => {
528
533
  headingsProcessedWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, pageHeading);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "scripts": {
5
5
  "// Check types while developing": "",
6
6
  "types": "tsc --noEmit --watch",