@brillout/docpress 0.3.8 → 0.3.9
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.d.ts +1 -8
- package/dist/index.js +70 -65
- package/dist/renderer/_default.page.server.js +35 -29
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -90,13 +90,6 @@ declare function Link(props: {
|
|
|
90
90
|
doNotInferSectionTitle?: true;
|
|
91
91
|
}): JSX.Element;
|
|
92
92
|
|
|
93
|
-
declare function DocLink({ href, text, noBreadcrumb, doNotInferSectionTitle }: {
|
|
94
|
-
href: string;
|
|
95
|
-
text?: string | JSX.Element;
|
|
96
|
-
noBreadcrumb?: true;
|
|
97
|
-
doNotInferSectionTitle?: true;
|
|
98
|
-
}): JSX.Element;
|
|
99
|
-
|
|
100
93
|
declare function isRepoLink(href: string): boolean;
|
|
101
94
|
declare function RepoLink({ path, text, editMode }: {
|
|
102
95
|
path: string;
|
|
@@ -147,4 +140,4 @@ declare function CodeBlock({ children, lineBreak }: {
|
|
|
147
140
|
lineBreak?: true;
|
|
148
141
|
}): JSX.Element;
|
|
149
142
|
|
|
150
|
-
export { CodeBlock, Config,
|
|
143
|
+
export { CodeBlock, Config, Emoji, EmojiName, HeadingDefinition, HeadingWithoutLink, HorizontalLine, ImportMeta, Info, Link, Note, P, ReadingRecommendation, RepoLink, Sponsor, Sponsors, assert, assertUsage, assertWarning, crawlAllFiles, determineSectionTitle, determineSectionUrlHash, filter, isBrowser, isRepoLink, jsxToTextContent, objectAssign };
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,19 @@ import {
|
|
|
26
26
|
import "./chunk-3QC7HYIF.js";
|
|
27
27
|
|
|
28
28
|
// src/components/Link.tsx
|
|
29
|
-
import React2 from "react";
|
|
30
|
-
|
|
31
|
-
// src/components/DocLink.tsx
|
|
32
29
|
import React from "react";
|
|
30
|
+
function Link(props) {
|
|
31
|
+
if (isRepoLink(props.href)) {
|
|
32
|
+
return /* @__PURE__ */ React.createElement(RepoLink, {
|
|
33
|
+
path: props.href,
|
|
34
|
+
text: props.text
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
return /* @__PURE__ */ React.createElement(DocLink, {
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
33
42
|
function DocLink({
|
|
34
43
|
href,
|
|
35
44
|
text,
|
|
@@ -52,8 +61,20 @@ function getTitle({
|
|
|
52
61
|
if (href.includes("#")) {
|
|
53
62
|
;
|
|
54
63
|
[hrefWithoutHash, urlHash] = href.split("#");
|
|
64
|
+
assert(hrefWithoutHash || urlHash);
|
|
65
|
+
}
|
|
66
|
+
let heading;
|
|
67
|
+
let linkIsOnSamePage;
|
|
68
|
+
if (hrefWithoutHash) {
|
|
69
|
+
heading = findHeading(hrefWithoutHash, pageContext);
|
|
70
|
+
linkIsOnSamePage = heading.url === pageContext.urlPathname;
|
|
71
|
+
} else {
|
|
72
|
+
assert(urlHash);
|
|
73
|
+
linkIsOnSamePage = true;
|
|
74
|
+
heading = pageContext.activeHeading;
|
|
55
75
|
}
|
|
56
|
-
|
|
76
|
+
assert(heading);
|
|
77
|
+
assert(heading === pageContext.activeHeading || !linkIsOnSamePage);
|
|
57
78
|
const breadcrumbs = [];
|
|
58
79
|
if ("parentHeadings" in heading) {
|
|
59
80
|
breadcrumbs.push(
|
|
@@ -80,7 +101,6 @@ function getTitle({
|
|
|
80
101
|
breadcrumbs.push(sectionTitle);
|
|
81
102
|
}
|
|
82
103
|
{
|
|
83
|
-
const linkIsOnSamePage = heading.url === pageContext.urlPathname;
|
|
84
104
|
if (noBreadcrumb || linkIsOnSamePage) {
|
|
85
105
|
return breadcrumbs[breadcrumbs.length - 1];
|
|
86
106
|
}
|
|
@@ -106,70 +126,56 @@ function findHeading(href, pageContext) {
|
|
|
106
126
|
return heading;
|
|
107
127
|
}
|
|
108
128
|
|
|
109
|
-
// src/components/Link.tsx
|
|
110
|
-
function Link(props) {
|
|
111
|
-
if (isRepoLink(props.href)) {
|
|
112
|
-
return /* @__PURE__ */ React2.createElement(RepoLink, {
|
|
113
|
-
path: props.href,
|
|
114
|
-
text: props.text
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
return /* @__PURE__ */ React2.createElement(DocLink, {
|
|
118
|
-
...props
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
129
|
// src/components/P.tsx
|
|
124
|
-
import
|
|
130
|
+
import React2 from "react";
|
|
125
131
|
function P(props) {
|
|
126
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
127
133
|
...props,
|
|
128
134
|
className: "paragraph"
|
|
129
135
|
});
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
// src/components/Info.tsx
|
|
133
|
-
import
|
|
139
|
+
import React3 from "react";
|
|
134
140
|
function Info({ children }) {
|
|
135
|
-
return /* @__PURE__ */
|
|
141
|
+
return /* @__PURE__ */ React3.createElement("blockquote", null, /* @__PURE__ */ React3.createElement(P, null, children));
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
// src/components/ReadingRecommendation.tsx
|
|
139
|
-
import
|
|
145
|
+
import React4 from "react";
|
|
140
146
|
function ReadingRecommendation({ tour, links }) {
|
|
141
147
|
const multiple = links.length + (tour ? 1 : 0) > 1;
|
|
142
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React4.createElement(Info, null, multiple ? " " : "", /* @__PURE__ */ React4.createElement("b", null, "Reading Recommendation", multiple ? "." : ": "), (() => {
|
|
143
149
|
if (!multiple) {
|
|
144
|
-
const link = tour ? /* @__PURE__ */
|
|
150
|
+
const link = tour ? /* @__PURE__ */ React4.createElement(TourLink, null) : /* @__PURE__ */ React4.createElement(Link, {
|
|
145
151
|
href: links[0]
|
|
146
152
|
});
|
|
147
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, link, ".");
|
|
148
154
|
}
|
|
149
|
-
return /* @__PURE__ */
|
|
155
|
+
return /* @__PURE__ */ React4.createElement("ul", {
|
|
150
156
|
style: {
|
|
151
157
|
marginLeft: 18,
|
|
152
158
|
marginTop: 11
|
|
153
159
|
}
|
|
154
|
-
}, tour && /* @__PURE__ */
|
|
160
|
+
}, tour && /* @__PURE__ */ React4.createElement("li", null, /* @__PURE__ */ React4.createElement(TourLink, null)), links.map((link, i) => /* @__PURE__ */ React4.createElement("li", {
|
|
155
161
|
key: i
|
|
156
|
-
}, /* @__PURE__ */
|
|
162
|
+
}, /* @__PURE__ */ React4.createElement(Link, {
|
|
157
163
|
href: link
|
|
158
164
|
}))));
|
|
159
165
|
})());
|
|
160
166
|
}
|
|
161
167
|
function TourLink() {
|
|
162
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Link, {
|
|
163
169
|
href: "/react-tour",
|
|
164
170
|
noBreadcrumb: true
|
|
165
|
-
}), " or ", /* @__PURE__ */
|
|
171
|
+
}), " or ", /* @__PURE__ */ React4.createElement(Link, {
|
|
166
172
|
href: "/vue-tour",
|
|
167
173
|
noBreadcrumb: true
|
|
168
174
|
}));
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
// src/components/Note.tsx
|
|
172
|
-
import
|
|
178
|
+
import React5 from "react";
|
|
173
179
|
function Note({
|
|
174
180
|
type,
|
|
175
181
|
icon,
|
|
@@ -184,31 +190,31 @@ function Note({
|
|
|
184
190
|
icon = ":warning:";
|
|
185
191
|
}
|
|
186
192
|
}
|
|
187
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ React5.createElement("blockquote", {
|
|
188
194
|
className: type
|
|
189
|
-
}, /* @__PURE__ */
|
|
195
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
190
196
|
style: { marginBottom: 20 }
|
|
191
|
-
}), icon, " ", children, /* @__PURE__ */
|
|
197
|
+
}), icon, " ", children, /* @__PURE__ */ React5.createElement("div", {
|
|
192
198
|
style: { marginTop: 20 }
|
|
193
199
|
}));
|
|
194
200
|
}
|
|
195
201
|
|
|
196
202
|
// src/components/ImportMeta.tsx
|
|
197
|
-
import
|
|
203
|
+
import React6 from "react";
|
|
198
204
|
function ImportMeta({ prop }) {
|
|
199
205
|
assert(!prop.startsWith("import"));
|
|
200
206
|
assert(!prop.startsWith("."));
|
|
201
207
|
const text = "import.meta." + prop;
|
|
202
|
-
return /* @__PURE__ */
|
|
208
|
+
return /* @__PURE__ */ React6.createElement("code", null, text);
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
// src/components/HorizontalLine.tsx
|
|
206
|
-
import
|
|
212
|
+
import React7 from "react";
|
|
207
213
|
function HorizontalLine({ primary }) {
|
|
208
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
209
215
|
className: "header-separator-line " + (primary ? "primary" : ""),
|
|
210
216
|
style: { textAlign: "center" }
|
|
211
|
-
}, /* @__PURE__ */
|
|
217
|
+
}, /* @__PURE__ */ React7.createElement("hr", {
|
|
212
218
|
style: {
|
|
213
219
|
display: "inline-block",
|
|
214
220
|
margin: 0,
|
|
@@ -221,7 +227,7 @@ function HorizontalLine({ primary }) {
|
|
|
221
227
|
}
|
|
222
228
|
|
|
223
229
|
// src/components/Sponsors.tsx
|
|
224
|
-
import
|
|
230
|
+
import React8 from "react";
|
|
225
231
|
|
|
226
232
|
// src/icons/heart.svg
|
|
227
233
|
var heart_default = "/assets/heart-OINVKOXO.svg";
|
|
@@ -341,9 +347,9 @@ function Sponsors() {
|
|
|
341
347
|
const { projectInfo } = pageContext.config;
|
|
342
348
|
const sponsorsCompany = sponsorsList.filter((sponsor) => !("username" in sponsor));
|
|
343
349
|
const sponsorsHumanidual = sponsorsList.filter((sponsor) => "username" in sponsor);
|
|
344
|
-
return /* @__PURE__ */
|
|
350
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
345
351
|
style: { textAlign: "center", marginTop: 19 }
|
|
346
|
-
}, /* @__PURE__ */
|
|
352
|
+
}, /* @__PURE__ */ React8.createElement("a", {
|
|
347
353
|
className: "button",
|
|
348
354
|
href: "https://github.com/sponsors/brillout",
|
|
349
355
|
style: {
|
|
@@ -353,21 +359,21 @@ function Sponsors() {
|
|
|
353
359
|
padding: "5px 10px",
|
|
354
360
|
marginBottom: 10
|
|
355
361
|
}
|
|
356
|
-
}, /* @__PURE__ */
|
|
362
|
+
}, /* @__PURE__ */ React8.createElement("img", {
|
|
357
363
|
src: heart_default,
|
|
358
364
|
height: 22
|
|
359
|
-
}), " ", /* @__PURE__ */
|
|
365
|
+
}), " ", /* @__PURE__ */ React8.createElement("span", {
|
|
360
366
|
style: { marginLeft: 7, fontSize: "1.07em" }
|
|
361
|
-
}, "Sponsor")), /* @__PURE__ */
|
|
367
|
+
}, "Sponsor")), /* @__PURE__ */ React8.createElement("div", null), /* @__PURE__ */ React8.createElement("div", {
|
|
362
368
|
style: { maxWidth: 400, display: "inline-block", marginTop: 12, marginBottom: 12 }
|
|
363
|
-
}, projectInfo.projectNameJsx || projectInfo.projectName, " is free and open source, made possible by wonderful sponsors."), /* @__PURE__ */
|
|
369
|
+
}, projectInfo.projectNameJsx || projectInfo.projectName, " is free and open source, made possible by wonderful sponsors."), /* @__PURE__ */ React8.createElement("div", {
|
|
364
370
|
style: { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", alignItems: "end" }
|
|
365
|
-
}, sponsorsCompany.map((sponsor, i) => /* @__PURE__ */
|
|
371
|
+
}, sponsorsCompany.map((sponsor, i) => /* @__PURE__ */ React8.createElement(SponsorDiv, {
|
|
366
372
|
sponsor,
|
|
367
373
|
key: i
|
|
368
|
-
}))), /* @__PURE__ */
|
|
374
|
+
}))), /* @__PURE__ */ React8.createElement("div", {
|
|
369
375
|
style: { display: "flex", flexWrap: "wrap", justifyContent: "center", alignItems: "end", marginTop: 20 }
|
|
370
|
-
}, sponsorsHumanidual.map((sponsor, i) => /* @__PURE__ */
|
|
376
|
+
}, sponsorsHumanidual.map((sponsor, i) => /* @__PURE__ */ React8.createElement(SponsorDiv, {
|
|
371
377
|
sponsor,
|
|
372
378
|
key: i
|
|
373
379
|
}))));
|
|
@@ -396,17 +402,17 @@ function SponsorDiv({ sponsor }) {
|
|
|
396
402
|
height = size.height;
|
|
397
403
|
padding = size.padding;
|
|
398
404
|
imgAlt = sponsor.companyName;
|
|
399
|
-
label = /* @__PURE__ */
|
|
405
|
+
label = /* @__PURE__ */ React8.createElement(Label, {
|
|
400
406
|
sponsor
|
|
401
407
|
});
|
|
402
408
|
}
|
|
403
409
|
const marginWidth = 5;
|
|
404
|
-
return /* @__PURE__ */
|
|
410
|
+
return /* @__PURE__ */ React8.createElement("a", {
|
|
405
411
|
href: website,
|
|
406
412
|
style: {
|
|
407
413
|
margin: `10px ${marginWidth}px`
|
|
408
414
|
}
|
|
409
|
-
}, label, /* @__PURE__ */
|
|
415
|
+
}, label, /* @__PURE__ */ React8.createElement("div", {
|
|
410
416
|
style: {
|
|
411
417
|
backgroundColor,
|
|
412
418
|
borderRadius: 7,
|
|
@@ -419,7 +425,7 @@ function SponsorDiv({ sponsor }) {
|
|
|
419
425
|
flexDirection: "column",
|
|
420
426
|
justifyContent: "center"
|
|
421
427
|
}
|
|
422
|
-
}, /* @__PURE__ */
|
|
428
|
+
}, /* @__PURE__ */ React8.createElement("img", {
|
|
423
429
|
style: { width: `calc(100% - ${padding}px)`, height: height - padding, zIndex: 2, objectFit: "contain" },
|
|
424
430
|
src: imgSrc,
|
|
425
431
|
alt: imgAlt
|
|
@@ -430,7 +436,7 @@ function Label({ sponsor }) {
|
|
|
430
436
|
const labelBg = getLabelBg(sponsor);
|
|
431
437
|
const labelIcon = getLabelIcon(sponsor);
|
|
432
438
|
const labelText = getLabelText(sponsor);
|
|
433
|
-
return /* @__PURE__ */
|
|
439
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
434
440
|
style: {
|
|
435
441
|
top: 0,
|
|
436
442
|
display: "flex",
|
|
@@ -443,20 +449,20 @@ function Label({ sponsor }) {
|
|
|
443
449
|
}
|
|
444
450
|
function getLabelBg(sponsor) {
|
|
445
451
|
const height = sponsor.plan === "platinum" ? 32 : 24;
|
|
446
|
-
return /* @__PURE__ */
|
|
452
|
+
return /* @__PURE__ */ React8.createElement("img", {
|
|
447
453
|
src: label_default,
|
|
448
454
|
style: { height, position: "absolute", bottom: 0, zIndex: -1 }
|
|
449
455
|
});
|
|
450
456
|
}
|
|
451
457
|
function getLabelText(sponsor) {
|
|
452
458
|
if (sponsor.plan === "platinum") {
|
|
453
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null);
|
|
454
460
|
}
|
|
455
461
|
let letterSpacing = void 0;
|
|
456
462
|
if (["bronze", "silver", "gold", "indie"].includes(sponsor.plan)) {
|
|
457
463
|
letterSpacing = 1;
|
|
458
464
|
}
|
|
459
|
-
return /* @__PURE__ */
|
|
465
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, " ", /* @__PURE__ */ React8.createElement("span", {
|
|
460
466
|
style: {
|
|
461
467
|
zIndex: 1,
|
|
462
468
|
fontSize: "0.82em",
|
|
@@ -471,12 +477,12 @@ function getLabelText(sponsor) {
|
|
|
471
477
|
function getLabelIcon(sponsor) {
|
|
472
478
|
let medalSrc;
|
|
473
479
|
if (sponsor.plan === "platinum") {
|
|
474
|
-
return /* @__PURE__ */
|
|
480
|
+
return /* @__PURE__ */ React8.createElement(Emoji, {
|
|
475
481
|
name: "trophy",
|
|
476
482
|
style: { fontSize: "1.3em" }
|
|
477
483
|
});
|
|
478
484
|
} else if (sponsor.plan === "indie") {
|
|
479
|
-
return /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ React8.createElement(Emoji, {
|
|
480
486
|
name: "ribbon",
|
|
481
487
|
style: { fontSize: "0.9em" }
|
|
482
488
|
});
|
|
@@ -489,7 +495,7 @@ function getLabelIcon(sponsor) {
|
|
|
489
495
|
} else {
|
|
490
496
|
assert(false);
|
|
491
497
|
}
|
|
492
|
-
return /* @__PURE__ */
|
|
498
|
+
return /* @__PURE__ */ React8.createElement("img", {
|
|
493
499
|
src: medalSrc,
|
|
494
500
|
style: { height: 15, zIndex: 1, marginRight: 5 }
|
|
495
501
|
});
|
|
@@ -517,7 +523,7 @@ function capitalizeFirstLetter(word) {
|
|
|
517
523
|
}
|
|
518
524
|
|
|
519
525
|
// src/components/CodeBlock.tsx
|
|
520
|
-
import
|
|
526
|
+
import React9 from "react";
|
|
521
527
|
function CodeBlock({ children, lineBreak }) {
|
|
522
528
|
assert(lineBreak, "`lineBreak: true` is currently the only use case for <CodeBlock>");
|
|
523
529
|
const style = {};
|
|
@@ -529,13 +535,12 @@ function CodeBlock({ children, lineBreak }) {
|
|
|
529
535
|
paddingRight: "16px !important"
|
|
530
536
|
});
|
|
531
537
|
}
|
|
532
|
-
return /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ React9.createElement("pre", null, /* @__PURE__ */ React9.createElement("code", {
|
|
533
539
|
style
|
|
534
540
|
}, children));
|
|
535
541
|
}
|
|
536
542
|
export {
|
|
537
543
|
CodeBlock,
|
|
538
|
-
DocLink,
|
|
539
544
|
Emoji,
|
|
540
545
|
FeatureList,
|
|
541
546
|
HorizontalLine,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
// src/renderer/_default.page.server.tsx
|
|
23
23
|
import ReactDOMServer from "react-dom/server";
|
|
24
24
|
import React7 from "react";
|
|
25
|
-
import { escapeInject as escapeInject2, dangerouslySkipEscape } from "vite-plugin-ssr";
|
|
25
|
+
import { escapeInject as escapeInject2, dangerouslySkipEscape as dangerouslySkipEscape2 } from "vite-plugin-ssr";
|
|
26
26
|
|
|
27
27
|
// src/PageLayout.tsx
|
|
28
28
|
import React6 from "react";
|
|
@@ -428,11 +428,11 @@ function getConfig() {
|
|
|
428
428
|
function resolvePageContext(pageContext) {
|
|
429
429
|
const config = getConfig();
|
|
430
430
|
const { headings, headingsWithoutLink } = getHeadings(config);
|
|
431
|
-
const activeHeading =
|
|
432
|
-
const headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext,
|
|
431
|
+
const { activeHeading, activeNavigationHeading } = findHeading(headings, headingsWithoutLink, pageContext);
|
|
432
|
+
const headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeNavigationHeading);
|
|
433
433
|
const { title, isLandingPage, pageTitle, isDetachedPage } = getMetaData(
|
|
434
434
|
headingsWithoutLink,
|
|
435
|
-
|
|
435
|
+
activeNavigationHeading,
|
|
436
436
|
pageContext,
|
|
437
437
|
config
|
|
438
438
|
);
|
|
@@ -449,6 +449,7 @@ function resolvePageContext(pageContext) {
|
|
|
449
449
|
tagline,
|
|
450
450
|
algolia
|
|
451
451
|
},
|
|
452
|
+
activeHeading,
|
|
452
453
|
headings,
|
|
453
454
|
headingsWithSubHeadings,
|
|
454
455
|
isLandingPage,
|
|
@@ -458,14 +459,14 @@ function resolvePageContext(pageContext) {
|
|
|
458
459
|
});
|
|
459
460
|
return pageContextResolved;
|
|
460
461
|
}
|
|
461
|
-
function getMetaData(headingsWithoutLink,
|
|
462
|
+
function getMetaData(headingsWithoutLink, activeNavigationHeading, pageContext, config) {
|
|
462
463
|
const url = pageContext.urlOriginal;
|
|
463
464
|
let title;
|
|
464
465
|
let pageTitle;
|
|
465
466
|
let isDetachedPage;
|
|
466
|
-
if (
|
|
467
|
-
title =
|
|
468
|
-
pageTitle =
|
|
467
|
+
if (activeNavigationHeading) {
|
|
468
|
+
title = activeNavigationHeading.titleDocument || jsxToTextContent(activeNavigationHeading.title);
|
|
469
|
+
pageTitle = activeNavigationHeading.title;
|
|
469
470
|
isDetachedPage = false;
|
|
470
471
|
} else {
|
|
471
472
|
pageTitle = headingsWithoutLink.find((h) => h.url === url).title;
|
|
@@ -481,29 +482,34 @@ function getMetaData(headingsWithoutLink, activeHeading, pageContext, config) {
|
|
|
481
482
|
}
|
|
482
483
|
return { title, isLandingPage, pageTitle, isDetachedPage };
|
|
483
484
|
}
|
|
484
|
-
function
|
|
485
|
+
function findHeading(headings, headingsWithoutLink, pageContext) {
|
|
486
|
+
let activeNavigationHeading = null;
|
|
485
487
|
let activeHeading = null;
|
|
486
488
|
assert(pageContext.urlOriginal);
|
|
487
489
|
const pageUrl = pageContext.urlOriginal;
|
|
488
490
|
headings.forEach((heading) => {
|
|
489
491
|
if (heading.url === pageUrl) {
|
|
492
|
+
activeNavigationHeading = heading;
|
|
490
493
|
activeHeading = heading;
|
|
491
494
|
assert(heading.level === 2, { pageUrl, heading });
|
|
492
495
|
}
|
|
493
496
|
});
|
|
497
|
+
if (!activeHeading) {
|
|
498
|
+
activeHeading = headingsWithoutLink.find(({ url }) => pageUrl === url) ?? null;
|
|
499
|
+
}
|
|
494
500
|
const debugInfo = {
|
|
495
501
|
msg: "Heading not found for url: " + pageUrl,
|
|
496
502
|
urls: headings.map((h) => h.url),
|
|
497
503
|
url: pageUrl
|
|
498
504
|
};
|
|
499
|
-
assert(activeHeading
|
|
500
|
-
return activeHeading;
|
|
505
|
+
assert(activeHeading, debugInfo);
|
|
506
|
+
return { activeHeading, activeNavigationHeading };
|
|
501
507
|
}
|
|
502
|
-
function getHeadingsWithSubHeadings(headings, pageContext,
|
|
508
|
+
function getHeadingsWithSubHeadings(headings, pageContext, activeNavigationHeading) {
|
|
503
509
|
const headingsWithSubHeadings = headings.slice();
|
|
504
|
-
if (
|
|
510
|
+
if (activeNavigationHeading === null)
|
|
505
511
|
return headingsWithSubHeadings;
|
|
506
|
-
const activeHeadingIdx = headingsWithSubHeadings.indexOf(
|
|
512
|
+
const activeHeadingIdx = headingsWithSubHeadings.indexOf(activeNavigationHeading);
|
|
507
513
|
assert(activeHeadingIdx >= 0);
|
|
508
514
|
const pageHeadings = pageContext.exports.headings || [];
|
|
509
515
|
pageHeadings.forEach((pageHeading, i) => {
|
|
@@ -517,15 +523,15 @@ function getHeadingsWithSubHeadings(headings, pageContext, activeHeading) {
|
|
|
517
523
|
const heading = {
|
|
518
524
|
url,
|
|
519
525
|
title,
|
|
520
|
-
parentHeadings: [
|
|
526
|
+
parentHeadings: [activeNavigationHeading, ...activeNavigationHeading.parentHeadings],
|
|
521
527
|
titleInNav: title,
|
|
522
528
|
level: 3
|
|
523
529
|
};
|
|
524
530
|
headingsWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, heading);
|
|
525
531
|
}
|
|
526
532
|
});
|
|
527
|
-
if (
|
|
528
|
-
|
|
533
|
+
if (activeNavigationHeading == null ? void 0 : activeNavigationHeading.sectionTitles) {
|
|
534
|
+
activeNavigationHeading.sectionTitles.forEach((sectionTitle) => {
|
|
529
535
|
const pageHeadingTitles = pageHeadings.map((h) => h.title);
|
|
530
536
|
assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle });
|
|
531
537
|
});
|
|
@@ -534,7 +540,7 @@ function getHeadingsWithSubHeadings(headings, pageContext, activeHeading) {
|
|
|
534
540
|
}
|
|
535
541
|
|
|
536
542
|
// src/algolia/DocSearch.ts
|
|
537
|
-
import { escapeInject } from "vite-plugin-ssr";
|
|
543
|
+
import { dangerouslySkipEscape, escapeInject } from "vite-plugin-ssr";
|
|
538
544
|
function getDocSearchCSS(pageContext) {
|
|
539
545
|
const docSearchCSS = !pageContext.meta.algolia ? "" : escapeInject`
|
|
540
546
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" />
|
|
@@ -543,19 +549,19 @@ function getDocSearchCSS(pageContext) {
|
|
|
543
549
|
}
|
|
544
550
|
var _a;
|
|
545
551
|
function getDocSearchJS(pageContext) {
|
|
546
|
-
const docSearchJS = !pageContext.meta.algolia ? "" : escapeInject(_a || (_a = __template(['\n <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"><\/script>\n <script type="text/javascript">\n const transformData = ', ";\n docsearch({\n appId: '", "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-desktop',\n transformData\n });\n docsearch({\n appId: '", "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-mobile',\n transformData\n });\n <\/script>\n "])), getTransformData(), pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName, pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName);
|
|
552
|
+
const docSearchJS = !pageContext.meta.algolia ? "" : escapeInject(_a || (_a = __template(['\n <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"><\/script>\n <script type="text/javascript">\n const transformData = ', ";\n docsearch({\n appId: '", "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-desktop',\n transformData\n });\n docsearch({\n appId: '", "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-mobile',\n transformData\n });\n <\/script>\n "])), dangerouslySkipEscape(getTransformData()), pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName, pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName);
|
|
547
553
|
return docSearchJS;
|
|
548
554
|
}
|
|
549
555
|
function getTransformData() {
|
|
550
556
|
return `function(hits) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
557
|
+
hits.map(hit => {
|
|
558
|
+
if (hit.anchor === 'page-content') {
|
|
559
|
+
hit.url = hit.url.replace('#'+ hit.anchor, '');
|
|
560
|
+
hit.anchor = null;
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
return hits;
|
|
564
|
+
}`;
|
|
559
565
|
}
|
|
560
566
|
|
|
561
567
|
// src/parseEmojis.ts
|
|
@@ -589,7 +595,7 @@ async function render(pageContextOriginal) {
|
|
|
589
595
|
const page = /* @__PURE__ */ React7.createElement(PageLayout, {
|
|
590
596
|
pageContext: pageContextResolved
|
|
591
597
|
}, /* @__PURE__ */ React7.createElement(Page, null));
|
|
592
|
-
const descriptionTag = pageContextResolved.isLandingPage ?
|
|
598
|
+
const descriptionTag = pageContextResolved.isLandingPage ? dangerouslySkipEscape2(`<meta name="description" content="${pageContextResolved.meta.tagline}" />`) : "";
|
|
593
599
|
const docSearchJS = getDocSearchJS(pageContextResolved);
|
|
594
600
|
const docSearchCSS = getDocSearchCSS(pageContextResolved);
|
|
595
601
|
let pageHtml = ReactDOMServer.renderToString(page);
|
|
@@ -606,7 +612,7 @@ async function render(pageContextOriginal) {
|
|
|
606
612
|
${getOpenGraphTags(pageContextOriginal.urlPathname, pageContextResolved.meta)}
|
|
607
613
|
</head>
|
|
608
614
|
<body>
|
|
609
|
-
<div id="page-view">${
|
|
615
|
+
<div id="page-view">${dangerouslySkipEscape2(pageHtml)}</div>
|
|
610
616
|
${docSearchJS}
|
|
611
617
|
</body>
|
|
612
618
|
</html>`;
|
package/package.json
CHANGED