@brillout/docpress 0.3.13 → 0.4.1
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/{chunk-IZDN24FQ.js → chunk-H7GTGR6A.js} +10 -7
- package/dist/cli/index.js +1 -1
- package/dist/{devServer-OXABOEEC.js → devServer-KXRA4OLE.js} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +38 -7
- package/dist/renderer/_default.page.client.js +17 -15
- package/dist/renderer/_default.page.server.css +13 -10
- package/dist/renderer/_default.page.server.d.ts +3 -3
- package/dist/renderer/_default.page.server.js +69 -50
- package/package.json +2 -2
|
@@ -74,20 +74,23 @@ function getHeadings(config) {
|
|
|
74
74
|
const parentHeadings = findParentHeadings(heading, headings);
|
|
75
75
|
headings.push({ ...heading, parentHeadings });
|
|
76
76
|
});
|
|
77
|
-
const
|
|
78
|
-
const { url, title } =
|
|
77
|
+
const headingsDetached = config.headingsDetached.map((headingsDetached2) => {
|
|
78
|
+
const { url, title } = headingsDetached2;
|
|
79
79
|
assert(
|
|
80
80
|
headings.find((heading) => heading.url === url) === void 0,
|
|
81
|
-
`remove ${
|
|
81
|
+
`remove ${headingsDetached2.url} from headingsDetached`
|
|
82
82
|
);
|
|
83
83
|
const titleProcessed = typeof title === "string" ? parseTitle(title) : title;
|
|
84
84
|
return {
|
|
85
|
-
...
|
|
86
|
-
|
|
85
|
+
...headingsDetached2,
|
|
86
|
+
level: 2,
|
|
87
|
+
title: titleProcessed,
|
|
88
|
+
titleInNav: titleProcessed,
|
|
89
|
+
parentHeadings: null
|
|
87
90
|
};
|
|
88
91
|
});
|
|
89
|
-
assertHeadingsUrl([...headings, ...
|
|
90
|
-
return { headings,
|
|
92
|
+
assertHeadingsUrl([...headings, ...headingsDetached]);
|
|
93
|
+
return { headings, headingsDetached };
|
|
91
94
|
}
|
|
92
95
|
function findParentHeadings(heading, headings) {
|
|
93
96
|
const parentHeadings = [];
|
package/dist/cli/index.js
CHANGED
|
@@ -16,7 +16,7 @@ Error.stackTraceLimit = Infinity;
|
|
|
16
16
|
cli();
|
|
17
17
|
async function cli() {
|
|
18
18
|
if (isDev) {
|
|
19
|
-
await import("../devServer-
|
|
19
|
+
await import("../devServer-KXRA4OLE.js");
|
|
20
20
|
} else if (isBuild) {
|
|
21
21
|
await build(vite_config_default);
|
|
22
22
|
await build({ ...vite_config_default, build: { ssr: true } });
|
|
@@ -8,7 +8,7 @@ import "./chunk-3QC7HYIF.js";
|
|
|
8
8
|
// src/cli/devServer.ts
|
|
9
9
|
import express from "express";
|
|
10
10
|
import * as vite from "vite";
|
|
11
|
-
import { renderPage } from "vite-plugin-ssr";
|
|
11
|
+
import { renderPage } from "vite-plugin-ssr/server";
|
|
12
12
|
var viteVersion = vite.version || "2.?.?";
|
|
13
13
|
startServer();
|
|
14
14
|
async function startServer() {
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare function Emoji({ name, style }: {
|
|
|
24
24
|
style?: React$1.CSSProperties;
|
|
25
25
|
}): JSX.Element;
|
|
26
26
|
|
|
27
|
-
type
|
|
27
|
+
type HeadingDetachedDefinition = {
|
|
28
28
|
url: string;
|
|
29
29
|
title: string | JSX.Element;
|
|
30
30
|
};
|
|
@@ -72,7 +72,7 @@ type Config = {
|
|
|
72
72
|
indexName: string;
|
|
73
73
|
};
|
|
74
74
|
headings: HeadingDefinition[];
|
|
75
|
-
|
|
75
|
+
headingsDetached: HeadingDetachedDefinition[];
|
|
76
76
|
navHeaderMobile: React.ReactNode;
|
|
77
77
|
navHeader: React.ReactNode;
|
|
78
78
|
titleNormalCase: boolean;
|
|
@@ -146,4 +146,4 @@ declare function CodeBlock({ children, lineBreak }: {
|
|
|
146
146
|
lineBreak?: true;
|
|
147
147
|
}): JSX.Element;
|
|
148
148
|
|
|
149
|
-
export { CodeBlock, Config, Emoji, EmojiName, HeadingDefinition,
|
|
149
|
+
export { CodeBlock, Config, Emoji, EmojiName, HeadingDefinition, HeadingDetachedDefinition, 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
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isRepoLink,
|
|
5
5
|
parseTitle,
|
|
6
6
|
usePageContext
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-H7GTGR6A.js";
|
|
8
8
|
import {
|
|
9
9
|
FeatureList
|
|
10
10
|
} from "./chunk-NVJING6T.js";
|
|
@@ -76,9 +76,9 @@ function getTitle({
|
|
|
76
76
|
assert(heading);
|
|
77
77
|
assert(heading === pageContext.activeHeading || !linkIsOnSamePage);
|
|
78
78
|
const breadcrumbs = [];
|
|
79
|
-
if (
|
|
79
|
+
if (heading.parentHeadings) {
|
|
80
80
|
breadcrumbs.push(
|
|
81
|
-
...heading.parentHeadings.slice().reverse().map(({ title }) => title)
|
|
81
|
+
...(heading.parentHeadings ?? []).slice().reverse().map(({ title }) => title)
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
breadcrumbs.push(heading.title);
|
|
@@ -114,9 +114,9 @@ function getTitle({
|
|
|
114
114
|
}
|
|
115
115
|
function findHeading(href, pageContext) {
|
|
116
116
|
assert(href.startsWith("/"), `\`href==='${href}'\` but should start with \`/\`.`);
|
|
117
|
-
const { headings,
|
|
117
|
+
const { headings, headingsDetached } = getHeadings(pageContext.config);
|
|
118
118
|
{
|
|
119
|
-
const heading2 =
|
|
119
|
+
const heading2 = headingsDetached.find(({ url }) => href === url);
|
|
120
120
|
if (heading2) {
|
|
121
121
|
return heading2;
|
|
122
122
|
}
|
|
@@ -267,6 +267,27 @@ var inlang_default = "/assets/inlang-GFRWND6X.png";
|
|
|
267
267
|
|
|
268
268
|
// src/components/Sponsors/sponsorsList.ts
|
|
269
269
|
var individuals = [
|
|
270
|
+
{
|
|
271
|
+
username: "fortezhuo"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
username: "nshelia"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
username: "marcusway"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
username: "edikdeisling"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
username: "AurelienLourot"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
username: "jahredhope"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
username: "charlieforward9"
|
|
290
|
+
},
|
|
270
291
|
{
|
|
271
292
|
username: "leonmondria"
|
|
272
293
|
},
|
|
@@ -282,6 +303,9 @@ var individuals = [
|
|
|
282
303
|
{
|
|
283
304
|
username: "ser1us"
|
|
284
305
|
},
|
|
306
|
+
{
|
|
307
|
+
username: "nikitavoloboev"
|
|
308
|
+
},
|
|
285
309
|
{
|
|
286
310
|
username: "samuelstroschein"
|
|
287
311
|
},
|
|
@@ -402,7 +426,14 @@ function Sponsors() {
|
|
|
402
426
|
sponsor,
|
|
403
427
|
key: i
|
|
404
428
|
}))), /* @__PURE__ */ React8.createElement("div", {
|
|
405
|
-
style: {
|
|
429
|
+
style: {
|
|
430
|
+
display: "flex",
|
|
431
|
+
flexWrap: "wrap",
|
|
432
|
+
justifyContent: "center",
|
|
433
|
+
alignItems: "end",
|
|
434
|
+
margin: "17px auto",
|
|
435
|
+
maxWidth: 700
|
|
436
|
+
}
|
|
406
437
|
}, sponsorsIndividuals.map((sponsor, i) => /* @__PURE__ */ React8.createElement(SponsorDiv, {
|
|
407
438
|
sponsor,
|
|
408
439
|
key: i
|
|
@@ -425,7 +456,7 @@ function SponsorDiv({ sponsor }) {
|
|
|
425
456
|
width = 30;
|
|
426
457
|
height = 30;
|
|
427
458
|
padding = 0;
|
|
428
|
-
marginHeight =
|
|
459
|
+
marginHeight = 5;
|
|
429
460
|
marginWidth = 5;
|
|
430
461
|
backgroundColor = "none";
|
|
431
462
|
} else {
|
|
@@ -6,7 +6,7 @@ import "../chunk-3QC7HYIF.js";
|
|
|
6
6
|
// src/autoScrollNav.ts
|
|
7
7
|
autoScrollNav();
|
|
8
8
|
function autoScrollNav() {
|
|
9
|
-
const navigationEl = document.getElementById("navigation-content");
|
|
9
|
+
const navigationEl = document.getElementById("navigation-content-main");
|
|
10
10
|
assert(navigationEl);
|
|
11
11
|
const href = window.location.pathname;
|
|
12
12
|
const navLinks = Array.from(navigationEl.querySelectorAll(`a[href="${href}"]`));
|
|
@@ -29,18 +29,20 @@ function installSectionUrlHashs() {
|
|
|
29
29
|
assert(window.location.pathname === "/");
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
assert(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
const navigationsEl = Array.from(document.querySelectorAll(".navigation-content"));
|
|
33
|
+
assert(navigationsEl.length > 0);
|
|
34
|
+
navigationsEl.forEach((navigationEl) => {
|
|
35
|
+
const docSections = Array.from(document.querySelectorAll("h2"));
|
|
36
|
+
docSections.forEach((docSection) => {
|
|
37
|
+
if (!docSection.id)
|
|
38
|
+
return;
|
|
39
|
+
const urlHash = "#" + docSection.id;
|
|
40
|
+
assertNavLink(navigationEl, urlHash);
|
|
41
|
+
docSection.onclick = () => {
|
|
42
|
+
window.location.hash = urlHash;
|
|
43
|
+
jumpToSection();
|
|
44
|
+
};
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
function assertNavLink(navigationEl, urlHash) {
|
|
@@ -93,7 +95,7 @@ function toggleNavExpend() {
|
|
|
93
95
|
}
|
|
94
96
|
function updateColumnWidth() {
|
|
95
97
|
const navMinWidth = 299;
|
|
96
|
-
const navH1Groups = Array.from(document.querySelectorAll(".nav-h1-group"));
|
|
98
|
+
const navH1Groups = Array.from(document.querySelectorAll("#navigation-content-main .nav-h1-group"));
|
|
97
99
|
const numberOfColumnsMax = navH1Groups.length;
|
|
98
100
|
const widthAvailable = getViewportWidth();
|
|
99
101
|
const numberOfColumns = Math.max(1, Math.min(numberOfColumnsMax, Math.floor(widthAvailable / navMinWidth)));
|
|
@@ -107,7 +109,7 @@ function updateColumnWidth() {
|
|
|
107
109
|
return column;
|
|
108
110
|
});
|
|
109
111
|
mergeColumns(columns, numberOfColumns);
|
|
110
|
-
const navContent = document.getElementById("navigation-content");
|
|
112
|
+
const navContent = document.getElementById("navigation-content-main");
|
|
111
113
|
Array.from(navContent.children).forEach((child) => {
|
|
112
114
|
assert(child.className === "nav-column");
|
|
113
115
|
});
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
overflow-y: auto;
|
|
19
19
|
overscroll-behavior: contain;
|
|
20
20
|
border-right: 1px solid #eee;
|
|
21
|
+
--background-color: #f0f0f0;
|
|
22
|
+
padding-bottom: 70px;
|
|
23
|
+
}
|
|
24
|
+
.navigation-content {
|
|
25
|
+
margin-top: 20px;
|
|
26
|
+
}
|
|
27
|
+
#navigation-content-detached {
|
|
28
|
+
margin-top: 25px;
|
|
21
29
|
}
|
|
22
30
|
#navigation-mask {
|
|
23
31
|
position: fixed;
|
|
@@ -92,14 +100,16 @@ html.navigation-fullscreen #navigation-container {
|
|
|
92
100
|
left: 0;
|
|
93
101
|
background-color: white;
|
|
94
102
|
}
|
|
95
|
-
html.navigation-fullscreen #navigation-header
|
|
103
|
+
html.navigation-fullscreen #navigation-header,
|
|
104
|
+
html.navigation-fullscreen #navigation-content-detached,
|
|
105
|
+
html.navigation-fullscreen #detached-note {
|
|
96
106
|
display: none !important;
|
|
97
107
|
}
|
|
98
|
-
html.navigation-fullscreen
|
|
108
|
+
html.navigation-fullscreen .navigation-content {
|
|
99
109
|
display: flex;
|
|
100
110
|
margin: auto;
|
|
101
111
|
}
|
|
102
|
-
html.navigation-fullscreen
|
|
112
|
+
html.navigation-fullscreen .navigation-content > .nav-column {
|
|
103
113
|
flex-grow: 1;
|
|
104
114
|
max-width: 350px;
|
|
105
115
|
}
|
|
@@ -231,13 +241,6 @@ html.navigation-fullscreen .nav-item {
|
|
|
231
241
|
/* src/navigation/Navigation-highlight.css */
|
|
232
242
|
|
|
233
243
|
/* src/navigation/Navigation.css */
|
|
234
|
-
#navigation-container {
|
|
235
|
-
--background-color: #f0f0f0;
|
|
236
|
-
padding-bottom: 70px;
|
|
237
|
-
}
|
|
238
|
-
html.navigation-fullscreen #detached-note {
|
|
239
|
-
display: none;
|
|
240
|
-
}
|
|
241
244
|
|
|
242
245
|
/* src/navigation/navigation-fullscreen/NavigationFullscreenButton.css */
|
|
243
246
|
:root {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PageContextBuiltIn } from 'vite-plugin-ssr';
|
|
1
|
+
import * as vite_plugin_ssr_dist_cjs_node_runtime_html_renderHtml from 'vite-plugin-ssr/dist/cjs/node/runtime/html/renderHtml';
|
|
2
|
+
import { PageContextBuiltIn } from 'vite-plugin-ssr/types';
|
|
3
3
|
|
|
4
4
|
type MarkdownHeading = {
|
|
5
5
|
title: string;
|
|
@@ -17,6 +17,6 @@ type PageContextOriginal = PageContextBuiltIn & {
|
|
|
17
17
|
exports: Exports;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
declare function render(pageContextOriginal: PageContextOriginal): Promise<
|
|
20
|
+
declare function render(pageContextOriginal: PageContextOriginal): Promise<vite_plugin_ssr_dist_cjs_node_runtime_html_renderHtml.TemplateWrapped>;
|
|
21
21
|
|
|
22
22
|
export { render };
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getHeadings,
|
|
5
5
|
parseTitle,
|
|
6
6
|
usePageContext
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-H7GTGR6A.js";
|
|
8
8
|
import {
|
|
9
9
|
Emoji,
|
|
10
10
|
jsxToTextContent,
|
|
@@ -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 as dangerouslySkipEscape2 } from "vite-plugin-ssr";
|
|
25
|
+
import { escapeInject as escapeInject2, dangerouslySkipEscape as dangerouslySkipEscape2 } from "vite-plugin-ssr/server";
|
|
26
26
|
|
|
27
27
|
// src/PageLayout.tsx
|
|
28
28
|
import React6 from "react";
|
|
@@ -184,11 +184,17 @@ function NavigationFullscreenClose() {
|
|
|
184
184
|
function Navigation({
|
|
185
185
|
pageContext
|
|
186
186
|
}) {
|
|
187
|
-
const
|
|
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),
|
|
191
|
-
|
|
190
|
+
}, /* @__PURE__ */ React3.createElement(NavigationHeader, null), pageContext.detachedPageHeadings && /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(NavigationContent, {
|
|
191
|
+
id: "navigation-content-detached",
|
|
192
|
+
headings: pageContext.detachedPageHeadings,
|
|
193
|
+
currentUrl
|
|
194
|
+
}), /* @__PURE__ */ React3.createElement(DetachedPageNote, null)), /* @__PURE__ */ React3.createElement(NavigationContent, {
|
|
195
|
+
id: "navigation-content-main",
|
|
196
|
+
headings: pageContext.headingsWithSubHeadings,
|
|
197
|
+
currentUrl
|
|
192
198
|
}), /* @__PURE__ */ React3.createElement(NavigationFullscreenClose, null)));
|
|
193
199
|
}
|
|
194
200
|
function NavigationMask() {
|
|
@@ -196,13 +202,12 @@ function NavigationMask() {
|
|
|
196
202
|
id: "navigation-mask"
|
|
197
203
|
});
|
|
198
204
|
}
|
|
199
|
-
function NavigationContent({
|
|
200
|
-
|
|
201
|
-
}) {
|
|
202
|
-
const headings = getHeadingsWithComputedProps(pageContext);
|
|
205
|
+
function NavigationContent(props) {
|
|
206
|
+
const headings = getHeadingsWithComputedProps(props.headings, props.currentUrl);
|
|
203
207
|
const headingsGrouped = groupHeadings(headings);
|
|
204
208
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
205
|
-
id:
|
|
209
|
+
id: props.id,
|
|
210
|
+
className: "navigation-content"
|
|
206
211
|
}, /* @__PURE__ */ React3.createElement("div", {
|
|
207
212
|
className: "nav-column",
|
|
208
213
|
style: { position: "relative" }
|
|
@@ -247,8 +252,9 @@ function Heading({
|
|
|
247
252
|
}
|
|
248
253
|
function groupHeadings(headings) {
|
|
249
254
|
const headingsGrouped = [];
|
|
255
|
+
const headingLevelMin = Math.min(...headings.map((h) => h.level));
|
|
250
256
|
headings.forEach((heading) => {
|
|
251
|
-
if (heading.level ===
|
|
257
|
+
if (heading.level === headingLevelMin) {
|
|
252
258
|
headingsGrouped.push({ ...heading, headings: [] });
|
|
253
259
|
} else {
|
|
254
260
|
headingsGrouped[headingsGrouped.length - 1].headings.push(heading);
|
|
@@ -256,18 +262,17 @@ function groupHeadings(headings) {
|
|
|
256
262
|
});
|
|
257
263
|
return headingsGrouped;
|
|
258
264
|
}
|
|
259
|
-
function getHeadingsWithComputedProps(
|
|
260
|
-
|
|
261
|
-
return headingsWithSubHeadings.map((heading, i) => {
|
|
265
|
+
function getHeadingsWithComputedProps(headings, currentUrl) {
|
|
266
|
+
return headings.map((heading, i) => {
|
|
262
267
|
var _a2;
|
|
263
268
|
assert([1, 2, 3, 4].includes(heading.level), heading);
|
|
264
|
-
const headingPrevious =
|
|
265
|
-
const headingNext =
|
|
269
|
+
const headingPrevious = headings[i - 1];
|
|
270
|
+
const headingNext = headings[i + 1];
|
|
266
271
|
let isActiveFirst = false;
|
|
267
272
|
let isActiveLast = false;
|
|
268
273
|
let isActive = false;
|
|
269
|
-
if (heading.url ===
|
|
270
|
-
assert(heading.level === 2, {
|
|
274
|
+
if (heading.url === currentUrl) {
|
|
275
|
+
assert(heading.level === 2, { currentUrl });
|
|
271
276
|
isActive = true;
|
|
272
277
|
isActiveFirst = true;
|
|
273
278
|
if ((headingNext == null ? void 0 : headingNext.level) !== 3) {
|
|
@@ -282,7 +287,7 @@ function getHeadingsWithComputedProps(pageContext) {
|
|
|
282
287
|
}
|
|
283
288
|
const isFirstOfItsKind = heading.level !== (headingPrevious == null ? void 0 : headingPrevious.level);
|
|
284
289
|
const isLastOfItsKind = heading.level !== (headingNext == null ? void 0 : headingNext.level);
|
|
285
|
-
const isChildOfListHeading = !!((_a2 = heading.parentHeadings[0]) == null ? void 0 : _a2.isListTitle);
|
|
290
|
+
const isChildOfListHeading = !!heading.parentHeadings && !!((_a2 = heading.parentHeadings[0]) == null ? void 0 : _a2.isListTitle);
|
|
286
291
|
return {
|
|
287
292
|
...heading,
|
|
288
293
|
computed: {
|
|
@@ -304,8 +309,8 @@ function DetachedPageNote() {
|
|
|
304
309
|
textAlign: "left",
|
|
305
310
|
marginLeft: 10,
|
|
306
311
|
marginRight: 10,
|
|
307
|
-
marginTop:
|
|
308
|
-
marginBottom: -
|
|
312
|
+
marginTop: 25,
|
|
313
|
+
marginBottom: -5,
|
|
309
314
|
borderRadius: 5,
|
|
310
315
|
padding: 10
|
|
311
316
|
}
|
|
@@ -427,11 +432,19 @@ function getConfig() {
|
|
|
427
432
|
// src/config/resolvePageContext.ts
|
|
428
433
|
function resolvePageContext(pageContext) {
|
|
429
434
|
const config = getConfig();
|
|
430
|
-
const { headings,
|
|
431
|
-
const { activeHeading, activeNavigationHeading } = findHeading(headings,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
const { headings, headingsDetached } = getHeadings(config);
|
|
436
|
+
const { activeHeading, activeNavigationHeading } = findHeading(headings, headingsDetached, pageContext);
|
|
437
|
+
let headingsWithSubHeadings;
|
|
438
|
+
let detachedPageHeadings;
|
|
439
|
+
if (activeNavigationHeading) {
|
|
440
|
+
detachedPageHeadings = null;
|
|
441
|
+
headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeNavigationHeading);
|
|
442
|
+
} else {
|
|
443
|
+
detachedPageHeadings = [activeHeading, ...getPageHeadings(pageContext, activeHeading)];
|
|
444
|
+
headingsWithSubHeadings = headings;
|
|
445
|
+
}
|
|
446
|
+
const { title, isLandingPage, pageTitle } = getMetaData(
|
|
447
|
+
headingsDetached,
|
|
435
448
|
activeNavigationHeading,
|
|
436
449
|
pageContext,
|
|
437
450
|
config
|
|
@@ -452,26 +465,23 @@ function resolvePageContext(pageContext) {
|
|
|
452
465
|
activeHeading,
|
|
453
466
|
headings,
|
|
454
467
|
headingsWithSubHeadings,
|
|
468
|
+
detachedPageHeadings,
|
|
455
469
|
isLandingPage,
|
|
456
|
-
isDetachedPage,
|
|
457
470
|
pageTitle,
|
|
458
471
|
config
|
|
459
472
|
});
|
|
460
473
|
return pageContextResolved;
|
|
461
474
|
}
|
|
462
|
-
function getMetaData(
|
|
475
|
+
function getMetaData(headingsDetached, activeNavigationHeading, pageContext, config) {
|
|
463
476
|
const url = pageContext.urlOriginal;
|
|
464
477
|
let title;
|
|
465
478
|
let pageTitle;
|
|
466
|
-
let isDetachedPage;
|
|
467
479
|
if (activeNavigationHeading) {
|
|
468
480
|
title = activeNavigationHeading.titleDocument || jsxToTextContent(activeNavigationHeading.title);
|
|
469
481
|
pageTitle = activeNavigationHeading.title;
|
|
470
|
-
isDetachedPage = false;
|
|
471
482
|
} else {
|
|
472
|
-
pageTitle =
|
|
483
|
+
pageTitle = headingsDetached.find((h) => h.url === url).title;
|
|
473
484
|
title = jsxToTextContent(pageTitle);
|
|
474
|
-
isDetachedPage = true;
|
|
475
485
|
}
|
|
476
486
|
const isLandingPage = url === "/";
|
|
477
487
|
if (!isLandingPage) {
|
|
@@ -480,9 +490,9 @@ function getMetaData(headingsWithoutLink, activeNavigationHeading, pageContext,
|
|
|
480
490
|
if (isLandingPage) {
|
|
481
491
|
pageTitle = null;
|
|
482
492
|
}
|
|
483
|
-
return { title, isLandingPage, pageTitle
|
|
493
|
+
return { title, isLandingPage, pageTitle };
|
|
484
494
|
}
|
|
485
|
-
function findHeading(headings,
|
|
495
|
+
function findHeading(headings, headingsDetached, pageContext) {
|
|
486
496
|
let activeNavigationHeading = null;
|
|
487
497
|
let activeHeading = null;
|
|
488
498
|
assert(pageContext.urlOriginal);
|
|
@@ -495,7 +505,7 @@ function findHeading(headings, headingsWithoutLink, pageContext) {
|
|
|
495
505
|
}
|
|
496
506
|
});
|
|
497
507
|
if (!activeHeading) {
|
|
498
|
-
activeHeading =
|
|
508
|
+
activeHeading = headingsDetached.find(({ url }) => pageUrl === url) ?? null;
|
|
499
509
|
}
|
|
500
510
|
const debugInfo = {
|
|
501
511
|
msg: "Heading not found for url: " + pageUrl,
|
|
@@ -509,38 +519,47 @@ function getHeadingsWithSubHeadings(headings, pageContext, activeNavigationHeadi
|
|
|
509
519
|
const headingsWithSubHeadings = headings.slice();
|
|
510
520
|
if (activeNavigationHeading === null)
|
|
511
521
|
return headingsWithSubHeadings;
|
|
522
|
+
const pageHeadings = getPageHeadings(pageContext, activeNavigationHeading);
|
|
512
523
|
const activeHeadingIdx = headingsWithSubHeadings.indexOf(activeNavigationHeading);
|
|
513
524
|
assert(activeHeadingIdx >= 0);
|
|
514
|
-
const pageHeadings = pageContext.exports.headings || [];
|
|
515
525
|
pageHeadings.forEach((pageHeading, i) => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
526
|
+
headingsWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, pageHeading);
|
|
527
|
+
});
|
|
528
|
+
return headingsWithSubHeadings;
|
|
529
|
+
}
|
|
530
|
+
function getPageHeadings(pageContext, currentHeading) {
|
|
531
|
+
const pageHeadings = [];
|
|
532
|
+
const markdownHeadings = pageContext.exports.headings ?? [];
|
|
533
|
+
markdownHeadings.forEach((markdownHeading) => {
|
|
534
|
+
const title = parseTitle(markdownHeading.title);
|
|
535
|
+
const url = markdownHeading.headingId && "#" + markdownHeading.headingId;
|
|
536
|
+
if (markdownHeading.headingLevel === 3) {
|
|
537
|
+
console.warn(
|
|
538
|
+
"Wrong page heading level `" + markdownHeading.headingLevel + "` (it should be `<h2>`) for sub-heading `" + markdownHeading.title + "` of page `" + pageContext.urlOriginal + "`."
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
if (markdownHeading.headingLevel === 2) {
|
|
523
542
|
const heading = {
|
|
524
543
|
url,
|
|
525
544
|
title,
|
|
526
|
-
parentHeadings: [
|
|
545
|
+
parentHeadings: [currentHeading, ...currentHeading.parentHeadings ?? []],
|
|
527
546
|
titleInNav: title,
|
|
528
547
|
level: 3
|
|
529
548
|
};
|
|
530
|
-
|
|
549
|
+
pageHeadings.push(heading);
|
|
531
550
|
}
|
|
532
551
|
});
|
|
533
|
-
if (
|
|
534
|
-
|
|
535
|
-
const pageHeadingTitles =
|
|
552
|
+
if (currentHeading == null ? void 0 : currentHeading.sectionTitles) {
|
|
553
|
+
currentHeading.sectionTitles.forEach((sectionTitle) => {
|
|
554
|
+
const pageHeadingTitles = markdownHeadings.map((h) => h.title);
|
|
536
555
|
assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle });
|
|
537
556
|
});
|
|
538
557
|
}
|
|
539
|
-
return
|
|
558
|
+
return pageHeadings;
|
|
540
559
|
}
|
|
541
560
|
|
|
542
561
|
// src/algolia/DocSearch.ts
|
|
543
|
-
import { dangerouslySkipEscape, escapeInject } from "vite-plugin-ssr";
|
|
562
|
+
import { dangerouslySkipEscape, escapeInject } from "vite-plugin-ssr/server";
|
|
544
563
|
function getDocSearchCSS(pageContext) {
|
|
545
564
|
const docSearchCSS = !pageContext.meta.algolia ? "" : escapeInject`
|
|
546
565
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/docpress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"// Check types while developing": "",
|
|
6
6
|
"types": "tsc --noEmit --watch",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"shiki": "^0.10.1",
|
|
25
25
|
"twemoji": "^13.1.0",
|
|
26
26
|
"vite": "npm:@brillout/vite@4.0.1-fix",
|
|
27
|
-
"vite-plugin-ssr": "^0.4.
|
|
27
|
+
"vite-plugin-ssr": "^0.4.110"
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
30
30
|
"exports": {
|