@brillout/docpress 0.6.20 → 0.6.21-commit-f22016e

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 (106) hide show
  1. package/+config.ts +26 -7
  2. package/MobileHeader.tsx +5 -3
  3. package/PageLayout.css +11 -11
  4. package/PageLayout.tsx +27 -20
  5. package/algolia/DocSearch.css +6 -9
  6. package/autoScrollNav.ts +4 -3
  7. package/components/FeatureList/FeatureList.client.ts +6 -11
  8. package/components/Link.tsx +9 -9
  9. package/config/getConfig.ts +2 -1
  10. package/config/resolveHeadingsData.ts +22 -30
  11. package/config/resolvePageContext.ts +4 -6
  12. package/dist/+config.d.ts +25 -8
  13. package/dist/+config.js +7 -7
  14. package/dist/components/CodeBlockTransformer.d.ts +7 -0
  15. package/dist/components/CodeBlockTransformer.js +9 -0
  16. package/dist/components/Comment.d.ts +5 -0
  17. package/dist/components/Comment.js +6 -0
  18. package/dist/components/Consulting.d.ts +4 -0
  19. package/dist/components/Consulting.js +39 -0
  20. package/dist/components/Contributors.d.ts +7 -0
  21. package/dist/components/Contributors.js +74 -0
  22. package/dist/components/FileRemoved.d.ts +9 -0
  23. package/dist/components/FileRemoved.js +28 -0
  24. package/dist/components/HorizontalLine.d.ts +5 -0
  25. package/dist/components/HorizontalLine.js +15 -0
  26. package/dist/components/ImportMeta.d.ts +5 -0
  27. package/dist/components/ImportMeta.js +10 -0
  28. package/dist/components/Link.d.ts +16 -0
  29. package/dist/components/Link.js +108 -0
  30. package/dist/components/Note.d.ts +22 -0
  31. package/dist/components/Note.js +93 -0
  32. package/dist/components/P.d.ts +4 -0
  33. package/dist/components/P.js +17 -0
  34. package/dist/components/ReadingRecommendation.d.ts +6 -0
  35. package/dist/components/ReadingRecommendation.js +40 -0
  36. package/dist/components/RepoLink.d.ts +9 -0
  37. package/dist/components/RepoLink.js +22 -0
  38. package/dist/components/Sponsors.d.ts +22 -0
  39. package/dist/components/Sponsors.js +161 -0
  40. package/dist/components/Supporters.d.ts +32 -0
  41. package/dist/components/Supporters.js +80 -0
  42. package/dist/components/index.d.ts +15 -0
  43. package/dist/components/index.js +15 -0
  44. package/dist/config/getConfig.d.ts +3 -0
  45. package/dist/config/getConfig.js +14 -0
  46. package/dist/config/resolveHeadingsData.d.ts +16 -0
  47. package/dist/config/resolveHeadingsData.js +223 -0
  48. package/dist/config/resolvePageContext.d.ts +38 -0
  49. package/dist/config/resolvePageContext.js +23 -0
  50. package/dist/data/maintainersList.d.ts +9 -0
  51. package/dist/data/maintainersList.js +83 -0
  52. package/dist/data/sponsorsList.d.ts +3 -0
  53. package/dist/data/sponsorsList.js +151 -0
  54. package/dist/navigation/Navigation.d.ts +20 -0
  55. package/dist/navigation/Navigation.js +128 -0
  56. package/dist/navigation/NavigationHeader.d.ts +4 -0
  57. package/dist/navigation/NavigationHeader.js +85 -0
  58. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +6 -0
  59. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +22 -0
  60. package/dist/parsePageSections.js +2 -2
  61. package/dist/parseTitle.d.ts +5 -0
  62. package/dist/parseTitle.js +52 -0
  63. package/dist/renderer/usePageContext.d.ts +17 -0
  64. package/dist/renderer/usePageContext.js +26 -0
  65. package/dist/types/Config.d.ts +30 -0
  66. package/dist/types/Config.js +1 -0
  67. package/dist/types/Heading.d.ts +45 -0
  68. package/dist/types/Heading.js +1 -0
  69. package/dist/utils/Emoji/Emoji.d.ts +8 -0
  70. package/dist/utils/Emoji/Emoji.js +191 -0
  71. package/dist/utils/Emoji/assets.d.ts +6 -0
  72. package/dist/utils/Emoji/assets.js +7 -0
  73. package/dist/utils/Emoji/index.d.ts +1 -0
  74. package/dist/utils/Emoji/index.js +1 -0
  75. package/dist/utils/client.d.ts +2 -0
  76. package/dist/utils/client.js +2 -0
  77. package/dist/utils/filter.d.ts +2 -0
  78. package/dist/utils/filter.js +11 -0
  79. package/dist/utils/isBrowser.d.ts +2 -0
  80. package/dist/utils/isBrowser.js +4 -0
  81. package/dist/utils/jsxToTextContent.d.ts +2 -0
  82. package/dist/utils/jsxToTextContent.js +12 -0
  83. package/dist/utils/objectAssign.d.ts +2 -0
  84. package/dist/utils/objectAssign.js +5 -0
  85. package/dist/utils/server.d.ts +7 -0
  86. package/dist/utils/server.js +7 -0
  87. package/dist/vite.config.js +5 -3
  88. package/installSectionUrlHashs.ts +8 -14
  89. package/navigation/Navigation-layout.css +2 -2
  90. package/navigation/Navigation.tsx +22 -17
  91. package/navigation/NavigationHeader.tsx +33 -4
  92. package/navigation/initMobileNavigation.ts +16 -6
  93. package/navigation/initPressKit.ts +5 -2
  94. package/package.json +15 -12
  95. package/renderer/getPageElement.tsx +16 -0
  96. package/renderer/onBeforeRender.ts +12 -0
  97. package/renderer/onRenderClient.tsx +53 -0
  98. package/renderer/onRenderHtml.tsx +7 -22
  99. package/renderer/usePageContext.tsx +20 -0
  100. package/tsconfig.json +1 -1
  101. package/types/Config.ts +6 -20
  102. package/types/Heading.ts +4 -4
  103. package/vite.config.ts +5 -3
  104. package/algolia/DocSearch.ts +0 -62
  105. package/navigation/Navigation.client.ts +0 -7
  106. package/renderer/client.ts +0 -4
@@ -0,0 +1,161 @@
1
+ export { Sponsors };
2
+ import React from 'react';
3
+ import iconHeart from '../icons/heart.svg';
4
+ import { usePageContext } from '../renderer/usePageContext';
5
+ import { assert, Emoji } from '../utils/server';
6
+ import { Supporter, SupporterSection, SectionDescription, Individuals, SupporterImg, CallToAction } from './Supporters';
7
+ import medalGold from './Sponsors/medalGold.svg';
8
+ import medalSilver from './Sponsors/medalSilver.svg';
9
+ import medalBronze from './Sponsors/medalBronze.svg';
10
+ import labelBgImg from './Sponsors/label.svg';
11
+ import { sponsorsList } from '../data/sponsorsList';
12
+ function Sponsors() {
13
+ var pageContext = usePageContext();
14
+ var projectInfo = pageContext.config.projectInfo;
15
+ var sponsorGithubAccount = pageContext.config.sponsorGithubAccount || 'brillout';
16
+ var sponsorsCompanies = sponsorsList.filter(isCompany);
17
+ var sponsorsIndividuals = sponsorsList.filter(isIndividual);
18
+ return (React.createElement(SupporterSection, null,
19
+ React.createElement(CallToAction, { iconUrl: iconHeart, text: "Sponsor", href: "https://github.com/sponsors/".concat(sponsorGithubAccount) }),
20
+ React.createElement("div", null),
21
+ React.createElement(SectionDescription, null,
22
+ projectInfo.projectName,
23
+ " is free and open source, made possible by wonderful sponsors."),
24
+ React.createElement("div", { style: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-evenly', alignItems: 'end' } }, sponsorsCompanies.map(function (sponsor, i) { return (React.createElement(SponsorDiv, { sponsor: sponsor, key: i })); })),
25
+ React.createElement(Individuals, null, sponsorsIndividuals.map(function (sponsor, i) { return (React.createElement(SponsorDiv, { sponsor: sponsor, key: i })); }))));
26
+ }
27
+ function SponsorDiv(_a) {
28
+ var sponsor = _a.sponsor;
29
+ if (isIndividual(sponsor)) {
30
+ return React.createElement(Supporter, { username: sponsor.username });
31
+ }
32
+ return React.createElement(CompanyDiv, { sponsor: sponsor });
33
+ }
34
+ function CompanyDiv(_a) {
35
+ var sponsor = _a.sponsor;
36
+ assert(isCompany(sponsor));
37
+ var imgSrc = sponsor.companyLogo;
38
+ var imgAlt = sponsor.companyName;
39
+ var _b = getSize(sponsor), width = _b.width, height = _b.height, padding = _b.padding;
40
+ var marginHeight = 20;
41
+ var marginWidth = 10;
42
+ return (React.createElement("a", { href: sponsor.website, style: {
43
+ margin: "".concat(marginHeight, "px ").concat(marginWidth, "px"),
44
+ } },
45
+ React.createElement(Label, { sponsor: sponsor }),
46
+ React.createElement("div", { style: {
47
+ backgroundColor: '#f0f0f0',
48
+ borderRadius: 7,
49
+ overflow: 'hidden',
50
+ width: width,
51
+ maxWidth: "calc(100vw - 2 * var(--main-view-padding) - 2 * ".concat(marginWidth, "px)"),
52
+ height: height,
53
+ display: 'flex',
54
+ alignItems: 'center',
55
+ flexDirection: 'column',
56
+ justifyContent: 'center',
57
+ } },
58
+ React.createElement(SupporterImg, { imgSrc: imgSrc, imgAlt: imgAlt, width: width, height: height, padding: padding }))));
59
+ }
60
+ function Label(_a) {
61
+ var sponsor = _a.sponsor;
62
+ assert(isCompany(sponsor));
63
+ var labelBg = getLabelBg(sponsor);
64
+ var labelIcon = getLabelIcon(sponsor);
65
+ var labelText = getLabelText(sponsor);
66
+ return (React.createElement("div", { style: {
67
+ top: 0,
68
+ display: 'flex',
69
+ justifyContent: 'center',
70
+ alignItems: 'center',
71
+ position: 'relative',
72
+ paddingBottom: 1,
73
+ } },
74
+ labelBg,
75
+ labelIcon,
76
+ labelText));
77
+ }
78
+ function getLabelBg(sponsor) {
79
+ var height = sponsor.plan === 'platinum' ? 32 : 24;
80
+ return React.createElement("img", { src: labelBgImg, style: { height: height, position: 'absolute', bottom: 0, zIndex: -1 } });
81
+ }
82
+ function getLabelText(sponsor) {
83
+ if (sponsor.plan === 'platinum') {
84
+ return React.createElement(React.Fragment, null);
85
+ }
86
+ var letterSpacing = undefined;
87
+ if (['bronze', 'silver', 'gold', 'indie'].includes(sponsor.plan)) {
88
+ letterSpacing = 1;
89
+ }
90
+ /*
91
+ if (sponsor.plan === 'indie') {
92
+ letterSpacing = 2
93
+ }
94
+ */
95
+ return (React.createElement(React.Fragment, null,
96
+ ' ',
97
+ React.createElement("span", { style: {
98
+ zIndex: 1,
99
+ fontSize: '0.82em',
100
+ position: 'relative',
101
+ top: 0,
102
+ fontWeight: 500,
103
+ color: '#666',
104
+ letterSpacing: letterSpacing,
105
+ } }, capitalizeFirstLetter(sponsor.plan))));
106
+ }
107
+ function getLabelIcon(sponsor) {
108
+ var medalSrc;
109
+ if (sponsor.plan === 'platinum') {
110
+ return React.createElement(Emoji, { name: "trophy", style: { fontSize: '1.3em' } });
111
+ }
112
+ else if (sponsor.plan === 'indie') {
113
+ return React.createElement(Emoji, { name: "ribbon", style: { fontSize: '0.9em' /*, position: 'relative', top: -1*/ } });
114
+ }
115
+ else if (sponsor.plan === 'gold') {
116
+ medalSrc = medalGold;
117
+ }
118
+ else if (sponsor.plan === 'silver') {
119
+ medalSrc = medalSilver;
120
+ }
121
+ else if (sponsor.plan === 'bronze') {
122
+ medalSrc = medalBronze;
123
+ }
124
+ else {
125
+ assert(false);
126
+ }
127
+ return React.createElement("img", { src: medalSrc, style: { height: 15, zIndex: 1, marginRight: 5 } });
128
+ }
129
+ function getSize(sponsor) {
130
+ var plan = sponsor.plan;
131
+ var divSize;
132
+ if (plan === 'platinum') {
133
+ divSize = { width: 500, height: 180, padding: 100 };
134
+ }
135
+ if (plan === 'gold') {
136
+ divSize = { width: 400, height: 150, padding: 95 };
137
+ }
138
+ if (plan === 'silver') {
139
+ divSize = { width: 300, height: 100, padding: 45 };
140
+ }
141
+ if (plan === 'bronze') {
142
+ divSize = { width: 200, height: 70, padding: 30 };
143
+ }
144
+ if (plan === 'indie') {
145
+ divSize = { width: 140, height: 50, padding: 20 };
146
+ }
147
+ assert(divSize);
148
+ if (sponsor.divSize) {
149
+ Object.assign(divSize, sponsor.divSize);
150
+ }
151
+ return divSize;
152
+ }
153
+ function capitalizeFirstLetter(word) {
154
+ return word[0].toUpperCase() + word.slice(1);
155
+ }
156
+ function isCompany(sponsor) {
157
+ return !isIndividual(sponsor);
158
+ }
159
+ function isIndividual(sponsor) {
160
+ return 'username' in sponsor;
161
+ }
@@ -0,0 +1,32 @@
1
+ export { Supporter, SupporterSection, SectionDescription, Individuals, SupporterImg, CallToAction };
2
+ import React from 'react';
3
+ type Children = (string | JSX.Element) | (string | JSX.Element)[];
4
+ declare function SupporterSection({ children }: {
5
+ children?: Children;
6
+ }): React.JSX.Element;
7
+ declare function SectionDescription({ children }: {
8
+ children?: Children;
9
+ }): React.JSX.Element;
10
+ declare function Individuals({ children }: {
11
+ children?: Children;
12
+ }): React.JSX.Element;
13
+ declare function Supporter({ username, avatarUrl }: {
14
+ username: string;
15
+ avatarUrl?: string;
16
+ }): React.JSX.Element;
17
+ declare function SupporterImg({ imgSrc, // has precedence over avatarUrl
18
+ avatarUrl, // has precedence over username
19
+ username, imgAlt, width, height, padding, }: {
20
+ imgSrc?: string;
21
+ avatarUrl?: string;
22
+ username?: string;
23
+ imgAlt?: string;
24
+ width: number;
25
+ height: number;
26
+ padding?: number;
27
+ }): React.JSX.Element;
28
+ declare function CallToAction({ iconUrl, text, href }: {
29
+ iconUrl: string;
30
+ text: string;
31
+ href: string;
32
+ }): React.JSX.Element;
@@ -0,0 +1,80 @@
1
+ // supporters = sponsors + contributors
2
+ export { Supporter, SupporterSection, SectionDescription, Individuals, SupporterImg, CallToAction };
3
+ import React from 'react';
4
+ function SupporterSection(_a) {
5
+ var children = _a.children;
6
+ return (React.createElement("div", { style: {
7
+ textAlign: 'center',
8
+ marginTop: 19,
9
+ } }, children));
10
+ }
11
+ function SectionDescription(_a) {
12
+ var children = _a.children;
13
+ return (React.createElement("div", { style: {
14
+ maxWidth: 400,
15
+ display: 'inline-block',
16
+ marginTop: 12,
17
+ marginBottom: 12,
18
+ } }, children));
19
+ }
20
+ function Individuals(_a) {
21
+ var children = _a.children;
22
+ return (React.createElement("div", { style: {
23
+ display: 'flex',
24
+ flexWrap: 'wrap',
25
+ justifyContent: 'center',
26
+ alignItems: 'end',
27
+ margin: '17px auto',
28
+ maxWidth: 700,
29
+ } }, children));
30
+ }
31
+ // Individual sponsor or small contributor
32
+ function Supporter(_a) {
33
+ var username = _a.username, avatarUrl = _a.avatarUrl;
34
+ var website = "https://github.com/".concat(username);
35
+ var width = 30;
36
+ var height = 30;
37
+ var marginWidth = 5;
38
+ var marginHeight = 5;
39
+ return (React.createElement("a", { href: website, style: {
40
+ margin: "".concat(marginHeight, "px ").concat(marginWidth, "px"),
41
+ } },
42
+ React.createElement("div", { style: {
43
+ borderRadius: 7,
44
+ overflow: 'hidden',
45
+ width: width,
46
+ height: height,
47
+ display: 'flex',
48
+ alignItems: 'center',
49
+ flexDirection: 'column',
50
+ justifyContent: 'center',
51
+ } },
52
+ React.createElement(SupporterImg, { username: username, avatarUrl: avatarUrl, width: width, height: height }))));
53
+ }
54
+ function SupporterImg(_a) {
55
+ var imgSrc = _a.imgSrc, // has precedence over avatarUrl
56
+ avatarUrl = _a.avatarUrl, // has precedence over username
57
+ username = _a.username, imgAlt = _a.imgAlt, width = _a.width, height = _a.height, _b = _a.padding, padding = _b === void 0 ? 0 : _b;
58
+ var size = Math.max(width, height);
59
+ if (avatarUrl) {
60
+ imgSrc = imgSrc || "".concat(avatarUrl, "&size=").concat(size);
61
+ }
62
+ if (username) {
63
+ imgSrc = imgSrc || "https://github.com/".concat(username, ".png?size=").concat(size);
64
+ imgAlt = imgAlt || username;
65
+ }
66
+ return (React.createElement("img", { style: { width: "calc(100% - ".concat(padding, "px)"), height: height - padding, zIndex: 2, objectFit: 'contain' }, src: imgSrc, alt: imgAlt }));
67
+ }
68
+ function CallToAction(_a) {
69
+ var iconUrl = _a.iconUrl, text = _a.text, href = _a.href;
70
+ return (React.createElement("a", { className: "button", style: {
71
+ color: 'inherit',
72
+ display: 'inline-flex',
73
+ alignItems: 'center',
74
+ padding: '5px 10px',
75
+ marginBottom: 10,
76
+ }, href: href },
77
+ React.createElement("img", { src: iconUrl, height: 22 }),
78
+ " ",
79
+ React.createElement("span", { style: { marginLeft: 7, fontSize: '1.07em' } }, text)));
80
+ }
@@ -0,0 +1,15 @@
1
+ export * from '../utils/Emoji';
2
+ export * from './Link';
3
+ export * from './RepoLink';
4
+ export * from './P';
5
+ export * from './ReadingRecommendation';
6
+ export * from './Note';
7
+ export * from './ImportMeta';
8
+ export * from './HorizontalLine';
9
+ export * from './Supporters';
10
+ export * from './Sponsors';
11
+ export * from './Contributors';
12
+ export * from './Consulting';
13
+ export * from './CodeBlockTransformer';
14
+ export * from './Comment';
15
+ export * from './FileRemoved';
@@ -0,0 +1,15 @@
1
+ export * from '../utils/Emoji';
2
+ export * from './Link';
3
+ export * from './RepoLink';
4
+ export * from './P';
5
+ export * from './ReadingRecommendation';
6
+ export * from './Note';
7
+ export * from './ImportMeta';
8
+ export * from './HorizontalLine';
9
+ export * from './Supporters';
10
+ export * from './Sponsors';
11
+ export * from './Contributors';
12
+ export * from './Consulting';
13
+ export * from './CodeBlockTransformer';
14
+ export * from './Comment';
15
+ export * from './FileRemoved';
@@ -0,0 +1,3 @@
1
+ export { getConfig };
2
+ import { Config } from '../types/Config';
3
+ declare function getConfig(): Config;
@@ -0,0 +1,14 @@
1
+ export { getConfig };
2
+ import { assert, assertUsage } from '../utils/server';
3
+ function getConfig() {
4
+ // We use `@ts-ignore` because the DocPress user most likely didn't add `vite/client` in his `tsconfig.json`.
5
+ // @ts-ignore
6
+ var globResult = import.meta.glob('/**/docpress.config.*([a-zA-Z0-9])', { eager: true });
7
+ var files = Object.keys(globResult);
8
+ assertUsage(files.length >= 1, 'No DocPress config file found `docpress.config.(js|ts|tsx|...)`');
9
+ assertUsage(files.length === 1, "Found multiple `docpress.config.js` files: ".concat(files.map(function (f) { return "`".concat(f, "`"); }).join(', '), ". Define only one instead."));
10
+ var exports = Object.values(globResult)[0];
11
+ var config = exports.default || exports.config;
12
+ assert(config);
13
+ return config;
14
+ }
@@ -0,0 +1,16 @@
1
+ export { resolveHeadingsData };
2
+ import { NavItem } from '../navigation/Navigation';
3
+ import type { LinkData } from '../components';
4
+ import type { PageContextOriginal } from './resolvePageContext';
5
+ declare function resolveHeadingsData(pageContext: PageContextOriginal): {
6
+ navigationData: {
7
+ navItems: NavItem[];
8
+ navItemsAll: NavItem[];
9
+ currentUrl: string;
10
+ isDetachedPage: boolean;
11
+ };
12
+ linksAll: LinkData[];
13
+ isLandingPage: boolean;
14
+ pageTitle: string | null;
15
+ documentTitle: string;
16
+ };
@@ -0,0 +1,223 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ export { resolveHeadingsData };
22
+ import { assert, jsxToTextContent } from '../utils/server';
23
+ import { getConfig } from './getConfig';
24
+ import pc from '@brillout/picocolors';
25
+ function resolveHeadingsData(pageContext) {
26
+ var config = getConfig();
27
+ {
28
+ var headings = config.headings, headingsDetached = config.headingsDetached;
29
+ assertHeadingsDefinition(__spreadArray(__spreadArray([], headings, true), headingsDetached, true));
30
+ }
31
+ var resolved = getHeadingsResolved(config);
32
+ var headingsDetachedResolved = resolved.headingsDetachedResolved;
33
+ var headingsResolved = resolved.headingsResolved;
34
+ var _a = getActiveHeading(headingsResolved, headingsDetachedResolved, pageContext), activeHeading = _a.activeHeading, isDetachedPage = _a.isDetachedPage;
35
+ var _b = getTitles(activeHeading, pageContext, config), documentTitle = _b.documentTitle, isLandingPage = _b.isLandingPage, pageTitle = _b.pageTitle;
36
+ var pageSectionsResolved = getPageSectionsResolved(pageContext, activeHeading);
37
+ var linksAll = __spreadArray(__spreadArray(__spreadArray([], pageSectionsResolved.map(pageSectionToLinkData), true), headingsResolved.map(headingToLinkData), true), headingsDetachedResolved.map(headingToLinkData), true);
38
+ var navigationData;
39
+ {
40
+ var currentUrl_1 = pageContext.urlPathname;
41
+ var navItemsPageSections = pageSectionsResolved
42
+ .filter(function (pageSection) { return pageSection.pageSectionLevel === 2; })
43
+ .map(pageSectionToNavItem);
44
+ if (isDetachedPage) {
45
+ var navItemsAll = headingsResolved;
46
+ var navItems = __spreadArray([headingToNavItem(activeHeading)], navItemsPageSections, true);
47
+ navigationData = {
48
+ isDetachedPage: true,
49
+ navItems: navItems,
50
+ navItemsAll: navItemsAll,
51
+ currentUrl: currentUrl_1,
52
+ };
53
+ }
54
+ else {
55
+ var navItemsAll_1 = headingsResolved.map(headingToNavItem);
56
+ var activeHeadingIndex_1 = navItemsAll_1.findIndex(function (navItem) { return navItem.url === currentUrl_1; });
57
+ assert(activeHeadingIndex_1 >= 0);
58
+ navItemsPageSections.forEach(function (navItem, i) {
59
+ navItemsAll_1.splice(activeHeadingIndex_1 + 1 + i, 0, navItem);
60
+ });
61
+ navigationData = {
62
+ isDetachedPage: false,
63
+ navItems: navItemsAll_1,
64
+ navItemsAll: navItemsAll_1,
65
+ currentUrl: currentUrl_1,
66
+ };
67
+ }
68
+ }
69
+ var pageContextAddendum = {
70
+ navigationData: navigationData,
71
+ linksAll: linksAll,
72
+ isLandingPage: isLandingPage,
73
+ pageTitle: pageTitle,
74
+ documentTitle: documentTitle,
75
+ };
76
+ return pageContextAddendum;
77
+ }
78
+ function headingToNavItem(heading) {
79
+ return {
80
+ level: heading.level,
81
+ url: heading.url,
82
+ title: heading.title,
83
+ titleInNav: heading.titleInNav,
84
+ };
85
+ }
86
+ function headingToLinkData(heading) {
87
+ return {
88
+ url: heading.url,
89
+ title: heading.title,
90
+ linkBreadcrumb: heading.linkBreadcrumb,
91
+ sectionTitles: heading.sectionTitles,
92
+ };
93
+ }
94
+ function pageSectionToNavItem(pageSection) {
95
+ return {
96
+ level: pageSection.pageSectionLevel + 1,
97
+ url: pageSection.url,
98
+ title: pageSection.title,
99
+ titleInNav: pageSection.titleInNav,
100
+ };
101
+ }
102
+ function pageSectionToLinkData(pageSection) {
103
+ return {
104
+ url: pageSection.url,
105
+ title: pageSection.title,
106
+ linkBreadcrumb: pageSection.linkBreadcrumb,
107
+ };
108
+ }
109
+ function getTitles(activeHeading, pageContext, config) {
110
+ var url = pageContext.urlPathname;
111
+ var isLandingPage = url === '/';
112
+ var title = activeHeading.title;
113
+ var pageTitle = isLandingPage ? null : title;
114
+ var documentTitle = activeHeading.titleDocument || jsxToTextContent(title);
115
+ if (!isLandingPage) {
116
+ documentTitle += ' | ' + config.projectInfo.projectName;
117
+ }
118
+ if (isLandingPage) {
119
+ pageTitle = null;
120
+ }
121
+ return { documentTitle: documentTitle, isLandingPage: isLandingPage, pageTitle: pageTitle };
122
+ }
123
+ function getActiveHeading(headingsResolved, headingsDetachedResolved, pageContext) {
124
+ var _a;
125
+ var activeHeading = null;
126
+ var urlPathname = pageContext.urlPathname;
127
+ assert(urlPathname);
128
+ headingsResolved.forEach(function (heading) {
129
+ if (heading.url === urlPathname) {
130
+ activeHeading = heading;
131
+ assert(heading.level === 2, { pageUrl: urlPathname, heading: heading });
132
+ }
133
+ });
134
+ var isDetachedPage = !activeHeading;
135
+ if (!activeHeading) {
136
+ activeHeading = (_a = headingsDetachedResolved.find(function (_a) {
137
+ var url = _a.url;
138
+ return urlPathname === url;
139
+ })) !== null && _a !== void 0 ? _a : null;
140
+ }
141
+ if (!activeHeading) {
142
+ throw new Error(__spreadArray([
143
+ "URL ".concat(pc.bold(urlPathname), " not found in following URLs:")
144
+ ], headingsResolved
145
+ .map(function (h) { return " ".concat(h.url); })
146
+ .filter(Boolean)
147
+ .sort(), true).join('\n'));
148
+ }
149
+ return { activeHeading: activeHeading, isDetachedPage: isDetachedPage };
150
+ }
151
+ function getPageSectionsResolved(pageContext, activeHeading) {
152
+ var _a;
153
+ var pageSections = (_a = pageContext.exports.pageSectionsExport) !== null && _a !== void 0 ? _a : [];
154
+ var pageSectionsResolved = pageSections.map(function (pageSection) {
155
+ var _a;
156
+ var pageSectionTitle = pageSection.pageSectionTitle;
157
+ var url = pageSection.pageSectionId === null ? null : '#' + pageSection.pageSectionId;
158
+ var pageSectionResolved = {
159
+ url: url,
160
+ title: pageSectionTitle,
161
+ linkBreadcrumb: __spreadArray([activeHeading.title], ((_a = activeHeading.linkBreadcrumb) !== null && _a !== void 0 ? _a : []), true),
162
+ titleInNav: pageSectionTitle,
163
+ pageSectionLevel: pageSection.pageSectionLevel,
164
+ };
165
+ return pageSectionResolved;
166
+ });
167
+ if (activeHeading === null || activeHeading === void 0 ? void 0 : activeHeading.sectionTitles) {
168
+ activeHeading.sectionTitles.forEach(function (sectionTitle) {
169
+ var pageSectionTitles = pageSections.map(function (h) { return h.pageSectionTitle; });
170
+ assert(pageSectionTitles.includes(sectionTitle), { pageHeadingTitles: pageSectionTitles, sectionTitle: sectionTitle });
171
+ });
172
+ }
173
+ return pageSectionsResolved;
174
+ }
175
+ function getHeadingsResolved(config) {
176
+ var headingsWithoutBreadcrumb = config.headings.map(function (heading) {
177
+ var titleInNav = heading.titleInNav || heading.title;
178
+ /* TODO: remove this and all realted code
179
+ let titleInNavParsed: JSX.Element
180
+ titleInNavParsed = parseTitle(titleInNav)
181
+ if ('titleEmoji' in heading) {
182
+ assert(heading.titleEmoji)
183
+ titleInNavParsed = withEmoji(heading.titleEmoji, titleInNavParsed)
184
+ }
185
+ */
186
+ var headingResolved = __assign(__assign({}, heading), { titleInNav: titleInNav });
187
+ return headingResolved;
188
+ });
189
+ var headingsResolved = [];
190
+ headingsWithoutBreadcrumb.forEach(function (heading) {
191
+ var linkBreadcrumb = getHeadingsBreadcrumb(heading, headingsResolved);
192
+ headingsResolved.push(__assign(__assign({}, heading), { linkBreadcrumb: linkBreadcrumb }));
193
+ });
194
+ var headingsDetachedResolved = config.headingsDetached.map(function (headingsDetached) {
195
+ var url = headingsDetached.url;
196
+ assert(headingsResolved.find(function (heading) { return heading.url === url; }) === undefined, "remove ".concat(headingsDetached.url, " from headingsDetached"));
197
+ return __assign(__assign({}, headingsDetached), { level: 2, titleInNav: headingsDetached.title, linkBreadcrumb: null });
198
+ });
199
+ return { headingsResolved: headingsResolved, headingsDetachedResolved: headingsDetachedResolved };
200
+ }
201
+ function getHeadingsBreadcrumb(heading, headings) {
202
+ var linkBreadcrumb = [];
203
+ var levelCurrent = heading.level;
204
+ headings
205
+ .slice()
206
+ .reverse()
207
+ .forEach(function (parentCandidate) {
208
+ var isParent = parentCandidate.level < levelCurrent;
209
+ if (isParent) {
210
+ levelCurrent = parentCandidate.level;
211
+ linkBreadcrumb.push(parentCandidate.title);
212
+ }
213
+ });
214
+ return linkBreadcrumb;
215
+ }
216
+ function assertHeadingsDefinition(headings) {
217
+ headings.forEach(function (heading) {
218
+ if (heading.url) {
219
+ var url = heading.url;
220
+ assert(url.startsWith('/'));
221
+ }
222
+ });
223
+ }
@@ -0,0 +1,38 @@
1
+ export { resolvePageContext };
2
+ export type { PageContextOriginal };
3
+ export type { PageContextResolved };
4
+ export type { Exports };
5
+ import type { PageContextServer } from 'vike/types';
6
+ import type { PageSection } from '../parsePageSections';
7
+ type Exports = {
8
+ pageSectionsExport?: PageSection[];
9
+ };
10
+ type PageContextOriginal = PageContextServer;
11
+ type PageContextResolved = ReturnType<typeof resolvePageContext>;
12
+ declare function resolvePageContext(pageContext: PageContextOriginal): {
13
+ navigationData: {
14
+ navItems: import("../navigation/Navigation").NavItem[];
15
+ navItemsAll: import("../navigation/Navigation").NavItem[];
16
+ currentUrl: string;
17
+ isDetachedPage: boolean;
18
+ };
19
+ linksAll: import("../components").LinkData[];
20
+ isLandingPage: boolean;
21
+ pageTitle: string | null;
22
+ documentTitle: string;
23
+ } & {
24
+ urlPathname: string;
25
+ meta: {
26
+ faviconUrl: string;
27
+ twitterHandle: string;
28
+ bannerUrl: string | undefined;
29
+ websiteUrl: string;
30
+ tagline: string;
31
+ algolia: {
32
+ appId: string;
33
+ apiKey: string;
34
+ indexName: string;
35
+ } | null;
36
+ };
37
+ config: import("../types/Config").Config;
38
+ };
@@ -0,0 +1,23 @@
1
+ export { resolvePageContext };
2
+ import { objectAssign } from '../utils/server';
3
+ import { getConfig } from './getConfig';
4
+ import { resolveHeadingsData } from './resolveHeadingsData';
5
+ function resolvePageContext(pageContext) {
6
+ var pageContextResolved = {};
7
+ objectAssign(pageContextResolved, resolveHeadingsData(pageContext));
8
+ var config = getConfig();
9
+ var faviconUrl = config.faviconUrl, algolia = config.algolia, tagline = config.tagline, twitterHandle = config.twitterHandle, bannerUrl = config.bannerUrl, websiteUrl = config.websiteUrl;
10
+ objectAssign(pageContextResolved, {
11
+ urlPathname: pageContext.urlPathname, // TODO: remove
12
+ meta: {
13
+ faviconUrl: faviconUrl,
14
+ twitterHandle: twitterHandle,
15
+ bannerUrl: bannerUrl,
16
+ websiteUrl: websiteUrl,
17
+ tagline: tagline,
18
+ algolia: algolia,
19
+ },
20
+ config: config,
21
+ });
22
+ return pageContextResolved;
23
+ }
@@ -0,0 +1,9 @@
1
+ export { maintainers };
2
+ import React from 'react';
3
+ type Maintainer = {
4
+ username: string;
5
+ firstName: string;
6
+ roles: React.ReactNode[];
7
+ consultingUrl?: string;
8
+ };
9
+ declare const maintainers: Maintainer[];