@brillout/docpress 0.1.9 → 0.1.11

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 (145) hide show
  1. package/{src/css/Inter-Var.ttf → dist/Inter-Var-IOAEQULN.ttf} +0 -0
  2. package/{src/components/Sponsors/companyLogos/ccoli.svg → dist/ccoli-CHW3TQKS.svg} +0 -0
  3. package/{src/icons/changelog.svg → dist/changelog-IPI5F42D.svg} +0 -0
  4. package/{src/navigation/navigation-fullscreen/chevron.svg → dist/chevron-K3WPYLOP.svg} +0 -0
  5. package/{src/components/features/chevron.svg → dist/chevron-R2IYJD62.svg} +0 -0
  6. package/dist/chunk-2SRWLPTC.js +9 -0
  7. package/dist/chunk-2SRWLPTC.js.map +1 -0
  8. package/dist/chunk-G2A5MZJA.js +48 -0
  9. package/dist/chunk-G2A5MZJA.js.map +1 -0
  10. package/dist/chunk-M7LTQJLV.js +178 -0
  11. package/dist/chunk-M7LTQJLV.js.map +1 -0
  12. package/dist/chunk-OEVBWUR6.js +92 -0
  13. package/dist/chunk-OEVBWUR6.js.map +1 -0
  14. package/dist/chunk-P6M6A4HU.js +154 -0
  15. package/dist/chunk-P6M6A4HU.js.map +1 -0
  16. package/dist/chunk-TTLAZ2T2.js +8 -0
  17. package/dist/chunk-TTLAZ2T2.js.map +1 -0
  18. package/dist/cli/index.d.ts +1 -0
  19. package/dist/cli/index.js +12 -8
  20. package/dist/cli/index.js.map +1 -0
  21. package/{src/navigation/navigation-fullscreen/close.svg → dist/close-IQXTDOHV.svg} +0 -0
  22. package/{src/utils/Emoji/compass.svg → dist/compass-2RWQU3E4.svg} +0 -0
  23. package/{src → dist}/components/features/FeatureList.css +2 -7
  24. package/dist/components/features/FeatureList.css.map +1 -0
  25. package/dist/components/features/FeatureList.d.ts +13 -0
  26. package/dist/components/features/FeatureList.js +8 -0
  27. package/dist/components/features/FeatureList.js.map +1 -0
  28. package/dist/components/features/initFeatureList.d.ts +3 -0
  29. package/dist/components/features/initFeatureList.js +60 -0
  30. package/dist/components/features/initFeatureList.js.map +1 -0
  31. package/{src/components/Sponsors/companyLogos/contra.svg → dist/contra-WLZBOPBV.svg} +0 -0
  32. package/dist/{cli/devServer.js → devServer-TDBL5PHQ.js} +4 -2
  33. package/dist/devServer-TDBL5PHQ.js.map +1 -0
  34. package/{src/icons/discord.svg → dist/discord-JD33TUSF.svg} +0 -0
  35. package/{src/utils/Emoji/engine.png → dist/engine-6Q6VSCVA.png} +0 -0
  36. package/{src/icons/github.svg → dist/github-P5ZSKN2N.svg} +0 -0
  37. package/{src/icons/heart.svg → dist/heart-OINVKOXO.svg} +0 -0
  38. package/dist/index.css +121 -0
  39. package/dist/index.css.map +1 -0
  40. package/dist/index.d.ts +137 -0
  41. package/dist/index.js +489 -0
  42. package/dist/index.js.map +1 -0
  43. package/{src/components/Sponsors/label.svg → dist/label-MP75CTIA.svg} +0 -0
  44. package/{src/utils/Emoji/mechanical-arm.svg → dist/mechanical-arm-TR7IQQMG.svg} +0 -0
  45. package/{src/components/Sponsors/medalBronze.svg → dist/medalBronze-CO4CTUR4.svg} +0 -0
  46. package/{src/components/Sponsors/medalGold.svg → dist/medalGold-UP6A73FL.svg} +0 -0
  47. package/{src/components/Sponsors/medalSilver.svg → dist/medalSilver-FAPGGOBN.svg} +0 -0
  48. package/{src/components/Sponsors/companyLogos/mfqs.svg → dist/mfqs-2EAEE7N6.svg} +0 -0
  49. package/dist/renderer/_default.page.client.css +263 -0
  50. package/dist/renderer/_default.page.client.css.map +1 -0
  51. package/dist/renderer/_default.page.client.d.ts +1 -0
  52. package/dist/renderer/_default.page.client.js +180 -0
  53. package/dist/renderer/_default.page.client.js.map +1 -0
  54. package/dist/renderer/_default.page.server.css +312 -0
  55. package/dist/renderer/_default.page.server.css.map +1 -0
  56. package/dist/renderer/_default.page.server.d.ts +22 -0
  57. package/dist/renderer/_default.page.server.js +602 -0
  58. package/dist/renderer/_default.page.server.js.map +1 -0
  59. package/{src/utils/Emoji/road-fork.svg → dist/road-fork-3WZLW3HB.svg} +0 -0
  60. package/{src/utils/Emoji/shield.svg → dist/shield-CU45RG5C.svg} +0 -0
  61. package/{src/icons/twitter.svg → dist/twitter-I7DXDN3J.svg} +0 -0
  62. package/{src/utils/Emoji/typescript.svg → dist/typescript-ALIPKLRM.svg} +0 -0
  63. package/dist/vite.config.d.ts +5 -0
  64. package/dist/vite.config.js +150 -0
  65. package/dist/vite.config.js.map +1 -0
  66. package/package.json +20 -26
  67. package/readme.md +4 -2
  68. package/cli.mjs +0 -2
  69. package/dist/cli/chunk-Y3OKG4SS.js +0 -30
  70. package/dist/cli/configFile.js +0 -6
  71. package/index.ts +0 -2
  72. package/src/MobileHeader.tsx +0 -68
  73. package/src/PageLayout.css +0 -41
  74. package/src/PageLayout.tsx +0 -37
  75. package/src/algolia/DocSearch.css +0 -29
  76. package/src/algolia/DocSearch.ts +0 -37
  77. package/src/autoScrollNav.ts +0 -22
  78. package/src/components/CodeBlock.tsx +0 -22
  79. package/src/components/DocLink.tsx +0 -108
  80. package/src/components/EditPageNote.tsx +0 -18
  81. package/src/components/HorizontalLine.tsx +0 -20
  82. package/src/components/ImportMeta.tsx +0 -11
  83. package/src/components/Info.tsx +0 -12
  84. package/src/components/Link.tsx +0 -18
  85. package/src/components/Note.tsx +0 -31
  86. package/src/components/P.css +0 -8
  87. package/src/components/P.tsx +0 -8
  88. package/src/components/ReadingRecommendation.tsx +0 -53
  89. package/src/components/RepoLink.tsx +0 -24
  90. package/src/components/Sponsors/companyLogos/ccoli-logo.svg +0 -1
  91. package/src/components/Sponsors/companyLogos/ccoli-text.svg +0 -1
  92. package/src/components/Sponsors/label.draft.svg +0 -108
  93. package/src/components/Sponsors.tsx +0 -243
  94. package/src/components/features/FeatureList.tsx +0 -114
  95. package/src/components/features/initFeatureList.ts +0 -66
  96. package/src/components/index.ts +0 -13
  97. package/src/config/Config.ts +0 -30
  98. package/src/config/getConfig.ts +0 -18
  99. package/src/config/resolveConfig/resolveHeading.ts +0 -0
  100. package/src/config/resolvePageContext.ts +0 -157
  101. package/src/css/button.css +0 -7
  102. package/src/css/code/block.css +0 -36
  103. package/src/css/code/inline.css +0 -27
  104. package/src/css/code.css +0 -20
  105. package/src/css/colorize-on-hover.css +0 -29
  106. package/src/css/font.css +0 -19
  107. package/src/css/heading.css +0 -25
  108. package/src/css/index.css +0 -10
  109. package/src/css/link.css +0 -17
  110. package/src/css/note.css +0 -26
  111. package/src/css/reset.css +0 -12
  112. package/src/css/table.css +0 -14
  113. package/src/css/tooltip.css +0 -11
  114. package/src/headings.ts +0 -201
  115. package/src/index.ts +0 -3
  116. package/src/installSectionUrlHashs.ts +0 -50
  117. package/src/navigation/Navigation-highlight.css +0 -41
  118. package/src/navigation/Navigation-items.css +0 -122
  119. package/src/navigation/Navigation-layout.css +0 -118
  120. package/src/navigation/Navigation.client.old.ts +0 -303
  121. package/src/navigation/Navigation.client.ts +0 -19
  122. package/src/navigation/Navigation.css +0 -12
  123. package/src/navigation/Navigation.tsx +0 -229
  124. package/src/navigation/NavigationHeader.tsx +0 -97
  125. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
  126. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -44
  127. package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -115
  128. package/src/parseEmojis.ts +0 -33
  129. package/src/renderer/_default.page.client.ts +0 -7
  130. package/src/renderer/_default.page.server.tsx +0 -69
  131. package/src/renderer/usePageContext.tsx +0 -25
  132. package/src/types.ts +0 -2
  133. package/src/utils/Emoji/Emoji.ts +0 -216
  134. package/src/utils/Emoji/assets.ts +0 -9
  135. package/src/utils/Emoji/index.ts +0 -1
  136. package/src/utils/Emoji/mountain.svg +0 -1
  137. package/src/utils/assert.ts +0 -39
  138. package/src/utils/determineSectionUrlHash.ts +0 -35
  139. package/src/utils/filter.ts +0 -12
  140. package/src/utils/index.ts +0 -6
  141. package/src/utils/isBrowser.ts +0 -5
  142. package/src/utils/jsxToTextContent.ts +0 -11
  143. package/src/utils/objectAssign.ts +0 -9
  144. package/vite.config/markdownHeadings.ts +0 -128
  145. package/vite.config.ts +0 -42
@@ -1,243 +0,0 @@
1
- import React from 'react'
2
- import iconHeart from '../icons/heart.svg'
3
- import { usePageContext } from '../renderer/usePageContext'
4
- import { assert } from '../utils'
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
- import { Emoji } from '../utils/Emoji'
13
-
14
- export { Sponsors }
15
-
16
- type Plan = 'FREE_SLOT' | 'bronze' | 'silver' | 'gold' | 'platinum'
17
-
18
- type SponsorCompany = {
19
- companyName: string
20
- companyLogo: string
21
- website: string
22
- plan: Plan
23
- }
24
- type SponsorIndividual = {
25
- username: string
26
- }
27
- type Sponsor = SponsorCompany | SponsorIndividual
28
-
29
- const sponsors: Sponsor[] = [
30
- {
31
- companyName: 'Contra',
32
- companyLogo: contraLogo,
33
- plan: 'gold',
34
- website: 'https://contra.com'
35
- },
36
- {
37
- companyName: 'ccoli',
38
- companyLogo: ccoliLogo,
39
- plan: 'silver',
40
- website: 'https://ccoli.co'
41
- },
42
- {
43
- companyName: 'My Favorite Quilt Store',
44
- companyLogo: mfqsLogo,
45
- plan: 'bronze',
46
- website: 'https://myfavoritequiltstore.com'
47
- },
48
- {
49
- username: 'spacedawwwg'
50
- },
51
- {
52
- username: 'codthing'
53
- },
54
- {
55
- username: 'Junaidhkn'
56
- },
57
- {
58
- username: 'zgfdev'
59
- }
60
- ]
61
-
62
- function Sponsors() {
63
- const pageContext = usePageContext()
64
- const { projectInfo } = pageContext.config
65
- return (
66
- <div style={{ textAlign: 'center', marginTop: 19 }}>
67
- <a
68
- className="button"
69
- href="https://github.com/sponsors/brillout"
70
- style={{
71
- color: 'inherit',
72
- display: 'inline-flex',
73
- alignItems: 'center',
74
- padding: '5px 10px',
75
- marginBottom: 10
76
- }}
77
- >
78
- <img src={iconHeart} height={22} /> <span style={{ marginLeft: 7, fontSize: '1.07em' }}>Sponsor</span>
79
- </a>
80
- <div></div>
81
- <div style={{ maxWidth: 400, display: 'inline-block', marginTop: 12, marginBottom: 12 }}>
82
- {projectInfo.projectNameJsx || projectInfo.projectName} is free and open source, made possible by wonderful
83
- sponsors.
84
- </div>
85
- <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', alignItems: 'end' }}>
86
- {sponsors.map((sponsor, i) => (
87
- <SponsorDiv sponsor={sponsor} key={i} />
88
- ))}
89
- </div>
90
- </div>
91
- )
92
- }
93
-
94
- function SponsorDiv({ sponsor }: { sponsor: Sponsor }) {
95
- let imgSrc: string
96
- let imgAlt: string | undefined
97
- let width: number
98
- let height: number
99
- let website: string
100
- let padding: number
101
- let backgroundColor = '#f0f0f0'
102
- let label: null | JSX.Element = null
103
- if ('username' in sponsor) {
104
- website = `https://github.com/${sponsor.username}`
105
- imgSrc = `https://github.com/${sponsor.username}.png?size=30`
106
- width = 30
107
- height = 30
108
- padding = 0
109
- backgroundColor = 'none'
110
- } else {
111
- imgSrc = sponsor.companyLogo
112
- website = sponsor.website
113
- const size = getSize(sponsor.plan)
114
- width = size.width
115
- height = size.height
116
- padding = size.padding
117
- imgAlt = sponsor.companyName
118
- label = <Label sponsor={sponsor} />
119
- }
120
- const marginWidth = 5
121
- return (
122
- <a
123
- href={website}
124
- style={{
125
- margin: `10px ${marginWidth}px`
126
- }}
127
- >
128
- {label}
129
- <div
130
- style={{
131
- backgroundColor,
132
- borderRadius: 7,
133
- overflow: 'hidden',
134
- width,
135
- maxWidth: `calc(100vw - 2 * var(--main-view-padding) - 2 * ${marginWidth}px)`,
136
- height,
137
- display: 'flex',
138
- alignItems: 'center',
139
- flexDirection: 'column',
140
- justifyContent: 'center'
141
- }}
142
- >
143
- <img
144
- style={{ width: `calc(100% - ${padding}px)`, height: height - padding, zIndex: 2 }}
145
- src={imgSrc}
146
- alt={imgAlt}
147
- />
148
- </div>
149
- </a>
150
- )
151
- }
152
-
153
- function Label({ sponsor }: { sponsor: Sponsor }) {
154
- assert(!('username' in sponsor))
155
- const labelBg = getLabelBg(sponsor)
156
- const labelIcon = getLabelIcon(sponsor)
157
- const labelText = getLabelText(sponsor)
158
- return (
159
- <div
160
- style={{
161
- top: 0,
162
- display: 'flex',
163
- justifyContent: 'center',
164
- alignItems: 'center',
165
- position: 'relative',
166
- paddingBottom: 1
167
- }}
168
- >
169
- {labelBg}
170
- {labelIcon}
171
- {labelText}
172
- </div>
173
- )
174
- }
175
-
176
- function getLabelBg(sponsor: SponsorCompany) {
177
- const height = sponsor.plan === 'platinum' ? 32 : 24
178
- return <img src={labelBgImg} style={{ height, position: 'absolute', bottom: 0, zIndex: -1 }} />
179
- }
180
-
181
- function getLabelText(sponsor: SponsorCompany) {
182
- if (sponsor.plan === 'platinum') {
183
- return <></>
184
- }
185
- const letterSpacing = ['bronze', 'silver', 'gold'].includes(sponsor.plan) ? 1 : undefined
186
- return (
187
- <>
188
- {' '}
189
- <span
190
- style={{
191
- zIndex: 1,
192
- fontSize: '0.82em',
193
- position: 'relative',
194
- top: 0,
195
- fontWeight: 500,
196
- color: '#666',
197
- letterSpacing
198
- }}
199
- >
200
- {capitalizeFirstLetter(sponsor.plan)}
201
- </span>
202
- </>
203
- )
204
- }
205
-
206
- function getLabelIcon(sponsor: SponsorCompany) {
207
- let medalSrc: string
208
- if (sponsor.plan === 'platinum') {
209
- return <Emoji name="trophy" style={{ fontSize: '1.3em' }} />
210
- } else if (sponsor.plan === 'gold') {
211
- medalSrc = medalGold
212
- } else if (sponsor.plan === 'silver') {
213
- medalSrc = medalSilver
214
- } else if (sponsor.plan === 'bronze') {
215
- medalSrc = medalBronze
216
- } else {
217
- assert(false)
218
- }
219
- return <img src={medalSrc} style={{ height: 15, zIndex: 1, marginRight: 5 }} />
220
- }
221
-
222
- function getSize(plan: Plan) {
223
- if (plan === 'platinum') {
224
- assert(false)
225
- }
226
- if (plan === 'gold') {
227
- return { width: 400, height: 150, padding: 95 }
228
- }
229
- if (plan === 'silver') {
230
- return { width: 300, height: 100, padding: 45 }
231
- }
232
- if (plan === 'bronze') {
233
- return { width: 200, height: 70, padding: 30 }
234
- }
235
- if (plan === 'FREE_SLOT') {
236
- return { width: 150, height: 40, padding: 15 }
237
- }
238
- assert(false)
239
- }
240
-
241
- function capitalizeFirstLetter(word: string): string {
242
- return word[0].toUpperCase() + word.slice(1)
243
- }
@@ -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'
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'
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'
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 '../../vite.config/markdownHeadings'
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
- }