@brillout/docpress 0.5.4 → 0.5.6
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.
|
@@ -44,9 +44,9 @@ function RepoLink({ path, text, editMode }) {
|
|
|
44
44
|
}, text);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/
|
|
47
|
+
// src/parseTitle.ts
|
|
48
48
|
import React3 from "react";
|
|
49
|
-
function
|
|
49
|
+
function getHeadingsWithProcessedTitle(config) {
|
|
50
50
|
const headingsWithoutParent = config.headings.map((heading) => {
|
|
51
51
|
const titleProcessed = parseTitle(heading.title);
|
|
52
52
|
const titleInNav = heading.titleInNav || heading.title;
|
|
@@ -69,28 +69,28 @@ function getHeadings(config) {
|
|
|
69
69
|
};
|
|
70
70
|
return headingProcessed;
|
|
71
71
|
});
|
|
72
|
-
const
|
|
72
|
+
const headingsProcessed = [];
|
|
73
73
|
headingsWithoutParent.forEach((heading) => {
|
|
74
|
-
const parentHeadings = findParentHeadings(heading,
|
|
75
|
-
|
|
74
|
+
const parentHeadings = findParentHeadings(heading, headingsProcessed);
|
|
75
|
+
headingsProcessed.push({ ...heading, parentHeadings });
|
|
76
76
|
});
|
|
77
|
-
const
|
|
78
|
-
const { url, title } =
|
|
77
|
+
const headingsDetachedProcessed = config.headingsDetached.map((headingsDetached) => {
|
|
78
|
+
const { url, title } = headingsDetached;
|
|
79
79
|
assert(
|
|
80
|
-
|
|
81
|
-
`remove ${
|
|
80
|
+
headingsProcessed.find((heading) => heading.url === url) === void 0,
|
|
81
|
+
`remove ${headingsDetached.url} from headingsDetached`
|
|
82
82
|
);
|
|
83
83
|
const titleProcessed = typeof title === "string" ? parseTitle(title) : title;
|
|
84
84
|
return {
|
|
85
|
-
...
|
|
85
|
+
...headingsDetached,
|
|
86
86
|
level: 2,
|
|
87
87
|
title: titleProcessed,
|
|
88
88
|
titleInNav: titleProcessed,
|
|
89
89
|
parentHeadings: null
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
|
-
assertHeadingsUrl([...
|
|
93
|
-
return {
|
|
92
|
+
assertHeadingsUrl([...headingsProcessed, ...headingsDetachedProcessed]);
|
|
93
|
+
return { headingsProcessed, headingsDetachedProcessed };
|
|
94
94
|
}
|
|
95
95
|
function findParentHeadings(heading, headings) {
|
|
96
96
|
const parentHeadings = [];
|
|
@@ -172,6 +172,6 @@ export {
|
|
|
172
172
|
usePageContext,
|
|
173
173
|
isRepoLink,
|
|
174
174
|
RepoLink,
|
|
175
|
-
|
|
175
|
+
getHeadingsWithProcessedTitle,
|
|
176
176
|
parseTitle
|
|
177
177
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RepoLink,
|
|
3
|
-
getHeadings,
|
|
4
3
|
isRepoLink,
|
|
5
4
|
parseTitle,
|
|
6
5
|
usePageContext
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5UXVGXHH.js";
|
|
8
7
|
import {
|
|
9
8
|
FeatureList
|
|
10
9
|
} from "./chunk-NVJING6T.js";
|
|
@@ -34,6 +33,10 @@ function Link({
|
|
|
34
33
|
doNotInferSectionTitle,
|
|
35
34
|
titleNormalCase
|
|
36
35
|
}) {
|
|
36
|
+
assertUsage(
|
|
37
|
+
href.startsWith("/") || href.startsWith("#"),
|
|
38
|
+
`<Link href /> prop \`href==='${href}'\` but should start with '/' or '#'`
|
|
39
|
+
);
|
|
37
40
|
if (isRepoLink(href)) {
|
|
38
41
|
return /* @__PURE__ */ React.createElement(RepoLink, {
|
|
39
42
|
path: href,
|
|
@@ -86,7 +89,11 @@ function getTitle({
|
|
|
86
89
|
breadcrumbs.push(heading.title);
|
|
87
90
|
if (urlHash) {
|
|
88
91
|
let sectionTitle = void 0;
|
|
89
|
-
|
|
92
|
+
assert(!urlHash.startsWith("#"));
|
|
93
|
+
const pageHeading = linkIsOnSamePage && findHeading(`#${urlHash}`, pageContext);
|
|
94
|
+
if (pageHeading) {
|
|
95
|
+
sectionTitle = pageHeading.title;
|
|
96
|
+
} else if ("sectionTitles" in heading && heading.sectionTitles) {
|
|
90
97
|
heading.sectionTitles.forEach((title) => {
|
|
91
98
|
if (determineSectionUrlHash(title) === urlHash) {
|
|
92
99
|
sectionTitle = parseTitle(title);
|
|
@@ -117,16 +124,16 @@ function getTitle({
|
|
|
117
124
|
}));
|
|
118
125
|
}
|
|
119
126
|
function findHeading(href, pageContext) {
|
|
120
|
-
assert(href.startsWith("/")
|
|
121
|
-
const {
|
|
127
|
+
assert(href.startsWith("/") || href.startsWith("#"));
|
|
128
|
+
const { headingsProcessed, headingsDetachedProcessed } = pageContext;
|
|
122
129
|
{
|
|
123
|
-
const heading2 =
|
|
130
|
+
const heading2 = headingsDetachedProcessed.find(({ url }) => href === url);
|
|
124
131
|
if (heading2) {
|
|
125
132
|
return heading2;
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
|
-
const heading =
|
|
129
|
-
assert(heading, `Could not find
|
|
135
|
+
const heading = headingsProcessed.find(({ url }) => href === url);
|
|
136
|
+
assert(heading, `Could not find heading for ${href}. Did you define the heading for ${href}?`);
|
|
130
137
|
return heading;
|
|
131
138
|
}
|
|
132
139
|
|
|
@@ -309,7 +316,9 @@ var alignable_default = "/assets/alignable-B4QZV4X7.svg";
|
|
|
309
316
|
|
|
310
317
|
// src/components/Sponsors/sponsorsList.ts
|
|
311
318
|
var individuals = [
|
|
312
|
-
{ username: "
|
|
319
|
+
{ username: "talzion12" },
|
|
320
|
+
{ username: "felixhaeberle" },
|
|
321
|
+
{ username: "apappas1129" },
|
|
313
322
|
{ username: "agalbenus" },
|
|
314
323
|
{ username: "phiberber" },
|
|
315
324
|
{ username: "cookieplace" },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PageContextProvider,
|
|
3
3
|
RepoLink,
|
|
4
|
-
|
|
4
|
+
getHeadingsWithProcessedTitle,
|
|
5
5
|
parseTitle,
|
|
6
6
|
usePageContext
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5UXVGXHH.js";
|
|
8
8
|
import {
|
|
9
9
|
Emoji,
|
|
10
10
|
jsxToTextContent,
|
|
@@ -187,13 +187,13 @@ function Navigation({
|
|
|
187
187
|
const currentUrl = pageContext.urlPathname;
|
|
188
188
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", {
|
|
189
189
|
id: "navigation-container"
|
|
190
|
-
}, /* @__PURE__ */ React3.createElement(NavigationHeader, null), pageContext.
|
|
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.
|
|
192
|
+
headings: 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.
|
|
196
|
+
headings: pageContext.headingsProcessed,
|
|
197
197
|
currentUrl
|
|
198
198
|
}), /* @__PURE__ */ React3.createElement(NavigationFullscreenClose, null)));
|
|
199
199
|
}
|
|
@@ -432,19 +432,18 @@ function getConfig() {
|
|
|
432
432
|
// src/config/resolvePageContext.ts
|
|
433
433
|
function resolvePageContext(pageContext) {
|
|
434
434
|
const config = getConfig();
|
|
435
|
-
const
|
|
436
|
-
const {
|
|
437
|
-
let
|
|
438
|
-
|
|
435
|
+
const processed = getHeadingsWithProcessedTitle(config);
|
|
436
|
+
const { headingsDetachedProcessed } = processed;
|
|
437
|
+
let { headingsProcessed } = processed;
|
|
438
|
+
const { activeHeading, activeNavigationHeading } = findHeading(headingsProcessed, headingsDetachedProcessed, pageContext);
|
|
439
|
+
let headingsOfDetachedPage = null;
|
|
439
440
|
if (activeNavigationHeading) {
|
|
440
|
-
|
|
441
|
-
headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeNavigationHeading);
|
|
441
|
+
headingsProcessed = getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeNavigationHeading);
|
|
442
442
|
} else {
|
|
443
|
-
|
|
444
|
-
headingsWithSubHeadings = headings;
|
|
443
|
+
headingsOfDetachedPage = [activeHeading, ...getPageHeadings(pageContext, activeHeading)];
|
|
445
444
|
}
|
|
446
445
|
const { title, isLandingPage, pageTitle } = getMetaData(
|
|
447
|
-
|
|
446
|
+
headingsDetachedProcessed,
|
|
448
447
|
activeNavigationHeading,
|
|
449
448
|
pageContext,
|
|
450
449
|
config
|
|
@@ -463,16 +462,16 @@ function resolvePageContext(pageContext) {
|
|
|
463
462
|
algolia
|
|
464
463
|
},
|
|
465
464
|
activeHeading,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
465
|
+
headingsProcessed,
|
|
466
|
+
headingsDetachedProcessed,
|
|
467
|
+
headingsOfDetachedPage,
|
|
469
468
|
isLandingPage,
|
|
470
469
|
pageTitle,
|
|
471
470
|
config
|
|
472
471
|
});
|
|
473
472
|
return pageContextResolved;
|
|
474
473
|
}
|
|
475
|
-
function getMetaData(
|
|
474
|
+
function getMetaData(headingsDetachedProcessed, activeNavigationHeading, pageContext, config) {
|
|
476
475
|
const url = pageContext.urlOriginal;
|
|
477
476
|
let title;
|
|
478
477
|
let pageTitle;
|
|
@@ -480,7 +479,7 @@ function getMetaData(headingsDetached, activeNavigationHeading, pageContext, con
|
|
|
480
479
|
title = activeNavigationHeading.titleDocument || jsxToTextContent(activeNavigationHeading.title);
|
|
481
480
|
pageTitle = activeNavigationHeading.title;
|
|
482
481
|
} else {
|
|
483
|
-
pageTitle =
|
|
482
|
+
pageTitle = headingsDetachedProcessed.find((h) => h.url === url).title;
|
|
484
483
|
title = jsxToTextContent(pageTitle);
|
|
485
484
|
}
|
|
486
485
|
const isLandingPage = url === "/";
|
|
@@ -492,12 +491,12 @@ function getMetaData(headingsDetached, activeNavigationHeading, pageContext, con
|
|
|
492
491
|
}
|
|
493
492
|
return { title, isLandingPage, pageTitle };
|
|
494
493
|
}
|
|
495
|
-
function findHeading(
|
|
494
|
+
function findHeading(headingsProcessed, headingsDetachedProcessed, pageContext) {
|
|
496
495
|
let activeNavigationHeading = null;
|
|
497
496
|
let activeHeading = null;
|
|
498
497
|
assert(pageContext.urlOriginal);
|
|
499
498
|
const pageUrl = pageContext.urlOriginal;
|
|
500
|
-
|
|
499
|
+
headingsProcessed.forEach((heading) => {
|
|
501
500
|
if (heading.url === pageUrl) {
|
|
502
501
|
activeNavigationHeading = heading;
|
|
503
502
|
activeHeading = heading;
|
|
@@ -505,30 +504,30 @@ function findHeading(headings, headingsDetached, pageContext) {
|
|
|
505
504
|
}
|
|
506
505
|
});
|
|
507
506
|
if (!activeHeading) {
|
|
508
|
-
activeHeading =
|
|
507
|
+
activeHeading = headingsDetachedProcessed.find(({ url }) => pageUrl === url) ?? null;
|
|
509
508
|
}
|
|
510
509
|
if (!activeHeading) {
|
|
511
510
|
throw new Error(
|
|
512
511
|
[
|
|
513
512
|
`Heading not found for URL '${pageUrl}'`,
|
|
514
513
|
"Heading is defined for following URLs:",
|
|
515
|
-
...
|
|
514
|
+
...headingsProcessed.map((h) => ` ${h.url}`).filter(Boolean).sort()
|
|
516
515
|
].join("\n")
|
|
517
516
|
);
|
|
518
517
|
}
|
|
519
518
|
return { activeHeading, activeNavigationHeading };
|
|
520
519
|
}
|
|
521
|
-
function getHeadingsWithSubHeadings(
|
|
522
|
-
const
|
|
520
|
+
function getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeNavigationHeading) {
|
|
521
|
+
const headingsProcessedWithSubHeadings = headingsProcessed.slice();
|
|
523
522
|
if (activeNavigationHeading === null)
|
|
524
|
-
return
|
|
523
|
+
return headingsProcessedWithSubHeadings;
|
|
525
524
|
const pageHeadings = getPageHeadings(pageContext, activeNavigationHeading);
|
|
526
|
-
const activeHeadingIdx =
|
|
525
|
+
const activeHeadingIdx = headingsProcessedWithSubHeadings.indexOf(activeNavigationHeading);
|
|
527
526
|
assert(activeHeadingIdx >= 0);
|
|
528
527
|
pageHeadings.forEach((pageHeading, i) => {
|
|
529
|
-
|
|
528
|
+
headingsProcessedWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, pageHeading);
|
|
530
529
|
});
|
|
531
|
-
return
|
|
530
|
+
return headingsProcessedWithSubHeadings;
|
|
532
531
|
}
|
|
533
532
|
function getPageHeadings(pageContext, currentHeading) {
|
|
534
533
|
const pageHeadings = [];
|