@brillout/docpress 0.5.5 → 0.5.7
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/dist/index.js +15 -17
- package/dist/renderer/_default.page.server.js +14 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,22 +64,22 @@ function getTitle({
|
|
|
64
64
|
assert(hrefWithoutHash || urlHash);
|
|
65
65
|
}
|
|
66
66
|
let heading;
|
|
67
|
-
let
|
|
67
|
+
let isLinkOnSamePage = false;
|
|
68
68
|
if (hrefWithoutHash) {
|
|
69
69
|
heading = findHeading(hrefWithoutHash, pageContext);
|
|
70
70
|
if (heading.url === pageContext.urlPathname) {
|
|
71
|
-
|
|
71
|
+
isLinkOnSamePage = true;
|
|
72
72
|
heading = pageContext.activeHeading;
|
|
73
73
|
}
|
|
74
74
|
} else {
|
|
75
75
|
assert(urlHash);
|
|
76
|
-
|
|
76
|
+
isLinkOnSamePage = true;
|
|
77
77
|
heading = pageContext.activeHeading;
|
|
78
78
|
}
|
|
79
79
|
assert(heading);
|
|
80
|
-
assert(
|
|
81
|
-
assert(
|
|
82
|
-
assert(
|
|
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
|
-
|
|
94
|
-
|
|
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 ||
|
|
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 {
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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(
|
|
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,
|
|
527
|
+
function getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeHeading) {
|
|
521
528
|
const headingsProcessedWithSubHeadings = headingsProcessed.slice();
|
|
522
|
-
|
|
523
|
-
|
|
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);
|