@brillout/docpress 0.5.38 → 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.
- package/MobileHeader.tsx +68 -0
- package/PageLayout.css +42 -0
- package/PageLayout.tsx +39 -0
- package/algolia/DocSearch.css +34 -0
- package/algolia/DocSearch.ts +62 -0
- package/autoScrollNav.ts +36 -0
- package/components/CodeBlockTransformer.css +9 -0
- package/components/CodeBlockTransformer.tsx +18 -0
- package/components/Comment.tsx +7 -0
- package/components/Consulting.tsx +47 -0
- package/components/Contributors.tsx +113 -0
- package/components/EditPageNote.tsx +18 -0
- package/components/HorizontalLine.tsx +20 -0
- package/components/ImportMeta.tsx +11 -0
- package/components/Link.tsx +144 -0
- package/components/Note.css +54 -0
- package/components/Note.tsx +78 -0
- package/components/P.css +8 -0
- package/components/P.tsx +8 -0
- package/components/ReadingRecommendation.tsx +56 -0
- package/components/RepoLink.tsx +24 -0
- package/components/Sponsors/label.draft.svg +108 -0
- package/components/Sponsors.tsx +218 -0
- package/components/Supporters.tsx +136 -0
- package/{dist/components → components}/features/FeatureList.css +10 -2
- package/components/features/FeatureList.tsx +114 -0
- package/components/features/initFeatureList.ts +66 -0
- package/components/index.ts +15 -0
- package/config/getConfig.ts +18 -0
- package/config/resolveConfig/resolveHeading.ts +0 -0
- package/config/resolvePageContext.ts +186 -0
- package/css/button.css +7 -0
- package/css/code/block.css +36 -0
- package/css/code/inline.css +27 -0
- package/css/code.css +20 -0
- package/css/colorize-on-hover.css +29 -0
- package/css/font.css +25 -0
- package/css/heading.css +45 -0
- package/css/index.css +12 -0
- package/css/link.css +17 -0
- package/css/reset.css +12 -0
- package/css/table.css +14 -0
- package/css/tooltip.css +11 -0
- package/data/maintainersList.tsx +92 -0
- package/data/sponsorsList.ts +147 -0
- package/dist/markdownHeadingsVitePlugin.d.ts +13 -0
- package/dist/markdownHeadingsVitePlugin.js +170 -0
- package/dist/utils/assert.d.ts +6 -0
- package/dist/utils/assert.js +48 -0
- package/dist/utils/determineSectionUrlHash.d.ts +4 -0
- package/dist/utils/determineSectionUrlHash.js +38 -0
- package/dist/vite.config.d.ts +3 -0
- package/dist/vite.config.js +32 -0
- package/index.ts +4 -0
- package/installSectionUrlHashs.ts +60 -0
- package/markdownHeadingsVitePlugin.ts +150 -0
- package/navigation/Navigation-highlight.css +41 -0
- package/navigation/Navigation-items.css +119 -0
- package/navigation/Navigation-layout.css +127 -0
- package/navigation/Navigation.client.ts +43 -0
- package/navigation/Navigation.css +3 -0
- package/navigation/Navigation.tsx +211 -0
- package/navigation/NavigationHeader.tsx +111 -0
- package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
- package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
- package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +116 -0
- package/package.json +27 -47
- package/parseEmojis.ts +35 -0
- package/parseTitle.ts +139 -0
- package/renderer/client.ts +4 -0
- package/renderer/onRenderHtml.tsx +69 -0
- package/renderer/usePageContext.tsx +25 -0
- package/tsconfig.json +15 -0
- package/tsconfig.vite-config.json +7 -0
- package/types/Config.ts +46 -0
- package/types/Heading.ts +49 -0
- package/utils/Emoji/Emoji.ts +224 -0
- package/utils/Emoji/assets.ts +9 -0
- package/utils/Emoji/index.ts +1 -0
- package/utils/Emoji/mountain.svg +1 -0
- package/utils/assert.ts +51 -0
- package/utils/client.ts +2 -0
- package/utils/determineSectionUrlHash.ts +44 -0
- package/utils/filesystemPathHandling.ts +42 -0
- package/utils/filter.ts +12 -0
- package/utils/isBrowser.ts +5 -0
- package/utils/jsxToTextContent.ts +11 -0
- package/utils/objectAssign.ts +9 -0
- package/utils/server.ts +7 -0
- package/vite.config.ts +36 -0
- package/bin.js +0 -3
- package/dist/chunk-2ZTPUQGS.js +0 -58
- package/dist/chunk-3QC7HYIF.js +0 -7
- package/dist/chunk-MGOI4AFO.js +0 -165
- package/dist/chunk-NVJING6T.js +0 -91
- package/dist/chunk-QWL3MA4E.js +0 -171
- package/dist/chunk-UN23G34B.js +0 -157
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -34
- package/dist/components/features/FeatureList.d.ts +0 -13
- package/dist/components/features/FeatureList.js +0 -7
- package/dist/components/features/initFeatureList.d.ts +0 -3
- package/dist/components/features/initFeatureList.js +0 -59
- package/dist/devServer-JKH6U5PF.js +0 -36
- package/dist/index.css +0 -120
- package/dist/index.d.ts +0 -225
- package/dist/index.js +0 -949
- package/dist/renderer/_default.page.client.css +0 -318
- package/dist/renderer/_default.page.client.d.ts +0 -1
- package/dist/renderer/_default.page.client.js +0 -218
- package/dist/renderer/_default.page.server.css +0 -310
- package/dist/renderer/_default.page.server.d.ts +0 -22
- package/dist/renderer/_default.page.server.js +0 -665
- package/readme.md +0 -5
- /package/{dist/label-MP75CTIA.svg → components/Sponsors/label.svg} +0 -0
- /package/{dist/medalBronze-CO4CTUR4.svg → components/Sponsors/medalBronze.svg} +0 -0
- /package/{dist/medalGold-UP6A73FL.svg → components/Sponsors/medalGold.svg} +0 -0
- /package/{dist/medalSilver-FAPGGOBN.svg → components/Sponsors/medalSilver.svg} +0 -0
- /package/{dist/chevron-R2IYJD62.svg → components/features/chevron.svg} +0 -0
- /package/{dist/Inter-Var-IOAEQULN.ttf → css/Inter-Var.ttf} +0 -0
- /package/{dist/alignable-B4QZV4X7.svg → data/sponsorsList/companyLogos/alignable.svg} +0 -0
- /package/{dist/bluefin-JQABZFGV.svg → data/sponsorsList/companyLogos/bluefin.svg} +0 -0
- /package/{dist/burdaforward-EUGURYZY.png → data/sponsorsList/companyLogos/burdaforward.png} +0 -0
- /package/{dist/contra-WLZBOPBV.svg → data/sponsorsList/companyLogos/contra.svg} +0 -0
- /package/{dist/ecosia-OYRLTR5T.svg → data/sponsorsList/companyLogos/ecosia.svg} +0 -0
- /package/{dist/inlang-GFRWND6X.png → data/sponsorsList/companyLogos/inlang.png} +0 -0
- /package/{dist/optimizers-SFEZF3NW.svg → data/sponsorsList/companyLogos/optimizers.svg} +0 -0
- /package/{dist/sourcegraph-YR2HADLS.svg → data/sponsorsList/companyLogos/sourcegraph.svg} +0 -0
- /package/{dist/changelog-IPI5F42D.svg → icons/changelog.svg} +0 -0
- /package/{dist/discord-JD33TUSF.svg → icons/discord.svg} +0 -0
- /package/{dist/github-P5ZSKN2N.svg → icons/github.svg} +0 -0
- /package/{dist/heart-OINVKOXO.svg → icons/heart.svg} +0 -0
- /package/{dist/languages-KXPKJFQL.svg → icons/languages.svg} +0 -0
- /package/{dist/people-72KKQHU4.svg → icons/people.svg} +0 -0
- /package/{dist/twitter-I7DXDN3J.svg → icons/twitter.svg} +0 -0
- /package/{dist/chevron-K3WPYLOP.svg → navigation/navigation-fullscreen/chevron.svg} +0 -0
- /package/{dist/close-IQXTDOHV.svg → navigation/navigation-fullscreen/close.svg} +0 -0
- /package/{dist/compass-2RWQU3E4.svg → utils/Emoji/compass.svg} +0 -0
- /package/{dist/engine-6Q6VSCVA.png → utils/Emoji/engine.png} +0 -0
- /package/{dist/mechanical-arm-TR7IQQMG.svg → utils/Emoji/mechanical-arm.svg} +0 -0
- /package/{dist/road-fork-3WZLW3HB.svg → utils/Emoji/road-fork.svg} +0 -0
- /package/{dist/shield-CU45RG5C.svg → utils/Emoji/shield.svg} +0 -0
- /package/{dist/typescript-ALIPKLRM.svg → utils/Emoji/typescript.svg} +0 -0
package/css/table.css
ADDED
package/css/tooltip.css
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export { maintainers }
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
type Maintainer = {
|
|
6
|
+
username: string
|
|
7
|
+
firstName: string
|
|
8
|
+
roles: React.ReactNode[]
|
|
9
|
+
consultingUrl?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const maintainers: Maintainer[] = [
|
|
13
|
+
{
|
|
14
|
+
username: 'brillout',
|
|
15
|
+
firstName: 'Rom',
|
|
16
|
+
roles: [
|
|
17
|
+
<>Vike Core (Lead Maintainer, Creator)</>,
|
|
18
|
+
<>
|
|
19
|
+
<code>vike-react</code> (Lead Maintainer, Creator)
|
|
20
|
+
</>,
|
|
21
|
+
<>
|
|
22
|
+
<code>vike-vue</code> (Contributor)
|
|
23
|
+
</>
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
username: 'magne4000',
|
|
28
|
+
firstName: 'Joël',
|
|
29
|
+
roles: [
|
|
30
|
+
<>Bati (Lead Maintainer, Creator)</>,
|
|
31
|
+
<>
|
|
32
|
+
<code>vike-solid</code> (Lead Maintainer, Creator)
|
|
33
|
+
</>,
|
|
34
|
+
<>Vike Core (Contributor)</>
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
username: 'AurelienLourot',
|
|
39
|
+
firstName: 'Aurélien',
|
|
40
|
+
roles: [
|
|
41
|
+
<>
|
|
42
|
+
<code>vike-vue</code> (Lead Maintainer, Creator)
|
|
43
|
+
</>,
|
|
44
|
+
<>
|
|
45
|
+
<code>vike-react</code> (Contributor)
|
|
46
|
+
</>,
|
|
47
|
+
<>Vike Core (Contributor)</>
|
|
48
|
+
]
|
|
49
|
+
// consultingUrl: 'https://lourot.dev/'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
username: 'nitedani',
|
|
53
|
+
firstName: 'Dániel',
|
|
54
|
+
roles: [
|
|
55
|
+
<>
|
|
56
|
+
<code>vike-react-query</code> (Lead Maintainer, Creator)
|
|
57
|
+
</>,
|
|
58
|
+
<>
|
|
59
|
+
<code>vike-angular</code> (Lead Maintainer, Creator)
|
|
60
|
+
</>,
|
|
61
|
+
<>Vike Core (Contributor)</>
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
username: 'phonzammi',
|
|
66
|
+
firstName: 'Muhammad',
|
|
67
|
+
roles: [
|
|
68
|
+
<>
|
|
69
|
+
<code>vike-vue</code> (Contributor)
|
|
70
|
+
</>,
|
|
71
|
+
<>
|
|
72
|
+
<code>vike-solid</code> (Contributor)
|
|
73
|
+
</>,
|
|
74
|
+
<>
|
|
75
|
+
<code>vike-react</code> (Contributor)
|
|
76
|
+
</>
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
username: '4350pChris',
|
|
81
|
+
firstName: 'Chris',
|
|
82
|
+
roles: [
|
|
83
|
+
<>
|
|
84
|
+
<code>vike-pinia</code> (Lead Maintainer, Creator)
|
|
85
|
+
</>,
|
|
86
|
+
<>
|
|
87
|
+
<code>vike-vue</code> (Contributor)
|
|
88
|
+
</>,
|
|
89
|
+
<>Vike Core (Contributor)</>
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export { sponsorsList }
|
|
2
|
+
|
|
3
|
+
import type { Sponsor } from '../components/Sponsors'
|
|
4
|
+
import contraLogo from './sponsorsList/companyLogos/contra.svg'
|
|
5
|
+
import optimizersLogo from './sponsorsList/companyLogos/optimizers.svg'
|
|
6
|
+
import sourcegraphLogo from './sponsorsList/companyLogos/sourcegraph.svg'
|
|
7
|
+
import burdaforwardLogo from './sponsorsList/companyLogos/burdaforward.png'
|
|
8
|
+
import ecosiaLogo from './sponsorsList/companyLogos/ecosia.svg'
|
|
9
|
+
import inlangLogo from './sponsorsList/companyLogos/inlang.png'
|
|
10
|
+
import bluefinLogo from './sponsorsList/companyLogos/bluefin.svg'
|
|
11
|
+
import alignableLogo from './sponsorsList/companyLogos/alignable.svg'
|
|
12
|
+
|
|
13
|
+
const individuals: Sponsor[] = [
|
|
14
|
+
{ username: 'arp' },
|
|
15
|
+
{ username: 'tlancina' },
|
|
16
|
+
{ username: 'shishkin17' },
|
|
17
|
+
{ username: 'royalswe' },
|
|
18
|
+
{ username: 'lebretont' },
|
|
19
|
+
{ username: 'xar' },
|
|
20
|
+
{ username: 'NicoZweifel' },
|
|
21
|
+
{ username: 'mariuslian' },
|
|
22
|
+
{ username: 'shortpoet' },
|
|
23
|
+
{ username: 'sqs' },
|
|
24
|
+
{ username: 'dylmye' },
|
|
25
|
+
{ username: 'isakura313' },
|
|
26
|
+
{ username: 'rivatove' },
|
|
27
|
+
{ username: 'SMKJALLAD' },
|
|
28
|
+
{ username: 'routinghub' },
|
|
29
|
+
{ username: 'LostCrew' }, // Ecosia
|
|
30
|
+
{ username: 'jakubfiala' }, // Ecosia
|
|
31
|
+
{ username: 'HarshwardhanSingh' },
|
|
32
|
+
{ username: 'd3x7r0' },
|
|
33
|
+
{ username: 'ChristophP' }, // BurdaForward
|
|
34
|
+
{ username: 'msiegenthaler' },
|
|
35
|
+
{ username: 'linkyard' },
|
|
36
|
+
{ username: 'AnukarOP' },
|
|
37
|
+
{ username: 'RoyMcCrain' },
|
|
38
|
+
{ username: 'chrisvander' }, // Bluefin
|
|
39
|
+
{ username: 'EralChen' },
|
|
40
|
+
{ username: '3dyuval' },
|
|
41
|
+
{ username: 'talzion12' },
|
|
42
|
+
{ username: 'felixhaeberle' },
|
|
43
|
+
{ username: 'apappas1129' },
|
|
44
|
+
/* 404
|
|
45
|
+
{ username: 'agalbenus' },
|
|
46
|
+
*/
|
|
47
|
+
{ username: 'phiberber' },
|
|
48
|
+
{ username: 'cookieplace' },
|
|
49
|
+
{ username: 'JiangWeixian' },
|
|
50
|
+
{ username: 'harrytran998' },
|
|
51
|
+
{ username: 'alexturpin' },
|
|
52
|
+
{ username: 'gu-stav' },
|
|
53
|
+
{ username: 'YannBirba' },
|
|
54
|
+
{ username: 'fi3ework' },
|
|
55
|
+
{ username: 'EJM-Company' },
|
|
56
|
+
{ username: 'Nelie-Taylor' },
|
|
57
|
+
{ username: 'fortezhuo' },
|
|
58
|
+
{ username: 'nshelia' },
|
|
59
|
+
{ username: 'marcusway' },
|
|
60
|
+
{ username: 'edikdeisling' },
|
|
61
|
+
{ username: 'AurelienLourot' },
|
|
62
|
+
{ username: 'jahredhope' },
|
|
63
|
+
{ username: 'charlieforward9' },
|
|
64
|
+
{ username: 'leonmondria' },
|
|
65
|
+
{ username: 'jscottsf' },
|
|
66
|
+
{ username: 'micah-redwood' },
|
|
67
|
+
{ username: 'nicka-redwood' },
|
|
68
|
+
{ username: 'ser1us' },
|
|
69
|
+
{ username: 'nikitavoloboev' },
|
|
70
|
+
{ username: 'samuelstroschein' },
|
|
71
|
+
{ username: 'npacucci' },
|
|
72
|
+
{ username: 'szarapka' },
|
|
73
|
+
{ username: 'techniath' },
|
|
74
|
+
{ username: 'DannyZB' },
|
|
75
|
+
{ username: 'pieperz' },
|
|
76
|
+
{ username: 'hemengke1997' },
|
|
77
|
+
{ username: 'spacedawwwg' },
|
|
78
|
+
{ username: 'arthurgailes' },
|
|
79
|
+
{ username: 'stackblitz' },
|
|
80
|
+
{ username: 'codthing' },
|
|
81
|
+
{ username: 'Junaidhkn' },
|
|
82
|
+
{ username: 'zgfdev' }
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
const companies: Sponsor[] = [
|
|
86
|
+
{
|
|
87
|
+
companyName: 'Contra',
|
|
88
|
+
companyLogo: contraLogo,
|
|
89
|
+
plan: 'silver',
|
|
90
|
+
website: 'https://contra.com',
|
|
91
|
+
github: 'contra'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
companyName: 'Inlang',
|
|
95
|
+
companyLogo: inlangLogo,
|
|
96
|
+
plan: 'silver',
|
|
97
|
+
website: 'https://inlang.com/',
|
|
98
|
+
github: 'opral'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
companyName: 'Alignable',
|
|
102
|
+
companyLogo: alignableLogo,
|
|
103
|
+
plan: 'silver',
|
|
104
|
+
website: 'https://www.alignable.com/',
|
|
105
|
+
github: 'AlignableUser'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
companyName: 'Sourcegraph',
|
|
109
|
+
companyLogo: sourcegraphLogo,
|
|
110
|
+
plan: 'bronze',
|
|
111
|
+
website: 'https://sourcegraph.com',
|
|
112
|
+
github: 'sourcegraph'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
companyName: 'Optimizers',
|
|
116
|
+
companyLogo: optimizersLogo,
|
|
117
|
+
plan: 'bronze',
|
|
118
|
+
website: 'https://www.optimizers.nl/',
|
|
119
|
+
divSize: {
|
|
120
|
+
padding: 20
|
|
121
|
+
},
|
|
122
|
+
github: 'OptimizersGroup'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
companyName: 'BurdaFoward',
|
|
126
|
+
companyLogo: burdaforwardLogo,
|
|
127
|
+
plan: 'bronze',
|
|
128
|
+
website: 'https://www.burda-forward.de',
|
|
129
|
+
github: 'BurdaForward'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
companyName: 'Ecosia',
|
|
133
|
+
companyLogo: ecosiaLogo,
|
|
134
|
+
plan: 'bronze',
|
|
135
|
+
website: 'https://ecosia.org',
|
|
136
|
+
github: 'ecosia'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
companyName: 'Bluefin',
|
|
140
|
+
companyLogo: bluefinLogo,
|
|
141
|
+
plan: 'indie',
|
|
142
|
+
website: 'https://www.bluefin.one',
|
|
143
|
+
github: 'bluefin-clinical'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
const sponsorsList: Sponsor[] = [...companies, ...individuals]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { markdownHeadingsVitePlugin };
|
|
2
|
+
export type { MarkdownHeading };
|
|
3
|
+
type MarkdownHeading = {
|
|
4
|
+
title: string;
|
|
5
|
+
headingId: string | null;
|
|
6
|
+
headingLevel: number;
|
|
7
|
+
titleAddendum?: string;
|
|
8
|
+
};
|
|
9
|
+
declare function markdownHeadingsVitePlugin(): {
|
|
10
|
+
name: string;
|
|
11
|
+
enforce: string;
|
|
12
|
+
transform: (code: string, id: string) => Promise<string | undefined>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export { markdownHeadingsVitePlugin };
|
|
38
|
+
import { assert } from './utils/assert.js';
|
|
39
|
+
import { determineSectionUrlHash } from './utils/determineSectionUrlHash.js';
|
|
40
|
+
import os from 'os';
|
|
41
|
+
function markdownHeadingsVitePlugin() {
|
|
42
|
+
var _this = this;
|
|
43
|
+
return {
|
|
44
|
+
name: 'mdx-headings',
|
|
45
|
+
enforce: 'pre',
|
|
46
|
+
transform: function (code, id) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
+
var codeNew;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
if (!id.endsWith('+Page.mdx')) {
|
|
50
|
+
return [2 /*return*/];
|
|
51
|
+
}
|
|
52
|
+
codeNew = transform(code);
|
|
53
|
+
return [2 /*return*/, codeNew];
|
|
54
|
+
});
|
|
55
|
+
}); }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function transform(code) {
|
|
59
|
+
var headings = [];
|
|
60
|
+
var isCodeBlock = false;
|
|
61
|
+
var codeNew = code
|
|
62
|
+
.split('\n')
|
|
63
|
+
.map(function (line) {
|
|
64
|
+
// Skip code blocks, e.g.
|
|
65
|
+
// ~~~md
|
|
66
|
+
// # Markdown Example
|
|
67
|
+
// Bla
|
|
68
|
+
// ~~~
|
|
69
|
+
if (line.startsWith('~~~') || line.startsWith('```')) {
|
|
70
|
+
isCodeBlock = !isCodeBlock;
|
|
71
|
+
return line;
|
|
72
|
+
}
|
|
73
|
+
if (isCodeBlock) {
|
|
74
|
+
return line;
|
|
75
|
+
}
|
|
76
|
+
if (line.startsWith('#')) {
|
|
77
|
+
var _a = parseMarkdownHeading(line), headingId = _a.headingId, headingLevel = _a.headingLevel, title = _a.title, headingHtml = _a.headingHtml;
|
|
78
|
+
headings.push({ headingId: headingId, headingLevel: headingLevel, title: title });
|
|
79
|
+
return headingHtml;
|
|
80
|
+
}
|
|
81
|
+
return line;
|
|
82
|
+
})
|
|
83
|
+
.join('\n');
|
|
84
|
+
var headingsExportCode = "export const headings = [".concat(headings
|
|
85
|
+
.map(function (heading) { return JSON.stringify(heading); })
|
|
86
|
+
.join(', '), "];");
|
|
87
|
+
codeNew += "\n\n".concat(headingsExportCode, "\n");
|
|
88
|
+
return codeNew;
|
|
89
|
+
}
|
|
90
|
+
function parseMarkdownHeading(line) {
|
|
91
|
+
var _a;
|
|
92
|
+
var _b = line.split(' '), lineBegin = _b[0], lineWords = _b.slice(1);
|
|
93
|
+
assert(lineBegin.split('#').join('') === '', { line: line, lineWords: lineWords });
|
|
94
|
+
var headingLevel = lineBegin.length;
|
|
95
|
+
var titleMdx = lineWords.join(' ');
|
|
96
|
+
assert(!titleMdx.startsWith(' '), { line: line, lineWords: lineWords });
|
|
97
|
+
assert(titleMdx, { line: line, lineWords: lineWords });
|
|
98
|
+
var headingMdx = {
|
|
99
|
+
title: titleMdx,
|
|
100
|
+
anchor: titleMdx
|
|
101
|
+
};
|
|
102
|
+
{
|
|
103
|
+
// Support custom anchor like: `## title{#custom-anchor}`
|
|
104
|
+
var customAnchor = (_a = /(?<={#).*(?=})/g.exec(titleMdx)) === null || _a === void 0 ? void 0 : _a[0];
|
|
105
|
+
if (customAnchor) {
|
|
106
|
+
headingMdx.anchor = customAnchor;
|
|
107
|
+
headingMdx.title = titleMdx.replace(/{#.*}/g, '');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var headingId = determineSectionUrlHash(headingMdx.anchor);
|
|
111
|
+
var title = headingMdx.title;
|
|
112
|
+
var titleParsed = parseTitle(title);
|
|
113
|
+
assert(headingId === null || headingId.length > 0);
|
|
114
|
+
var headingAttrId = headingId === null ? '' : " id=\"".concat(headingId, "\"");
|
|
115
|
+
var headingHtml = "<h".concat(headingLevel).concat(headingAttrId, ">").concat(titleParsed, "</h").concat(headingLevel, ">");
|
|
116
|
+
var heading = { headingLevel: headingLevel, title: title, headingId: headingId, headingHtml: headingHtml };
|
|
117
|
+
return heading;
|
|
118
|
+
}
|
|
119
|
+
function parseTitle(titleMarkdown) {
|
|
120
|
+
var parts = [];
|
|
121
|
+
var current;
|
|
122
|
+
titleMarkdown.split('').forEach(function (letter) {
|
|
123
|
+
if (letter === '`') {
|
|
124
|
+
if ((current === null || current === void 0 ? void 0 : current.nodeType) === 'code') {
|
|
125
|
+
// </code>
|
|
126
|
+
parts.push(current);
|
|
127
|
+
current = undefined;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// <code>
|
|
131
|
+
if (current) {
|
|
132
|
+
parts.push(current);
|
|
133
|
+
}
|
|
134
|
+
current = { nodeType: 'code', content: '' };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
if (!current) {
|
|
139
|
+
current = { nodeType: 'text', content: '' };
|
|
140
|
+
}
|
|
141
|
+
current.content += letter;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (current) {
|
|
145
|
+
parts.push(current);
|
|
146
|
+
}
|
|
147
|
+
var titleHtml = parts
|
|
148
|
+
.map(function (part) {
|
|
149
|
+
if (part.nodeType === 'code') {
|
|
150
|
+
return "<code>".concat(serializeText(part.content), "</code>");
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
assert(part.nodeType === 'text', { parts: parts });
|
|
154
|
+
return serializeText(part.content);
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
.join('');
|
|
158
|
+
return titleHtml;
|
|
159
|
+
function serializeText(text) {
|
|
160
|
+
var textEscaped = text.split("'").join("\\'");
|
|
161
|
+
// https://github.com/brillout/docpress/pull/2
|
|
162
|
+
if (isWindows()) {
|
|
163
|
+
textEscaped = textEscaped.replace(/\r/, '');
|
|
164
|
+
}
|
|
165
|
+
return "{'".concat(textEscaped, "'}");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function isWindows() {
|
|
169
|
+
return os.platform() === 'win32';
|
|
170
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { assert };
|
|
2
|
+
export { assertUsage };
|
|
3
|
+
export { assertWarning };
|
|
4
|
+
declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
|
|
5
|
+
declare function assertUsage(condition: unknown, msg: string): asserts condition;
|
|
6
|
+
declare function assertWarning(condition: unknown, msg: string): asserts condition;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { assert };
|
|
2
|
+
export { assertUsage };
|
|
3
|
+
export { assertWarning };
|
|
4
|
+
function assert(condition, debugInfo) {
|
|
5
|
+
if (condition) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
var hasDebugInfo = debugInfo !== undefined;
|
|
9
|
+
if (hasDebugInfo) {
|
|
10
|
+
console.log(debugInfo);
|
|
11
|
+
if (typeof debugInfo === 'object') {
|
|
12
|
+
debugInfo = JSON.stringify(debugInfo);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var errMsg = '[DocPress] Bug. Contact DocPress maintainer.';
|
|
16
|
+
if (hasDebugInfo) {
|
|
17
|
+
errMsg += ' Debug info: ' + String(debugInfo);
|
|
18
|
+
}
|
|
19
|
+
var err = new Error(errMsg);
|
|
20
|
+
if (isBrowserAndDev()) {
|
|
21
|
+
alert(err.stack);
|
|
22
|
+
}
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
function assertUsage(condition, msg) {
|
|
26
|
+
if (condition) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var err = new Error('[DocPress][Wrong Usage] ' + msg);
|
|
30
|
+
if (isBrowserAndDev()) {
|
|
31
|
+
alert(err.stack);
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
function isBrowserAndDev() {
|
|
36
|
+
var _a;
|
|
37
|
+
return typeof window !== 'undefined' && ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.port) !== '';
|
|
38
|
+
}
|
|
39
|
+
function assertWarning(condition, msg) {
|
|
40
|
+
if (condition) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
msg = '[DocPress][Warning] ' + msg;
|
|
44
|
+
console.warn(msg);
|
|
45
|
+
if (isBrowserAndDev()) {
|
|
46
|
+
alert(msg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assert } from './assert.js';
|
|
2
|
+
export { determineSectionUrlHash };
|
|
3
|
+
export { determineSectionTitle };
|
|
4
|
+
function determineSectionUrlHash(title) {
|
|
5
|
+
title = title.toLowerCase();
|
|
6
|
+
title = removeAccentsAndDiacritics(title);
|
|
7
|
+
var urlHash = title
|
|
8
|
+
// \u4E00-\u9FA5 are chinese characters, see https://github.com/brillout/docpress/pull/2
|
|
9
|
+
.split(/[^a-z0-9\u4E00-\u9FA5]+/)
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join('-');
|
|
12
|
+
// E.g. section is composed of only non-latin characters
|
|
13
|
+
if (urlHash === '')
|
|
14
|
+
return null;
|
|
15
|
+
return urlHash;
|
|
16
|
+
}
|
|
17
|
+
// Remove accents/diacritics in a string in JavaScript
|
|
18
|
+
// https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463
|
|
19
|
+
function removeAccentsAndDiacritics(str) {
|
|
20
|
+
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
21
|
+
}
|
|
22
|
+
function determineSectionTitle(urlWithHash) {
|
|
23
|
+
assert(urlWithHash.includes('#'), { urlWithHash: urlWithHash });
|
|
24
|
+
var urlHash = urlWithHash.split('#')[1];
|
|
25
|
+
var title = urlHash
|
|
26
|
+
.split('-')
|
|
27
|
+
.map(function (word, i) {
|
|
28
|
+
if (i === 0) {
|
|
29
|
+
return capitalizeFirstLetter(word);
|
|
30
|
+
}
|
|
31
|
+
return word;
|
|
32
|
+
})
|
|
33
|
+
.join(' ');
|
|
34
|
+
return title;
|
|
35
|
+
}
|
|
36
|
+
function capitalizeFirstLetter(word) {
|
|
37
|
+
return word[0].toUpperCase() + word.slice(1);
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import mdx from '@mdx-js/rollup';
|
|
2
|
+
import react from '@vitejs/plugin-react-swc';
|
|
3
|
+
import vike from 'vike/plugin';
|
|
4
|
+
import { markdownHeadingsVitePlugin } from './markdownHeadingsVitePlugin.js';
|
|
5
|
+
import rehypePrettyCode from 'rehype-pretty-code';
|
|
6
|
+
import remarkGfm from 'remark-gfm';
|
|
7
|
+
var root = process.cwd();
|
|
8
|
+
var prettyCode = [rehypePrettyCode, { theme: 'github-light' }];
|
|
9
|
+
var rehypePlugins = [prettyCode];
|
|
10
|
+
var remarkPlugins = [remarkGfm];
|
|
11
|
+
var config = {
|
|
12
|
+
root: root,
|
|
13
|
+
plugins: [
|
|
14
|
+
markdownHeadingsVitePlugin(),
|
|
15
|
+
mdx({ rehypePlugins: rehypePlugins, remarkPlugins: remarkPlugins }),
|
|
16
|
+
// @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
|
|
17
|
+
react(),
|
|
18
|
+
vike({
|
|
19
|
+
prerender: {
|
|
20
|
+
noExtraDir: true
|
|
21
|
+
},
|
|
22
|
+
includeAssetsImportedByServer: true
|
|
23
|
+
})
|
|
24
|
+
],
|
|
25
|
+
optimizeDeps: { include: ['@mdx-js/react', 'react-dom'] },
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
ssr: {
|
|
28
|
+
noExternal: ['@brillout/docpress']
|
|
29
|
+
},
|
|
30
|
+
clearScreen: false
|
|
31
|
+
};
|
|
32
|
+
export default config;
|
package/index.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { assert } from './utils/client'
|
|
2
|
+
|
|
3
|
+
installSectionUrlHashs()
|
|
4
|
+
/* Let browser restore previous scroll
|
|
5
|
+
jumpToSection()
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function installSectionUrlHashs() {
|
|
9
|
+
const pageContainer = document.querySelector('.doc-page #page-container')
|
|
10
|
+
if (!pageContainer) {
|
|
11
|
+
assert(window.location.pathname === '/')
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
const headings = [...Array.from(document.querySelectorAll('h2')), ...Array.from(document.querySelectorAll('h3'))]
|
|
15
|
+
headings.forEach((heading) => {
|
|
16
|
+
if (!heading.id) return
|
|
17
|
+
const urlHash = '#' + heading.id
|
|
18
|
+
assertNavLink(urlHash, heading)
|
|
19
|
+
heading.onclick = () => {
|
|
20
|
+
window.location.hash = urlHash
|
|
21
|
+
// The browser doesn't jump if hash doesn't change
|
|
22
|
+
jumpToSection()
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function assertNavLink(urlHash: string, heading: HTMLHeadingElement) {
|
|
28
|
+
const navigationEl = getNavigationEl()
|
|
29
|
+
{
|
|
30
|
+
const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${window.location.pathname}"]`))
|
|
31
|
+
assert(parentNavLinkMatch.length === 1)
|
|
32
|
+
}
|
|
33
|
+
{
|
|
34
|
+
const navLinks: HTMLElement[] = Array.from(navigationEl.querySelectorAll(`a[href="${urlHash}"]`))
|
|
35
|
+
const { tagName } = heading
|
|
36
|
+
assert(tagName.startsWith('H'))
|
|
37
|
+
const lengthExpected = tagName === 'H2' ? 1 : 0
|
|
38
|
+
assert(navLinks.length === lengthExpected, { urlHash })
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function jumpToSection() {
|
|
43
|
+
const { hash } = window.location
|
|
44
|
+
if (hash === '' || hash === '#') {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
assert(hash.startsWith('#'))
|
|
48
|
+
const target = document.getElementById(hash.slice(1))
|
|
49
|
+
if (!target) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
target.scrollIntoView()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getNavigationEl() {
|
|
56
|
+
const elems: HTMLElement[] = Array.from(document.querySelectorAll('#navigation-container'))
|
|
57
|
+
assert(elems.length === 1)
|
|
58
|
+
const navigationEl = elems[0]!
|
|
59
|
+
return navigationEl
|
|
60
|
+
}
|