@brillout/docpress 0.1.17 → 0.2.0

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 (144) hide show
  1. package/bin.js +3 -0
  2. package/{src/css/Inter-Var.ttf → dist/Inter-Var-IOAEQULN.ttf} +0 -0
  3. package/{src/components/Sponsors/companyLogos/ccoli.svg → dist/ccoli-CHW3TQKS.svg} +0 -0
  4. package/{src/icons/changelog.svg → dist/changelog-IPI5F42D.svg} +0 -0
  5. package/{src/navigation/navigation-fullscreen/chevron.svg → dist/chevron-K3WPYLOP.svg} +0 -0
  6. package/{src/components/features/chevron.svg → dist/chevron-R2IYJD62.svg} +0 -0
  7. package/dist/chunk-7HKDCMSZ.js +154 -0
  8. package/dist/chunk-7HKDCMSZ.js.map +1 -0
  9. package/dist/chunk-G2A5MZJA.js +48 -0
  10. package/dist/chunk-G2A5MZJA.js.map +1 -0
  11. package/dist/chunk-JS5BGVDK.js +178 -0
  12. package/dist/chunk-JS5BGVDK.js.map +1 -0
  13. package/dist/chunk-OEVBWUR6.js +92 -0
  14. package/dist/chunk-OEVBWUR6.js.map +1 -0
  15. package/dist/chunk-TTLAZ2T2.js +8 -0
  16. package/dist/chunk-TTLAZ2T2.js.map +1 -0
  17. package/dist/{chunk-ZYYJWJMY.js → chunk-XUTBTIEE.js} +15 -42
  18. package/dist/chunk-XUTBTIEE.js.map +1 -0
  19. package/dist/cli/index.d.ts +1 -0
  20. package/dist/cli/index.js +35 -0
  21. package/dist/cli/index.js.map +1 -0
  22. package/{src/navigation/navigation-fullscreen/close.svg → dist/close-IQXTDOHV.svg} +0 -0
  23. package/{src/utils/Emoji/compass.svg → dist/compass-2RWQU3E4.svg} +0 -0
  24. package/{src → dist}/components/features/FeatureList.css +2 -7
  25. package/dist/components/features/FeatureList.css.map +1 -0
  26. package/dist/components/features/FeatureList.d.ts +13 -0
  27. package/dist/components/features/FeatureList.js +8 -0
  28. package/dist/components/features/FeatureList.js.map +1 -0
  29. package/dist/components/features/initFeatureList.d.ts +3 -0
  30. package/dist/components/features/initFeatureList.js +60 -0
  31. package/dist/components/features/initFeatureList.js.map +1 -0
  32. package/{src/components/Sponsors/companyLogos/contra.svg → dist/contra-WLZBOPBV.svg} +0 -0
  33. package/dist/{devServer-J2XJQJGT.js → devServer-534L4U45.js} +5 -2
  34. package/dist/{devServer-J2XJQJGT.js.map → devServer-534L4U45.js.map} +1 -1
  35. package/{src/icons/discord.svg → dist/discord-JD33TUSF.svg} +0 -0
  36. package/{src/utils/Emoji/engine.png → dist/engine-6Q6VSCVA.png} +0 -0
  37. package/{src/icons/github.svg → dist/github-P5ZSKN2N.svg} +0 -0
  38. package/{src/icons/heart.svg → dist/heart-OINVKOXO.svg} +0 -0
  39. package/dist/index.css +121 -0
  40. package/dist/index.css.map +1 -0
  41. package/dist/index.d.ts +136 -0
  42. package/dist/index.js +484 -27
  43. package/dist/index.js.map +1 -1
  44. package/{src/components/Sponsors/label.svg → dist/label-MP75CTIA.svg} +0 -0
  45. package/{src/utils/Emoji/mechanical-arm.svg → dist/mechanical-arm-TR7IQQMG.svg} +0 -0
  46. package/{src/components/Sponsors/medalBronze.svg → dist/medalBronze-CO4CTUR4.svg} +0 -0
  47. package/{src/components/Sponsors/medalGold.svg → dist/medalGold-UP6A73FL.svg} +0 -0
  48. package/{src/components/Sponsors/medalSilver.svg → dist/medalSilver-FAPGGOBN.svg} +0 -0
  49. package/{src/components/Sponsors/companyLogos/mfqs.svg → dist/mfqs-2EAEE7N6.svg} +0 -0
  50. package/dist/renderer/_default.page.client.css +263 -0
  51. package/dist/renderer/_default.page.client.css.map +1 -0
  52. package/dist/renderer/_default.page.client.d.ts +1 -0
  53. package/dist/renderer/_default.page.client.js +180 -0
  54. package/dist/renderer/_default.page.client.js.map +1 -0
  55. package/dist/renderer/_default.page.server.css +312 -0
  56. package/dist/renderer/_default.page.server.css.map +1 -0
  57. package/dist/renderer/_default.page.server.d.ts +22 -0
  58. package/dist/renderer/_default.page.server.js +602 -0
  59. package/dist/renderer/_default.page.server.js.map +1 -0
  60. package/{src/utils/Emoji/road-fork.svg → dist/road-fork-3WZLW3HB.svg} +0 -0
  61. package/{src/utils/Emoji/shield.svg → dist/shield-CU45RG5C.svg} +0 -0
  62. package/{src/icons/twitter.svg → dist/twitter-I7DXDN3J.svg} +0 -0
  63. package/{src/utils/Emoji/typescript.svg → dist/typescript-ALIPKLRM.svg} +0 -0
  64. package/package.json +22 -13
  65. package/dist/chunk-ZYYJWJMY.js.map +0 -1
  66. package/src/MobileHeader.tsx +0 -68
  67. package/src/PageLayout.css +0 -41
  68. package/src/PageLayout.tsx +0 -37
  69. package/src/algolia/DocSearch.css +0 -29
  70. package/src/algolia/DocSearch.ts +0 -37
  71. package/src/autoScrollNav.ts +0 -22
  72. package/src/cli/devServer.ts +0 -31
  73. package/src/cli/index.ts +0 -29
  74. package/src/components/CodeBlock.tsx +0 -22
  75. package/src/components/DocLink.tsx +0 -108
  76. package/src/components/EditPageNote.tsx +0 -18
  77. package/src/components/HorizontalLine.tsx +0 -20
  78. package/src/components/ImportMeta.tsx +0 -11
  79. package/src/components/Info.tsx +0 -12
  80. package/src/components/Link.tsx +0 -18
  81. package/src/components/Note.tsx +0 -31
  82. package/src/components/P.css +0 -8
  83. package/src/components/P.tsx +0 -8
  84. package/src/components/ReadingRecommendation.tsx +0 -53
  85. package/src/components/RepoLink.tsx +0 -24
  86. package/src/components/Sponsors/companyLogos/ccoli-logo.svg +0 -1
  87. package/src/components/Sponsors/companyLogos/ccoli-text.svg +0 -1
  88. package/src/components/Sponsors/label.draft.svg +0 -108
  89. package/src/components/Sponsors.tsx +0 -242
  90. package/src/components/features/FeatureList.tsx +0 -114
  91. package/src/components/features/initFeatureList.ts +0 -66
  92. package/src/components/index.ts +0 -13
  93. package/src/config/Config.ts +0 -30
  94. package/src/config/getConfig.ts +0 -18
  95. package/src/config/resolveConfig/resolveHeading.ts +0 -0
  96. package/src/config/resolvePageContext.ts +0 -157
  97. package/src/css/button.css +0 -7
  98. package/src/css/code/block.css +0 -36
  99. package/src/css/code/inline.css +0 -27
  100. package/src/css/code.css +0 -20
  101. package/src/css/colorize-on-hover.css +0 -29
  102. package/src/css/font.css +0 -19
  103. package/src/css/heading.css +0 -25
  104. package/src/css/index.css +0 -11
  105. package/src/css/link.css +0 -17
  106. package/src/css/note.css +0 -26
  107. package/src/css/reset.css +0 -12
  108. package/src/css/table.css +0 -14
  109. package/src/css/tooltip.css +0 -11
  110. package/src/headings.ts +0 -200
  111. package/src/index.ts +0 -3
  112. package/src/installSectionUrlHashs.ts +0 -50
  113. package/src/markdownHeadingsVitePlugin.ts +0 -128
  114. package/src/navigation/Navigation-highlight.css +0 -41
  115. package/src/navigation/Navigation-items.css +0 -122
  116. package/src/navigation/Navigation-layout.css +0 -118
  117. package/src/navigation/Navigation.client.old.ts +0 -303
  118. package/src/navigation/Navigation.client.ts +0 -19
  119. package/src/navigation/Navigation.css +0 -12
  120. package/src/navigation/Navigation.tsx +0 -228
  121. package/src/navigation/NavigationHeader.tsx +0 -97
  122. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
  123. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -44
  124. package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -115
  125. package/src/parseEmojis.ts +0 -33
  126. package/src/renderer/_default.page.client.ts +0 -4
  127. package/src/renderer/_default.page.server.tsx +0 -69
  128. package/src/renderer/usePageContext.tsx +0 -25
  129. package/src/types.ts +0 -2
  130. package/src/utils/Emoji/Emoji.ts +0 -216
  131. package/src/utils/Emoji/assets.ts +0 -9
  132. package/src/utils/Emoji/index.ts +0 -1
  133. package/src/utils/Emoji/mountain.svg +0 -1
  134. package/src/utils/assert.ts +0 -39
  135. package/src/utils/client.ts +0 -2
  136. package/src/utils/crawlAllFiles.ts +0 -17
  137. package/src/utils/determineSectionUrlHash.ts +0 -35
  138. package/src/utils/filesystemPathHandling.ts +0 -42
  139. package/src/utils/filter.ts +0 -12
  140. package/src/utils/isBrowser.ts +0 -5
  141. package/src/utils/jsxToTextContent.ts +0 -11
  142. package/src/utils/objectAssign.ts +0 -9
  143. package/src/utils/server.ts +0 -8
  144. package/src/vite.config.ts +0 -44
@@ -1,242 +0,0 @@
1
- import React from 'react'
2
- import iconHeart from '../icons/heart.svg'
3
- import { usePageContext } from '../renderer/usePageContext'
4
- import { assert, Emoji } from '../utils/server'
5
- import ccoliLogo from './Sponsors/companyLogos/ccoli.svg'
6
- import contraLogo from './Sponsors/companyLogos/contra.svg'
7
- import mfqsLogo from './Sponsors/companyLogos/mfqs.svg'
8
- import medalGold from './Sponsors/medalGold.svg'
9
- import medalSilver from './Sponsors/medalSilver.svg'
10
- import medalBronze from './Sponsors/medalBronze.svg'
11
- import labelBgImg from './Sponsors/label.svg'
12
-
13
- export { Sponsors }
14
-
15
- type Plan = 'FREE_SLOT' | 'bronze' | 'silver' | 'gold' | 'platinum'
16
-
17
- type SponsorCompany = {
18
- companyName: string
19
- companyLogo: string
20
- website: string
21
- plan: Plan
22
- }
23
- type SponsorIndividual = {
24
- username: string
25
- }
26
- type Sponsor = SponsorCompany | SponsorIndividual
27
-
28
- const sponsors: Sponsor[] = [
29
- {
30
- companyName: 'Contra',
31
- companyLogo: contraLogo,
32
- plan: 'gold',
33
- website: 'https://contra.com'
34
- },
35
- {
36
- companyName: 'ccoli',
37
- companyLogo: ccoliLogo,
38
- plan: 'silver',
39
- website: 'https://ccoli.co'
40
- },
41
- {
42
- companyName: 'My Favorite Quilt Store',
43
- companyLogo: mfqsLogo,
44
- plan: 'bronze',
45
- website: 'https://myfavoritequiltstore.com'
46
- },
47
- {
48
- username: 'spacedawwwg'
49
- },
50
- {
51
- username: 'codthing'
52
- },
53
- {
54
- username: 'Junaidhkn'
55
- },
56
- {
57
- username: 'zgfdev'
58
- }
59
- ]
60
-
61
- function Sponsors() {
62
- const pageContext = usePageContext()
63
- const { projectInfo } = pageContext.config
64
- return (
65
- <div style={{ textAlign: 'center', marginTop: 19 }}>
66
- <a
67
- className="button"
68
- href="https://github.com/sponsors/brillout"
69
- style={{
70
- color: 'inherit',
71
- display: 'inline-flex',
72
- alignItems: 'center',
73
- padding: '5px 10px',
74
- marginBottom: 10
75
- }}
76
- >
77
- <img src={iconHeart} height={22} /> <span style={{ marginLeft: 7, fontSize: '1.07em' }}>Sponsor</span>
78
- </a>
79
- <div></div>
80
- <div style={{ maxWidth: 400, display: 'inline-block', marginTop: 12, marginBottom: 12 }}>
81
- {projectInfo.projectNameJsx || projectInfo.projectName} is free and open source, made possible by wonderful
82
- sponsors.
83
- </div>
84
- <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', alignItems: 'end' }}>
85
- {sponsors.map((sponsor, i) => (
86
- <SponsorDiv sponsor={sponsor} key={i} />
87
- ))}
88
- </div>
89
- </div>
90
- )
91
- }
92
-
93
- function SponsorDiv({ sponsor }: { sponsor: Sponsor }) {
94
- let imgSrc: string
95
- let imgAlt: string | undefined
96
- let width: number
97
- let height: number
98
- let website: string
99
- let padding: number
100
- let backgroundColor = '#f0f0f0'
101
- let label: null | JSX.Element = null
102
- if ('username' in sponsor) {
103
- website = `https://github.com/${sponsor.username}`
104
- imgSrc = `https://github.com/${sponsor.username}.png?size=30`
105
- width = 30
106
- height = 30
107
- padding = 0
108
- backgroundColor = 'none'
109
- } else {
110
- imgSrc = sponsor.companyLogo
111
- website = sponsor.website
112
- const size = getSize(sponsor.plan)
113
- width = size.width
114
- height = size.height
115
- padding = size.padding
116
- imgAlt = sponsor.companyName
117
- label = <Label sponsor={sponsor} />
118
- }
119
- const marginWidth = 5
120
- return (
121
- <a
122
- href={website}
123
- style={{
124
- margin: `10px ${marginWidth}px`
125
- }}
126
- >
127
- {label}
128
- <div
129
- style={{
130
- backgroundColor,
131
- borderRadius: 7,
132
- overflow: 'hidden',
133
- width,
134
- maxWidth: `calc(100vw - 2 * var(--main-view-padding) - 2 * ${marginWidth}px)`,
135
- height,
136
- display: 'flex',
137
- alignItems: 'center',
138
- flexDirection: 'column',
139
- justifyContent: 'center'
140
- }}
141
- >
142
- <img
143
- style={{ width: `calc(100% - ${padding}px)`, height: height - padding, zIndex: 2 }}
144
- src={imgSrc}
145
- alt={imgAlt}
146
- />
147
- </div>
148
- </a>
149
- )
150
- }
151
-
152
- function Label({ sponsor }: { sponsor: Sponsor }) {
153
- assert(!('username' in sponsor))
154
- const labelBg = getLabelBg(sponsor)
155
- const labelIcon = getLabelIcon(sponsor)
156
- const labelText = getLabelText(sponsor)
157
- return (
158
- <div
159
- style={{
160
- top: 0,
161
- display: 'flex',
162
- justifyContent: 'center',
163
- alignItems: 'center',
164
- position: 'relative',
165
- paddingBottom: 1
166
- }}
167
- >
168
- {labelBg}
169
- {labelIcon}
170
- {labelText}
171
- </div>
172
- )
173
- }
174
-
175
- function getLabelBg(sponsor: SponsorCompany) {
176
- const height = sponsor.plan === 'platinum' ? 32 : 24
177
- return <img src={labelBgImg} style={{ height, position: 'absolute', bottom: 0, zIndex: -1 }} />
178
- }
179
-
180
- function getLabelText(sponsor: SponsorCompany) {
181
- if (sponsor.plan === 'platinum') {
182
- return <></>
183
- }
184
- const letterSpacing = ['bronze', 'silver', 'gold'].includes(sponsor.plan) ? 1 : undefined
185
- return (
186
- <>
187
- {' '}
188
- <span
189
- style={{
190
- zIndex: 1,
191
- fontSize: '0.82em',
192
- position: 'relative',
193
- top: 0,
194
- fontWeight: 500,
195
- color: '#666',
196
- letterSpacing
197
- }}
198
- >
199
- {capitalizeFirstLetter(sponsor.plan)}
200
- </span>
201
- </>
202
- )
203
- }
204
-
205
- function getLabelIcon(sponsor: SponsorCompany) {
206
- let medalSrc: string
207
- if (sponsor.plan === 'platinum') {
208
- return <Emoji name="trophy" style={{ fontSize: '1.3em' }} />
209
- } else if (sponsor.plan === 'gold') {
210
- medalSrc = medalGold
211
- } else if (sponsor.plan === 'silver') {
212
- medalSrc = medalSilver
213
- } else if (sponsor.plan === 'bronze') {
214
- medalSrc = medalBronze
215
- } else {
216
- assert(false)
217
- }
218
- return <img src={medalSrc} style={{ height: 15, zIndex: 1, marginRight: 5 }} />
219
- }
220
-
221
- function getSize(plan: Plan) {
222
- if (plan === 'platinum') {
223
- assert(false)
224
- }
225
- if (plan === 'gold') {
226
- return { width: 400, height: 150, padding: 95 }
227
- }
228
- if (plan === 'silver') {
229
- return { width: 300, height: 100, padding: 45 }
230
- }
231
- if (plan === 'bronze') {
232
- return { width: 200, height: 70, padding: 30 }
233
- }
234
- if (plan === 'FREE_SLOT') {
235
- return { width: 150, height: 40, padding: 15 }
236
- }
237
- assert(false)
238
- }
239
-
240
- function capitalizeFirstLetter(word: string): string {
241
- return word[0].toUpperCase() + word.slice(1)
242
- }
@@ -1,114 +0,0 @@
1
- import React from 'react'
2
- import './FeatureList.css'
3
- import iconChevron from './chevron.svg'
4
-
5
- export { FeatureList }
6
-
7
- type FeatureProps = {
8
- title: React.ReactNode
9
- desc: React.ReactNode
10
- learnMore?: React.ReactNode
11
- isSecondaryFeature?: true
12
- }
13
-
14
- function FeatureList({ features }: { features: FeatureProps[] }) {
15
- const numberOfFeatures = features.length
16
- const numberOfRows = Math.ceil(numberOfFeatures / 2)
17
- return (
18
- <div id="features">
19
- {Array.from({ length: numberOfRows }, (_, i) => {
20
- const feature1Id = 2 * i + 0
21
- const feature2Id = 2 * i + 1
22
- const feature1 = features[feature1Id]
23
- const feature2 = features[feature2Id]
24
- const className = ['features-row', feature2 ? '' : 'single-column'].filter(Boolean).join(' ')
25
- return (
26
- <div className={className} key={i}>
27
- <Feature {...{ ...feature1, featureId: feature1Id }} />
28
- {feature2 && <Feature {...{ ...feature2, featureId: feature2Id }} />}
29
- </div>
30
- )
31
- })}
32
- </div>
33
- )
34
- }
35
-
36
- function Feature({ title, desc, learnMore, isSecondaryFeature, featureId }: FeatureProps & { featureId: number }) {
37
- const name = `feature-${featureId}`
38
- const rightSide = featureId % 2 === 1
39
- return (
40
- <>
41
- <FeatureHead name={name} hasLearnMore={!!learnMore} isSecondaryFeature={isSecondaryFeature}>
42
- {' '}
43
- <h2>{title}</h2>
44
- {desc}
45
- </FeatureHead>
46
- {!!learnMore && (
47
- <LearnMore name={name} rightSide={rightSide}>
48
- {learnMore}
49
- </LearnMore>
50
- )}
51
- </>
52
- )
53
- }
54
-
55
- function FeatureHead({
56
- children,
57
- name,
58
- hasLearnMore,
59
- isSecondaryFeature,
60
- className = ''
61
- }: {
62
- className?: string
63
- name?: string
64
- hasLearnMore?: boolean
65
- isSecondaryFeature?: true
66
- children: any
67
- }) {
68
- return (
69
- <summary
70
- className={[
71
- className,
72
- 'feature',
73
- 'colorize-on-hover',
74
- hasLearnMore && 'has-learn-more',
75
- isSecondaryFeature && 'secondary-feature'
76
- ]
77
- .filter(Boolean)
78
- .join(' ')}
79
- id={name && `feature-${name}`}
80
- style={{ cursor: (hasLearnMore && 'pointer') || undefined }}
81
- >
82
- {children}
83
- {hasLearnMore && (
84
- <div style={{ textAlign: 'center', marginTop: '1em' }}>
85
- <button
86
- type="button"
87
- style={{
88
- textAlign: 'center',
89
- padding: '0 7px',
90
- paddingTop: 3,
91
- paddingBottom: 1,
92
- display: 'inline-block',
93
- fontSize: '10px',
94
- textTransform: 'uppercase',
95
- letterSpacing: '1px',
96
- fontWeight: 600
97
- }}
98
- >
99
- <span className="decolorize-5">Learn more</span>
100
- <br />
101
- <img className="decolorize-4 chevron" src={iconChevron} height="7" style={{ marginTop: 2 }} />
102
- </button>
103
- </div>
104
- )}
105
- </summary>
106
- )
107
- }
108
- function LearnMore({ children, name, rightSide }: { name: string; children: any; rightSide: boolean }) {
109
- return (
110
- <aside className={'learn-more ' + (rightSide ? 'right-side' : '')} id={`learn-more-${name}`}>
111
- {children}
112
- </aside>
113
- )
114
- }
@@ -1,66 +0,0 @@
1
- import { assert } from '../../utils/client'
2
-
3
- addTwitterWidgets()
4
- addFeatureClickHandlers()
5
- window.__docpress_hydrationFinished = true
6
-
7
- function addTwitterWidgets() {
8
- loadScript('https://platform.twitter.com/widgets.js')
9
- }
10
-
11
- function addFeatureClickHandlers() {
12
- const featureEls: HTMLElement[] = Array.from(
13
- document.getElementById('features')!.querySelectorAll('.feature.has-learn-more')
14
- )
15
- featureEls.forEach((featureEl) => {
16
- featureEl.onclick = () => {
17
- expandLearnMore(featureEl)
18
- }
19
- })
20
- }
21
-
22
- function expandLearnMore(featureEl: HTMLElement) {
23
- const featureId = featureEl.id
24
- assert(featureId.startsWith('feature-'), { featureId })
25
- const featureName = featureId.slice('feature-'.length)
26
-
27
- const selectedClass = 'selected'
28
- const learnId = 'learn-more-' + featureName
29
- const learnEl = document.getElementById(learnId)
30
- assert(learnEl, { learnId })
31
-
32
- const isExpanded = featureEl.classList.contains(selectedClass)
33
-
34
- if (!isExpanded) {
35
- const rowEl = featureEl.parentNode as HTMLElement
36
- if (getComputedStyle(rowEl, 'display') === 'grid') {
37
- ;[
38
- ...(rowEl.querySelectorAll('.learn-more') as any as HTMLElement[]),
39
- ...(rowEl.querySelectorAll('.feature') as any as HTMLElement[])
40
- ].forEach((el) => {
41
- el.classList.remove(selectedClass)
42
- })
43
- }
44
- }
45
-
46
- ;[featureEl, learnEl].forEach((el) => {
47
- el.classList.toggle(selectedClass)
48
- })
49
- }
50
-
51
- function loadScript(scriptUrl: string): void {
52
- assert(scriptUrl.startsWith('https://'))
53
- const scriptEl = document.createElement('script')
54
- scriptEl.src = scriptUrl
55
- scriptEl.async = true
56
- scriptEl.setAttribute('charset', 'utf-8')
57
- document.getElementsByTagName('head')[0].appendChild(scriptEl)
58
- }
59
-
60
- function getComputedStyle(el: HTMLElement, styleProp: string) {
61
- return window.document.defaultView!.getComputedStyle(el).getPropertyValue(styleProp)
62
- }
63
-
64
- declare global {
65
- var __docpress_hydrationFinished: undefined | true
66
- }
@@ -1,13 +0,0 @@
1
- export * from '../utils/Emoji'
2
- export * from './Link'
3
- export * from './DocLink'
4
- export * from './RepoLink'
5
- export * from './P'
6
- export * from './Info'
7
- export * from './ReadingRecommendation'
8
- export * from './Note'
9
- export * from './ImportMeta'
10
- export * from './features/FeatureList'
11
- export * from './HorizontalLine'
12
- export * from './Sponsors'
13
- export * from './CodeBlock'
@@ -1,30 +0,0 @@
1
- export type { Config }
2
-
3
- import type { HeadingDefinition, HeadingWithoutLink } from '../headings'
4
-
5
- type Config = {
6
- projectInfo: {
7
- githubRepository: string
8
- githubIssues: string
9
- projectName: string
10
- projectNameJsx?: JSX.Element
11
- projectVersion: string
12
- discordInvite: string
13
- twitterProfile: string
14
- }
15
- faviconUrl: string
16
- algolia: null | {
17
- appId: string
18
- apiKey: string
19
- indexName: string
20
- }
21
- headings: HeadingDefinition[]
22
- headingsWithoutLink: HeadingWithoutLink[]
23
- navHeaderMobile: React.ReactNode
24
- navHeader: React.ReactNode
25
- titleNormalCase: boolean
26
- tagline: string
27
- websiteUrl: string
28
- bannerUrl?: string
29
- twitterHandle: string
30
- }
@@ -1,18 +0,0 @@
1
- export { getConfig }
2
- import { assert, assertUsage } from '../utils/server'
3
- import { Config } from './Config'
4
-
5
- function getConfig(): Config {
6
- // We use `@ts-ignore` because the DocPress user most likely didn't add `vite/client` in his `tsconfig.json`.
7
- // @ts-ignore
8
- const globResult = import.meta.glob('/**/docpress.config.*([a-zA-Z0-9])', { eager: true })
9
- const files = Object.keys(globResult)
10
- assertUsage(files.length >= 1, 'No DocPress config file found `docpress.config.(js|ts|tsx|...)`')
11
- assertUsage(
12
- files.length === 1,
13
- `Found multiple \`docpress.config.js\` files: ${files.map((f) => `\`${f}\``).join(', ')}. Define only one instead.`
14
- )
15
- const config = (Object.values(globResult)[0] as any).default as Config
16
- assert(config)
17
- return config
18
- }
File without changes
@@ -1,157 +0,0 @@
1
- import { assert, jsxToTextContent, objectAssign } from '../utils/server'
2
- import { getHeadings, HeadingWithoutLink, parseTitle } from '../headings'
3
- import type { Heading } from '../headings'
4
- import type { PageContextBuiltIn } from 'vite-plugin-ssr'
5
- import type { MarkdownHeading } from '../markdownHeadingsVitePlugin'
6
- import type { Config } from './Config'
7
- import { getConfig } from './getConfig'
8
-
9
- export { resolvePageContext }
10
- export type { PageContextOriginal }
11
- export type { PageContextResolved }
12
- export type { Heading }
13
-
14
- type ReactComponent = () => JSX.Element
15
- type Exports = {
16
- headings?: MarkdownHeading[]
17
- }
18
- type PageContextOriginal = PageContextBuiltIn & {
19
- Page: ReactComponent
20
- exports: Exports
21
- }
22
- type PageContextResolved = ReturnType<typeof resolvePageContext>
23
-
24
- function resolvePageContext(pageContext: PageContextOriginal) {
25
- const config = getConfig()
26
- const { headings, headingsWithoutLink } = getHeadings(config)
27
- const activeHeading = findActiveHeading(headings, headingsWithoutLink, pageContext)
28
- const headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeHeading)
29
- const { title, isLandingPage, pageTitle, isDetachedPage } = getMetaData(
30
- headingsWithoutLink,
31
- activeHeading,
32
- pageContext,
33
- config
34
- )
35
- const { faviconUrl, algolia, tagline, twitterHandle, bannerUrl, websiteUrl } = config
36
- const pageContextResolved = {}
37
- objectAssign(pageContextResolved, {
38
- ...pageContext,
39
- meta: {
40
- title,
41
- faviconUrl,
42
- twitterHandle,
43
- bannerUrl,
44
- websiteUrl,
45
- tagline,
46
- algolia
47
- },
48
- headings,
49
- headingsWithSubHeadings,
50
- isLandingPage,
51
- isDetachedPage,
52
- pageTitle,
53
- config
54
- })
55
- return pageContextResolved
56
- }
57
-
58
- function getMetaData(
59
- headingsWithoutLink: HeadingWithoutLink[],
60
- activeHeading: Heading | null,
61
- pageContext: { urlOriginal: string; exports: Exports },
62
- config: Config
63
- ) {
64
- const url = pageContext.urlOriginal
65
-
66
- let title: string
67
- let pageTitle: string | JSX.Element | null
68
- let isDetachedPage: boolean
69
- if (activeHeading) {
70
- title = activeHeading.titleDocument || jsxToTextContent(activeHeading.title)
71
- pageTitle = activeHeading.title
72
- isDetachedPage = false
73
- } else {
74
- pageTitle = headingsWithoutLink.find((h) => h.url === url)!.title
75
- title = jsxToTextContent(pageTitle)
76
- isDetachedPage = true
77
- }
78
-
79
- const isLandingPage = url === '/'
80
- if (!isLandingPage) {
81
- title += ' | ' + config.projectInfo.projectName
82
- }
83
-
84
- if (isLandingPage) {
85
- pageTitle = null
86
- }
87
-
88
- return { title, isLandingPage, pageTitle, isDetachedPage }
89
- }
90
-
91
- function findActiveHeading(
92
- headings: Heading[],
93
- headingsWithoutLink: HeadingWithoutLink[],
94
- pageContext: { urlOriginal: string; exports: Exports }
95
- ): Heading | null {
96
- let activeHeading: Heading | null = null
97
- assert(pageContext.urlOriginal)
98
- const pageUrl = pageContext.urlOriginal
99
- headings.forEach((heading) => {
100
- if (heading.url === pageUrl) {
101
- activeHeading = heading
102
- assert(heading.level === 2, { pageUrl, heading })
103
- }
104
- })
105
- const debugInfo = {
106
- msg: 'Heading not found for url: ' + pageUrl,
107
- urls: headings.map((h) => h.url),
108
- url: pageUrl
109
- }
110
- assert(activeHeading || headingsWithoutLink.find(({ url }) => pageUrl === url), debugInfo)
111
- return activeHeading
112
- }
113
-
114
- function getHeadingsWithSubHeadings(
115
- headings: Heading[],
116
- pageContext: { exports: Exports; urlOriginal: string },
117
- activeHeading: Heading | null
118
- ): Heading[] {
119
- const headingsWithSubHeadings = headings.slice()
120
- if (activeHeading === null) return headingsWithSubHeadings
121
- const activeHeadingIdx = headingsWithSubHeadings.indexOf(activeHeading)
122
- assert(activeHeadingIdx >= 0)
123
- const pageHeadings = pageContext.exports.headings || []
124
- pageHeadings.forEach((pageHeading, i) => {
125
- const title = parseTitle(pageHeading.title)
126
- const url = '#' + pageHeading.id
127
- assert(
128
- pageHeading.headingLevel !== 3,
129
- 'Wrong page heading level `' +
130
- pageHeading.headingLevel +
131
- '` (it should be `<h2>`) for sub-heading `' +
132
- pageHeading.title +
133
- '` of page `' +
134
- pageContext.urlOriginal +
135
- '`.'
136
- )
137
- if (pageHeading.headingLevel === 2) {
138
- const heading: Heading = {
139
- url,
140
- title,
141
- parentHeadings: [activeHeading, ...activeHeading.parentHeadings],
142
- titleInNav: title,
143
- level: 3
144
- }
145
- headingsWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, heading)
146
- }
147
- })
148
-
149
- if (activeHeading?.sectionTitles) {
150
- activeHeading.sectionTitles.forEach((sectionTitle) => {
151
- const pageHeadingTitles = pageHeadings.map((h) => h.title)
152
- assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle })
153
- })
154
- }
155
-
156
- return headingsWithSubHeadings
157
- }
@@ -1,7 +0,0 @@
1
- button,
2
- a.button {
3
- background-color: #fafafa;
4
- border: 1px solid #aaa;
5
- border-radius: 5px;
6
- cursor: pointer;
7
- }
@@ -1,36 +0,0 @@
1
- pre > code {
2
- padding: 16px !important;
3
- }
4
- @media screen and (max-width: 900px) {
5
- pre > code {
6
- font-size: 0.7em;
7
- }
8
- }
9
- pre {
10
- display: grid;
11
- }
12
- pre > code {
13
- padding-right: 0px !important;
14
- overflow-x: auto;
15
- }
16
-
17
- @media screen and (max-width: 1139px) {
18
- pre > code {
19
- font-size: 0.95em;
20
- }
21
- }
22
- @media screen and (max-width: 1040px) {
23
- pre > code {
24
- font-size: 0.8em;
25
- }
26
- }
27
- @media screen and (max-width: 940px) {
28
- pre > code {
29
- font-size: 0.7em;
30
- }
31
- }
32
-
33
- pre > code {
34
- display: reset;
35
- word-break: reset;
36
- }