@brillout/docpress 0.1.14 → 0.1.15

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.
Files changed (143) hide show
  1. package/dist/{chunk-GBXQT242.js → chunk-J7PKG3ZA.js} +38 -13
  2. package/dist/chunk-J7PKG3ZA.js.map +1 -0
  3. package/dist/{devServer-CXZI7V2M.js → devServer-RUTLBMIJ.js} +2 -5
  4. package/dist/{devServer-CXZI7V2M.js.map → devServer-RUTLBMIJ.js.map} +1 -1
  5. package/dist/index.d.ts +0 -136
  6. package/dist/index.js +27 -484
  7. package/dist/index.js.map +1 -1
  8. package/package.json +8 -11
  9. package/src/MobileHeader.tsx +68 -0
  10. package/src/PageLayout.css +41 -0
  11. package/src/PageLayout.tsx +37 -0
  12. package/src/algolia/DocSearch.css +29 -0
  13. package/src/algolia/DocSearch.ts +37 -0
  14. package/src/autoScrollNav.ts +22 -0
  15. package/src/cli/devServer.ts +31 -0
  16. package/src/cli/index.ts +29 -0
  17. package/src/components/CodeBlock.tsx +22 -0
  18. package/src/components/DocLink.tsx +108 -0
  19. package/src/components/EditPageNote.tsx +18 -0
  20. package/src/components/HorizontalLine.tsx +20 -0
  21. package/src/components/ImportMeta.tsx +11 -0
  22. package/src/components/Info.tsx +12 -0
  23. package/src/components/Link.tsx +18 -0
  24. package/src/components/Note.tsx +31 -0
  25. package/src/components/P.css +8 -0
  26. package/src/components/P.tsx +8 -0
  27. package/src/components/ReadingRecommendation.tsx +53 -0
  28. package/src/components/RepoLink.tsx +24 -0
  29. package/src/components/Sponsors/companyLogos/ccoli-logo.svg +1 -0
  30. package/src/components/Sponsors/companyLogos/ccoli-text.svg +1 -0
  31. package/{dist/ccoli-CHW3TQKS.svg → src/components/Sponsors/companyLogos/ccoli.svg} +0 -0
  32. package/{dist/contra-WLZBOPBV.svg → src/components/Sponsors/companyLogos/contra.svg} +0 -0
  33. package/{dist/mfqs-2EAEE7N6.svg → src/components/Sponsors/companyLogos/mfqs.svg} +0 -0
  34. package/src/components/Sponsors/label.draft.svg +108 -0
  35. package/{dist/label-MP75CTIA.svg → src/components/Sponsors/label.svg} +0 -0
  36. package/{dist/medalBronze-CO4CTUR4.svg → src/components/Sponsors/medalBronze.svg} +0 -0
  37. package/{dist/medalGold-UP6A73FL.svg → src/components/Sponsors/medalGold.svg} +0 -0
  38. package/{dist/medalSilver-FAPGGOBN.svg → src/components/Sponsors/medalSilver.svg} +0 -0
  39. package/src/components/Sponsors.tsx +242 -0
  40. package/{dist → src}/components/features/FeatureList.css +7 -2
  41. package/src/components/features/FeatureList.tsx +114 -0
  42. package/{dist/chevron-R2IYJD62.svg → src/components/features/chevron.svg} +0 -0
  43. package/src/components/features/initFeatureList.ts +66 -0
  44. package/src/components/index.ts +13 -0
  45. package/src/config/Config.ts +30 -0
  46. package/src/config/getConfig.ts +18 -0
  47. package/src/config/resolveConfig/resolveHeading.ts +0 -0
  48. package/src/config/resolvePageContext.ts +157 -0
  49. package/{dist/Inter-Var-IOAEQULN.ttf → src/css/Inter-Var.ttf} +0 -0
  50. package/src/css/button.css +7 -0
  51. package/src/css/code/block.css +36 -0
  52. package/src/css/code/inline.css +27 -0
  53. package/src/css/code.css +20 -0
  54. package/src/css/colorize-on-hover.css +29 -0
  55. package/src/css/font.css +19 -0
  56. package/src/css/heading.css +25 -0
  57. package/src/css/index.css +11 -0
  58. package/src/css/link.css +17 -0
  59. package/src/css/note.css +26 -0
  60. package/src/css/reset.css +12 -0
  61. package/src/css/table.css +14 -0
  62. package/src/css/tooltip.css +11 -0
  63. package/src/headings.ts +200 -0
  64. package/{dist/changelog-IPI5F42D.svg → src/icons/changelog.svg} +0 -0
  65. package/{dist/discord-JD33TUSF.svg → src/icons/discord.svg} +0 -0
  66. package/{dist/github-P5ZSKN2N.svg → src/icons/github.svg} +0 -0
  67. package/{dist/heart-OINVKOXO.svg → src/icons/heart.svg} +0 -0
  68. package/{dist/twitter-I7DXDN3J.svg → src/icons/twitter.svg} +0 -0
  69. package/src/index.ts +3 -0
  70. package/src/installSectionUrlHashs.ts +50 -0
  71. package/src/markdownHeadingsVitePlugin.ts +128 -0
  72. package/src/navigation/Navigation-highlight.css +41 -0
  73. package/src/navigation/Navigation-items.css +122 -0
  74. package/src/navigation/Navigation-layout.css +118 -0
  75. package/src/navigation/Navigation.client.old.ts +303 -0
  76. package/src/navigation/Navigation.client.ts +19 -0
  77. package/src/navigation/Navigation.css +12 -0
  78. package/src/navigation/Navigation.tsx +228 -0
  79. package/src/navigation/NavigationHeader.tsx +97 -0
  80. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
  81. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
  82. package/{dist/chevron-K3WPYLOP.svg → src/navigation/navigation-fullscreen/chevron.svg} +0 -0
  83. package/{dist/close-IQXTDOHV.svg → src/navigation/navigation-fullscreen/close.svg} +0 -0
  84. package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +115 -0
  85. package/src/parseEmojis.ts +33 -0
  86. package/src/renderer/_default.page.client.ts +4 -0
  87. package/src/renderer/_default.page.server.tsx +69 -0
  88. package/src/renderer/usePageContext.tsx +25 -0
  89. package/src/types.ts +2 -0
  90. package/src/utils/Emoji/Emoji.ts +216 -0
  91. package/src/utils/Emoji/assets.ts +9 -0
  92. package/{dist/compass-2RWQU3E4.svg → src/utils/Emoji/compass.svg} +0 -0
  93. package/{dist/engine-6Q6VSCVA.png → src/utils/Emoji/engine.png} +0 -0
  94. package/src/utils/Emoji/index.ts +1 -0
  95. package/{dist/mechanical-arm-TR7IQQMG.svg → src/utils/Emoji/mechanical-arm.svg} +0 -0
  96. package/src/utils/Emoji/mountain.svg +1 -0
  97. package/{dist/road-fork-3WZLW3HB.svg → src/utils/Emoji/road-fork.svg} +0 -0
  98. package/{dist/shield-CU45RG5C.svg → src/utils/Emoji/shield.svg} +0 -0
  99. package/{dist/typescript-ALIPKLRM.svg → src/utils/Emoji/typescript.svg} +0 -0
  100. package/src/utils/assert.ts +39 -0
  101. package/src/utils/client.ts +2 -0
  102. package/src/utils/crawlAllFiles.ts +17 -0
  103. package/src/utils/determineSectionUrlHash.ts +35 -0
  104. package/src/utils/filesystemPathHandling.ts +42 -0
  105. package/src/utils/filter.ts +12 -0
  106. package/src/utils/isBrowser.ts +5 -0
  107. package/src/utils/jsxToTextContent.ts +11 -0
  108. package/src/utils/objectAssign.ts +9 -0
  109. package/src/utils/server.ts +8 -0
  110. package/src/vite.config.ts +52 -0
  111. package/dist/chunk-7HKDCMSZ.js +0 -154
  112. package/dist/chunk-7HKDCMSZ.js.map +0 -1
  113. package/dist/chunk-G2A5MZJA.js +0 -48
  114. package/dist/chunk-G2A5MZJA.js.map +0 -1
  115. package/dist/chunk-GBXQT242.js.map +0 -1
  116. package/dist/chunk-JS5BGVDK.js +0 -178
  117. package/dist/chunk-JS5BGVDK.js.map +0 -1
  118. package/dist/chunk-OEVBWUR6.js +0 -92
  119. package/dist/chunk-OEVBWUR6.js.map +0 -1
  120. package/dist/chunk-TTLAZ2T2.js +0 -8
  121. package/dist/chunk-TTLAZ2T2.js.map +0 -1
  122. package/dist/cli/index.d.ts +0 -1
  123. package/dist/cli/index.js +0 -35
  124. package/dist/cli/index.js.map +0 -1
  125. package/dist/components/features/FeatureList.css.map +0 -1
  126. package/dist/components/features/FeatureList.d.ts +0 -13
  127. package/dist/components/features/FeatureList.js +0 -8
  128. package/dist/components/features/FeatureList.js.map +0 -1
  129. package/dist/components/features/initFeatureList.d.ts +0 -3
  130. package/dist/components/features/initFeatureList.js +0 -60
  131. package/dist/components/features/initFeatureList.js.map +0 -1
  132. package/dist/index.css +0 -121
  133. package/dist/index.css.map +0 -1
  134. package/dist/renderer/_default.page.client.css +0 -263
  135. package/dist/renderer/_default.page.client.css.map +0 -1
  136. package/dist/renderer/_default.page.client.d.ts +0 -1
  137. package/dist/renderer/_default.page.client.js +0 -180
  138. package/dist/renderer/_default.page.client.js.map +0 -1
  139. package/dist/renderer/_default.page.server.css +0 -312
  140. package/dist/renderer/_default.page.server.css.map +0 -1
  141. package/dist/renderer/_default.page.server.d.ts +0 -22
  142. package/dist/renderer/_default.page.server.js +0 -602
  143. package/dist/renderer/_default.page.server.js.map +0 -1
@@ -1,602 +0,0 @@
1
- import {
2
- PageContextProvider,
3
- RepoLink,
4
- getHeadings,
5
- parseTitle,
6
- usePageContext
7
- } from "../chunk-JS5BGVDK.js";
8
- import {
9
- Emoji,
10
- jsxToTextContent,
11
- objectAssign
12
- } from "../chunk-7HKDCMSZ.js";
13
- import {
14
- assert,
15
- assertUsage
16
- } from "../chunk-G2A5MZJA.js";
17
- import {
18
- __template
19
- } from "../chunk-TTLAZ2T2.js";
20
-
21
- // src/renderer/_default.page.server.tsx
22
- import ReactDOMServer from "react-dom/server";
23
- import React7 from "react";
24
- import { escapeInject as escapeInject2, dangerouslySkipEscape } from "vite-plugin-ssr";
25
-
26
- // src/PageLayout.tsx
27
- import React6 from "react";
28
-
29
- // src/navigation/Navigation.tsx
30
- import React3 from "react";
31
-
32
- // src/navigation/NavigationHeader.tsx
33
- import React from "react";
34
-
35
- // src/icons/github.svg
36
- var github_default = "/assets/github-P5ZSKN2N.svg";
37
-
38
- // src/icons/twitter.svg
39
- var twitter_default = "/assets/twitter-I7DXDN3J.svg";
40
-
41
- // src/icons/discord.svg
42
- var discord_default = "/assets/discord-JD33TUSF.svg";
43
-
44
- // src/icons/changelog.svg
45
- var changelog_default = "/assets/changelog-IPI5F42D.svg";
46
-
47
- // src/navigation/NavigationHeader.tsx
48
- function NavigationHeader() {
49
- const pageContext = usePageContext();
50
- return /* @__PURE__ */ React.createElement("div", {
51
- id: "navigation-header",
52
- style: {
53
- display: "flex",
54
- flexDirection: "column",
55
- alignItems: "center",
56
- marginBottom: -5
57
- }
58
- }, /* @__PURE__ */ React.createElement("a", {
59
- id: "navigation-header-logo",
60
- style: {
61
- display: "flex",
62
- alignItems: "center",
63
- color: "inherit",
64
- justifyContent: "left",
65
- textDecoration: "none",
66
- paddingTop: 12,
67
- paddingBottom: 7
68
- },
69
- href: "/"
70
- }, pageContext.config.navHeader), /* @__PURE__ */ React.createElement(Links, null));
71
- }
72
- function Links() {
73
- const pageContext = usePageContext();
74
- const { projectInfo } = pageContext.config;
75
- return /* @__PURE__ */ React.createElement("div", {
76
- style: {
77
- display: "flex",
78
- alignItems: "center",
79
- paddingTop: 0,
80
- justifyContent: "left"
81
- }
82
- }, /* @__PURE__ */ React.createElement(SocialLink, {
83
- className: "decolorize-4",
84
- icon: github_default,
85
- href: projectInfo.githubRepository
86
- }), /* @__PURE__ */ React.createElement(SocialLink, {
87
- className: "decolorize-6",
88
- icon: discord_default,
89
- href: projectInfo.discordInvite
90
- }), /* @__PURE__ */ React.createElement(SocialLink, {
91
- className: "decolorize-7",
92
- icon: twitter_default,
93
- href: projectInfo.twitterProfile
94
- }), /* @__PURE__ */ React.createElement("div", {
95
- id: "docsearch-desktop"
96
- }), /* @__PURE__ */ React.createElement(ChangelogButton, null));
97
- }
98
- function ChangelogButton() {
99
- const pageContext = usePageContext();
100
- const { projectInfo } = pageContext.config;
101
- return /* @__PURE__ */ React.createElement("a", {
102
- href: `${projectInfo.githubRepository}/blob/main/CHANGELOG.md`,
103
- className: "button colorize-on-hover",
104
- style: {
105
- display: "flex",
106
- alignItems: "center",
107
- padding: "1px 7px",
108
- marginLeft: 2,
109
- fontSize: "0.97em",
110
- color: "inherit"
111
- }
112
- }, /* @__PURE__ */ React.createElement("span", {
113
- className: "decolorize-7"
114
- }, "v", projectInfo.projectVersion), /* @__PURE__ */ React.createElement("img", {
115
- className: "decolorize-6",
116
- src: changelog_default,
117
- height: 16,
118
- style: { marginLeft: 5 }
119
- }));
120
- }
121
- function SocialLink({ className, icon, href }) {
122
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("a", {
123
- className: "colorize-on-hover " + className,
124
- href,
125
- style: { padding: 3, display: "inline-block", lineHeight: 0 }
126
- }, /* @__PURE__ */ React.createElement("img", {
127
- src: icon,
128
- height: "20",
129
- style: {}
130
- })));
131
- }
132
-
133
- // src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx
134
- import React2 from "react";
135
-
136
- // src/navigation/navigation-fullscreen/close.svg
137
- var close_default = "/assets/close-IQXTDOHV.svg";
138
-
139
- // src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx
140
- function NavigationFullscreenButton() {
141
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("a", {
142
- id: "navigation-fullscreen-button"
143
- }, /* @__PURE__ */ React2.createElement("div", {
144
- style: {
145
- position: "fixed",
146
- cursor: "pointer",
147
- height: "100vh",
148
- width: 20,
149
- overflow: "hidden"
150
- }
151
- }, /* @__PURE__ */ React2.createElement("div", null)), /* @__PURE__ */ React2.createElement("div", {
152
- style: { position: "fixed", height: "100vh", width: 20 },
153
- "aria-label": "Press <Esc>",
154
- "data-balloon-pos": "right"
155
- })));
156
- }
157
- function NavigationFullscreenClose() {
158
- return /* @__PURE__ */ React2.createElement("a", {
159
- id: "navigation-fullscreen-close",
160
- style: { position: "fixed", top: 11, right: 15, zIndex: 10 },
161
- "aria-label": "Press <Esc>",
162
- "data-balloon-pos": "left"
163
- }, /* @__PURE__ */ React2.createElement("img", {
164
- src: close_default,
165
- height: 50,
166
- width: 50,
167
- style: { display: "block" }
168
- }));
169
- }
170
-
171
- // src/navigation/Navigation.tsx
172
- function Navigation({
173
- pageContext
174
- }) {
175
- const { isDetachedPage } = pageContext;
176
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", {
177
- id: "navigation-container"
178
- }, /* @__PURE__ */ React3.createElement(NavigationHeader, null), isDetachedPage && /* @__PURE__ */ React3.createElement(DetachedPageNote, null), /* @__PURE__ */ React3.createElement(NavigationContent, {
179
- pageContext
180
- }), /* @__PURE__ */ React3.createElement(NavigationFullscreenClose, null)));
181
- }
182
- function NavigationMask() {
183
- return /* @__PURE__ */ React3.createElement("div", {
184
- id: "navigation-mask"
185
- });
186
- }
187
- function NavigationContent({
188
- pageContext
189
- }) {
190
- const headings = getHeadingsWithComputedProps(pageContext);
191
- const headingsGrouped = groupHeadings(headings);
192
- return /* @__PURE__ */ React3.createElement("div", {
193
- id: "navigation-content"
194
- }, /* @__PURE__ */ React3.createElement("div", {
195
- className: "nav-column",
196
- style: { position: "relative" }
197
- }, headingsGrouped.map((headingsH1, i) => /* @__PURE__ */ React3.createElement("div", {
198
- className: "nav-h1-group",
199
- key: i
200
- }, /* @__PURE__ */ React3.createElement(Heading, {
201
- heading: headingsH1
202
- }), headingsH1.headings.map((heading, j) => /* @__PURE__ */ React3.createElement(Heading, {
203
- heading,
204
- key: j
205
- }))))));
206
- }
207
- function Heading({
208
- heading
209
- }) {
210
- assert([1, 2, 3, 4].includes(heading.level), heading);
211
- return /* @__PURE__ */ React3.createElement("a", {
212
- className: [
213
- "nav-item",
214
- "nav-item-h" + heading.level,
215
- heading.computed.isActive && " is-active",
216
- heading.computed.isActiveFirst && " is-active-first",
217
- heading.computed.isActiveLast && " is-active-last",
218
- heading.computed.isChildOfListHeading && "nav-item-parent-is-list-heading",
219
- heading.computed.isFirstOfItsKind && "nav-item-first-of-its-kind",
220
- heading.computed.isLastOfItsKind && "nav-item-last-of-its-kind"
221
- ].filter(Boolean).join(" "),
222
- href: heading.url || void 0
223
- }, heading.titleInNav);
224
- }
225
- function groupHeadings(headings) {
226
- const headingsGrouped = [];
227
- headings.forEach((heading) => {
228
- if (heading.level === 1) {
229
- headingsGrouped.push({ ...heading, headings: [] });
230
- } else {
231
- headingsGrouped[headingsGrouped.length - 1].headings.push(heading);
232
- }
233
- });
234
- return headingsGrouped;
235
- }
236
- function getHeadingsWithComputedProps(pageContext) {
237
- const { headingsWithSubHeadings, urlPathname } = pageContext;
238
- return headingsWithSubHeadings.map((heading, i) => {
239
- var _a2;
240
- assert([1, 2, 3, 4].includes(heading.level), heading);
241
- const headingPrevious = headingsWithSubHeadings[i - 1];
242
- const headingNext = headingsWithSubHeadings[i + 1];
243
- let isActiveFirst = false;
244
- let isActiveLast = false;
245
- let isActive = false;
246
- if (heading.url === urlPathname) {
247
- assert(heading.level === 2, { urlPathname });
248
- isActive = true;
249
- isActiveFirst = true;
250
- if ((headingNext == null ? void 0 : headingNext.level) !== 3) {
251
- isActiveLast = true;
252
- }
253
- }
254
- if (heading.level === 3) {
255
- isActive = true;
256
- if ((headingNext == null ? void 0 : headingNext.level) !== 3) {
257
- isActiveLast = true;
258
- }
259
- }
260
- const isFirstOfItsKind = heading.level !== (headingPrevious == null ? void 0 : headingPrevious.level);
261
- const isLastOfItsKind = heading.level !== (headingNext == null ? void 0 : headingNext.level);
262
- const isChildOfListHeading = !!((_a2 = heading.parentHeadings[0]) == null ? void 0 : _a2.isListTitle);
263
- return {
264
- ...heading,
265
- computed: {
266
- isActive,
267
- isActiveFirst,
268
- isActiveLast,
269
- isFirstOfItsKind,
270
- isLastOfItsKind,
271
- isChildOfListHeading
272
- }
273
- };
274
- });
275
- }
276
- function DetachedPageNote() {
277
- return /* @__PURE__ */ React3.createElement("div", {
278
- id: "detached-note",
279
- style: {
280
- backgroundColor: "var(--background-color)",
281
- textAlign: "left",
282
- marginLeft: 10,
283
- marginRight: 10,
284
- marginTop: 30,
285
- marginBottom: -8,
286
- borderRadius: 5,
287
- padding: 10
288
- }
289
- }, /* @__PURE__ */ React3.createElement(Emoji, {
290
- name: "info"
291
- }), " ", /* @__PURE__ */ React3.createElement("b", null, /* @__PURE__ */ React3.createElement("em", null, "Detached")), /* @__PURE__ */ React3.createElement("span", {
292
- style: {
293
- opacity: 0.8
294
- }
295
- }, " ", "\u2014 this page isn't listed in the navigation menu below."));
296
- }
297
-
298
- // src/MobileHeader.tsx
299
- import React4 from "react";
300
- function MobileHeader() {
301
- const pageContext = usePageContext();
302
- return /* @__PURE__ */ React4.createElement("div", {
303
- id: "mobile-header",
304
- style: {
305
- height: "var(--mobile-header-height)",
306
- width: "100vw",
307
- position: "relative"
308
- }
309
- }, /* @__PURE__ */ React4.createElement("div", {
310
- style: {
311
- position: "fixed",
312
- display: "flex",
313
- alignItems: "center",
314
- background: "white",
315
- zIndex: 99,
316
- top: 0,
317
- left: 0,
318
- height: "var(--mobile-header-height)",
319
- width: "100%",
320
- borderBottom: "1px solid #ddd"
321
- }
322
- }, /* @__PURE__ */ React4.createElement(MenuToggle, null), /* @__PURE__ */ React4.createElement("a", {
323
- href: "/",
324
- style: {
325
- color: "inherit",
326
- display: "flex",
327
- alignItems: "center",
328
- justifyContent: "left",
329
- textDecoration: "none"
330
- }
331
- }, pageContext.config.navHeaderMobile), /* @__PURE__ */ React4.createElement("div", {
332
- id: "docsearch-mobile"
333
- })));
334
- }
335
- function MenuToggle() {
336
- return /* @__PURE__ */ React4.createElement("div", {
337
- style: { padding: 20, lineHeight: 0 },
338
- id: "menu-toggle"
339
- }, /* @__PURE__ */ React4.createElement("svg", {
340
- style: { width: 20 },
341
- className: "icon",
342
- xmlns: "http://www.w3.org/2000/svg",
343
- "aria-hidden": "true",
344
- role: "img",
345
- viewBox: "0 0 448 512"
346
- }, /* @__PURE__ */ React4.createElement("path", {
347
- fill: "currentColor",
348
- d: "M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
349
- })));
350
- }
351
-
352
- // src/components/EditPageNote.tsx
353
- import React5 from "react";
354
- function EditPageNote({ pageContext }) {
355
- const text = /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(Emoji, {
356
- name: "writing-hang"
357
- }), " Edit this page");
358
- return /* @__PURE__ */ React5.createElement("div", {
359
- style: { marginTop: 50 }
360
- }, /* @__PURE__ */ React5.createElement(RepoLink, {
361
- path: "/docs/pages" + pageContext.urlPathname + ".page.server.mdx",
362
- text,
363
- editMode: true
364
- }));
365
- }
366
-
367
- // src/PageLayout.tsx
368
- function PageLayout({ pageContext, children }) {
369
- const { isLandingPage, pageTitle } = pageContext;
370
- return /* @__PURE__ */ React6.createElement(React6.StrictMode, null, /* @__PURE__ */ React6.createElement(PageContextProvider, {
371
- pageContext
372
- }, /* @__PURE__ */ React6.createElement("div", {
373
- id: "page-layout",
374
- className: isLandingPage ? "landing-page" : "doc-page"
375
- }, /* @__PURE__ */ React6.createElement("div", {
376
- id: "navigation-wrapper"
377
- }, /* @__PURE__ */ React6.createElement(Navigation, {
378
- pageContext
379
- })), /* @__PURE__ */ React6.createElement(NavigationFullscreenButton, null), /* @__PURE__ */ React6.createElement("div", {
380
- id: "page-wrapper"
381
- }, /* @__PURE__ */ React6.createElement("div", {
382
- id: "page-container"
383
- }, /* @__PURE__ */ React6.createElement(MobileHeader, null), /* @__PURE__ */ React6.createElement("div", {
384
- id: "page-content"
385
- }, pageTitle && /* @__PURE__ */ React6.createElement("h1", null, pageTitle), children, !isLandingPage && /* @__PURE__ */ React6.createElement(EditPageNote, {
386
- pageContext
387
- }))), /* @__PURE__ */ React6.createElement(NavigationMask, null)))));
388
- }
389
-
390
- // src/config/getConfig.ts
391
- function getConfig() {
392
- const globResult = import.meta.glob("/**/docpress.config.*([a-zA-Z0-9])", { eager: true });
393
- const files = Object.keys(globResult);
394
- assertUsage(files.length >= 1, "No DocPress config file found `docpress.config.(js|ts|tsx|...)`");
395
- assertUsage(
396
- files.length === 1,
397
- `Found multiple \`docpress.config.js\` files: ${files.map((f) => `\`${f}\``).join(", ")}. Define only one instead.`
398
- );
399
- const config = Object.values(globResult)[0].default;
400
- assert(config);
401
- return config;
402
- }
403
-
404
- // src/config/resolvePageContext.ts
405
- function resolvePageContext(pageContext) {
406
- const config = getConfig();
407
- const { headings, headingsWithoutLink } = getHeadings(config);
408
- const activeHeading = findActiveHeading(headings, headingsWithoutLink, pageContext);
409
- const headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeHeading);
410
- const { title, isLandingPage, pageTitle, isDetachedPage } = getMetaData(
411
- headingsWithoutLink,
412
- activeHeading,
413
- pageContext,
414
- config
415
- );
416
- const { faviconUrl, algolia, tagline, twitterHandle, bannerUrl, websiteUrl } = config;
417
- const pageContextResolved = {};
418
- objectAssign(pageContextResolved, {
419
- ...pageContext,
420
- meta: {
421
- title,
422
- faviconUrl,
423
- twitterHandle,
424
- bannerUrl,
425
- websiteUrl,
426
- tagline,
427
- algolia
428
- },
429
- headings,
430
- headingsWithSubHeadings,
431
- isLandingPage,
432
- isDetachedPage,
433
- pageTitle,
434
- config
435
- });
436
- return pageContextResolved;
437
- }
438
- function getMetaData(headingsWithoutLink, activeHeading, pageContext, config) {
439
- const url = pageContext.urlOriginal;
440
- let title;
441
- let pageTitle;
442
- let isDetachedPage;
443
- if (activeHeading) {
444
- title = activeHeading.titleDocument || jsxToTextContent(activeHeading.title);
445
- pageTitle = activeHeading.title;
446
- isDetachedPage = false;
447
- } else {
448
- pageTitle = headingsWithoutLink.find((h) => h.url === url).title;
449
- title = jsxToTextContent(pageTitle);
450
- isDetachedPage = true;
451
- }
452
- const isLandingPage = url === "/";
453
- if (!isLandingPage) {
454
- title += " | " + config.projectInfo.projectName;
455
- }
456
- if (isLandingPage) {
457
- pageTitle = null;
458
- }
459
- return { title, isLandingPage, pageTitle, isDetachedPage };
460
- }
461
- function findActiveHeading(headings, headingsWithoutLink, pageContext) {
462
- let activeHeading = null;
463
- assert(pageContext.urlOriginal);
464
- const pageUrl = pageContext.urlOriginal;
465
- headings.forEach((heading) => {
466
- if (heading.url === pageUrl) {
467
- activeHeading = heading;
468
- assert(heading.level === 2, { pageUrl, heading });
469
- }
470
- });
471
- const debugInfo = {
472
- msg: "Heading not found for url: " + pageUrl,
473
- urls: headings.map((h) => h.url),
474
- url: pageUrl
475
- };
476
- assert(activeHeading || headingsWithoutLink.find(({ url }) => pageUrl === url), debugInfo);
477
- return activeHeading;
478
- }
479
- function getHeadingsWithSubHeadings(headings, pageContext, activeHeading) {
480
- const headingsWithSubHeadings = headings.slice();
481
- if (activeHeading === null)
482
- return headingsWithSubHeadings;
483
- const activeHeadingIdx = headingsWithSubHeadings.indexOf(activeHeading);
484
- assert(activeHeadingIdx >= 0);
485
- const pageHeadings = pageContext.exports.headings || [];
486
- pageHeadings.forEach((pageHeading, i) => {
487
- const title = parseTitle(pageHeading.title);
488
- const url = "#" + pageHeading.id;
489
- assert(
490
- pageHeading.headingLevel !== 3,
491
- "Wrong page heading level `" + pageHeading.headingLevel + "` (it should be `<h2>`) for sub-heading `" + pageHeading.title + "` of page `" + pageContext.urlOriginal + "`."
492
- );
493
- if (pageHeading.headingLevel === 2) {
494
- const heading = {
495
- url,
496
- title,
497
- parentHeadings: [activeHeading, ...activeHeading.parentHeadings],
498
- titleInNav: title,
499
- level: 3
500
- };
501
- headingsWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, heading);
502
- }
503
- });
504
- if (activeHeading == null ? void 0 : activeHeading.sectionTitles) {
505
- activeHeading.sectionTitles.forEach((sectionTitle) => {
506
- const pageHeadingTitles = pageHeadings.map((h) => h.title);
507
- assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle });
508
- });
509
- }
510
- return headingsWithSubHeadings;
511
- }
512
-
513
- // src/algolia/DocSearch.ts
514
- import { escapeInject } from "vite-plugin-ssr";
515
- function getDocSearchCSS(pageContext) {
516
- const docSearchCSS = !pageContext.meta.algolia ? "" : escapeInject`
517
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" />
518
- `;
519
- return docSearchCSS;
520
- }
521
- var _a;
522
- function getDocSearchJS(pageContext) {
523
- const docSearchJS = !pageContext.meta.algolia ? "" : escapeInject(_a || (_a = __template([`
524
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"><\/script>
525
- <script type="text/javascript">
526
- docsearch({
527
- appId: '`, "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-desktop',\n })\n docsearch({\n appId: '", "',\n apiKey: '", "',\n indexName: '", "',\n container: '#docsearch-mobile',\n })\n <\/script>\n "])), pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName, pageContext.meta.algolia.appId, pageContext.meta.algolia.apiKey, pageContext.meta.algolia.indexName);
528
- return docSearchJS;
529
- }
530
-
531
- // src/parseEmojis.ts
532
- import twemoji from "twemoji";
533
- var emojiList = {
534
- ":no_entry:": 9940,
535
- ":warning:": 9888,
536
- ":trophy:": 127942
537
- };
538
- function parseEmojis(html) {
539
- Object.entries(emojiList).forEach(([shortcode, codepoint]) => {
540
- if (!html.includes(shortcode)) {
541
- return;
542
- }
543
- const emojiStr = twemoji.convert.fromCodePoint(codepoint);
544
- let emojiImg = twemoji.parse(emojiStr, {
545
- folder: "svg",
546
- ext: ".svg"
547
- });
548
- const style = "height: 1.275em; width: 1.275em; vertical-align: -20%";
549
- emojiImg = emojiImg.replace('<img class="emoji" ', `<img style="${style}" `);
550
- html = html.split(shortcode).join(emojiImg);
551
- });
552
- return html;
553
- }
554
-
555
- // src/renderer/_default.page.server.tsx
556
- async function render(pageContextOriginal) {
557
- const { Page } = pageContextOriginal;
558
- const pageContextResolved = resolvePageContext(pageContextOriginal);
559
- const page = /* @__PURE__ */ React7.createElement(PageLayout, {
560
- pageContext: pageContextResolved
561
- }, /* @__PURE__ */ React7.createElement(Page, null));
562
- const descriptionTag = pageContextResolved.isLandingPage ? dangerouslySkipEscape(`<meta name="description" content="${pageContextResolved.meta.tagline}" />`) : "";
563
- const docSearchJS = getDocSearchJS(pageContextResolved);
564
- const docSearchCSS = getDocSearchCSS(pageContextResolved);
565
- let pageHtml = ReactDOMServer.renderToString(page);
566
- pageHtml = parseEmojis(pageHtml);
567
- return escapeInject2`<!DOCTYPE html>
568
- <html>
569
- <head>
570
- <meta charset="UTF-8" />
571
- <link rel="icon" href="${pageContextResolved.meta.faviconUrl}" />
572
- <title>${pageContextResolved.meta.title}</title>
573
- ${descriptionTag}
574
- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
575
- ${docSearchCSS}
576
- ${getOpenGraphTags(pageContextOriginal.urlPathname, pageContextResolved.meta)}
577
- </head>
578
- <body>
579
- <div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
580
- ${docSearchJS}
581
- </body>
582
- </html>`;
583
- }
584
- function getOpenGraphTags(url, meta) {
585
- const { title, tagline, websiteUrl, twitterHandle, bannerUrl } = meta;
586
- assert(url.startsWith("/"));
587
- if (url !== "/" || !bannerUrl)
588
- return "";
589
- return escapeInject2`
590
- <meta property="og:type" content="website">
591
- <meta property="og:title" content="${title}">
592
- <meta property="og:image" content="${bannerUrl}">
593
- <meta property="og:url" content="${websiteUrl}">
594
- <meta property="og:description" content="${tagline}">
595
- <meta name="twitter:card" content="summary_large_image">
596
- <meta name="twitter:site" content="${twitterHandle}">
597
- `;
598
- }
599
- export {
600
- render
601
- };
602
- //# sourceMappingURL=_default.page.server.js.map