@brillout/docpress 0.5.39 → 0.5.40-commit-1ba896e

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