@brillout/docpress 0.5.39 → 0.5.40-commit-51be4fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/MobileHeader.tsx +68 -0
  2. package/PageLayout.css +42 -0
  3. package/PageLayout.tsx +39 -0
  4. package/algolia/DocSearch.css +34 -0
  5. package/algolia/DocSearch.ts +62 -0
  6. package/autoScrollNav.ts +36 -0
  7. package/components/CodeBlockTransformer.css +9 -0
  8. package/components/CodeBlockTransformer.tsx +18 -0
  9. package/components/Comment.tsx +7 -0
  10. package/components/Consulting.tsx +47 -0
  11. package/components/Contributors.tsx +113 -0
  12. package/components/EditPageNote.tsx +18 -0
  13. package/components/HorizontalLine.tsx +20 -0
  14. package/components/ImportMeta.tsx +11 -0
  15. package/components/Link.tsx +144 -0
  16. package/components/Note.css +54 -0
  17. package/components/Note.tsx +78 -0
  18. package/components/P.css +8 -0
  19. package/components/P.tsx +8 -0
  20. package/components/ReadingRecommendation.tsx +56 -0
  21. package/components/RepoLink.tsx +24 -0
  22. package/components/Sponsors/label.draft.svg +108 -0
  23. package/components/Sponsors.tsx +218 -0
  24. package/components/Supporters.tsx +136 -0
  25. package/{dist/components → components}/features/FeatureList.css +10 -2
  26. package/components/features/FeatureList.tsx +114 -0
  27. package/components/features/initFeatureList.ts +66 -0
  28. package/components/index.ts +15 -0
  29. package/config/getConfig.ts +18 -0
  30. package/config/resolveConfig/resolveHeading.ts +0 -0
  31. package/config/resolvePageContext.ts +186 -0
  32. package/css/button.css +7 -0
  33. package/css/code/block.css +36 -0
  34. package/css/code/inline.css +27 -0
  35. package/css/code.css +20 -0
  36. package/css/colorize-on-hover.css +29 -0
  37. package/css/font.css +25 -0
  38. package/css/heading.css +45 -0
  39. package/css/index.css +12 -0
  40. package/css/link.css +17 -0
  41. package/css/reset.css +12 -0
  42. package/css/table.css +14 -0
  43. package/css/tooltip.css +11 -0
  44. package/data/maintainersList.tsx +92 -0
  45. package/data/sponsorsList.ts +147 -0
  46. package/dist/markdownHeadingsVitePlugin.d.ts +13 -0
  47. package/dist/markdownHeadingsVitePlugin.js +170 -0
  48. package/dist/utils/assert.d.ts +6 -0
  49. package/dist/utils/assert.js +48 -0
  50. package/dist/utils/determineSectionUrlHash.d.ts +4 -0
  51. package/dist/utils/determineSectionUrlHash.js +38 -0
  52. package/dist/vite.config.d.ts +3 -0
  53. package/dist/vite.config.js +32 -0
  54. package/index.ts +4 -0
  55. package/installSectionUrlHashs.ts +60 -0
  56. package/markdownHeadingsVitePlugin.ts +150 -0
  57. package/navigation/Navigation-highlight.css +41 -0
  58. package/navigation/Navigation-items.css +119 -0
  59. package/navigation/Navigation-layout.css +127 -0
  60. package/navigation/Navigation.client.ts +43 -0
  61. package/navigation/Navigation.css +3 -0
  62. package/navigation/Navigation.tsx +211 -0
  63. package/navigation/NavigationHeader.tsx +111 -0
  64. package/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
  65. package/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
  66. package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +116 -0
  67. package/package.json +26 -48
  68. package/parseEmojis.ts +35 -0
  69. package/parseTitle.ts +139 -0
  70. package/renderer/client.ts +4 -0
  71. package/renderer/onRenderHtml.tsx +69 -0
  72. package/renderer/usePageContext.tsx +25 -0
  73. package/tsconfig.json +15 -0
  74. package/tsconfig.vite-config.json +7 -0
  75. package/types/Config.ts +46 -0
  76. package/types/Heading.ts +49 -0
  77. package/utils/Emoji/Emoji.ts +224 -0
  78. package/utils/Emoji/assets.ts +9 -0
  79. package/utils/Emoji/index.ts +1 -0
  80. package/utils/Emoji/mountain.svg +1 -0
  81. package/utils/assert.ts +51 -0
  82. package/utils/client.ts +2 -0
  83. package/utils/determineSectionUrlHash.ts +44 -0
  84. package/utils/filesystemPathHandling.ts +42 -0
  85. package/utils/filter.ts +12 -0
  86. package/utils/isBrowser.ts +5 -0
  87. package/utils/jsxToTextContent.ts +11 -0
  88. package/utils/objectAssign.ts +9 -0
  89. package/utils/server.ts +7 -0
  90. package/vite.config.ts +36 -0
  91. package/bin.js +0 -3
  92. package/dist/chunk-2ZTPUQGS.js +0 -58
  93. package/dist/chunk-3QC7HYIF.js +0 -7
  94. package/dist/chunk-MGOI4AFO.js +0 -165
  95. package/dist/chunk-NVJING6T.js +0 -91
  96. package/dist/chunk-QWL3MA4E.js +0 -171
  97. package/dist/chunk-UN23G34B.js +0 -157
  98. package/dist/cli/index.d.ts +0 -1
  99. package/dist/cli/index.js +0 -34
  100. package/dist/components/features/FeatureList.d.ts +0 -13
  101. package/dist/components/features/FeatureList.js +0 -7
  102. package/dist/components/features/initFeatureList.d.ts +0 -3
  103. package/dist/components/features/initFeatureList.js +0 -59
  104. package/dist/devServer-JKH6U5PF.js +0 -36
  105. package/dist/index.css +0 -120
  106. package/dist/index.d.ts +0 -225
  107. package/dist/index.js +0 -948
  108. package/dist/renderer/_default.page.client.css +0 -318
  109. package/dist/renderer/_default.page.client.d.ts +0 -1
  110. package/dist/renderer/_default.page.client.js +0 -218
  111. package/dist/renderer/_default.page.server.css +0 -310
  112. package/dist/renderer/_default.page.server.d.ts +0 -22
  113. package/dist/renderer/_default.page.server.js +0 -665
  114. package/readme.md +0 -5
  115. /package/{dist/label-MP75CTIA.svg → components/Sponsors/label.svg} +0 -0
  116. /package/{dist/medalBronze-CO4CTUR4.svg → components/Sponsors/medalBronze.svg} +0 -0
  117. /package/{dist/medalGold-UP6A73FL.svg → components/Sponsors/medalGold.svg} +0 -0
  118. /package/{dist/medalSilver-FAPGGOBN.svg → components/Sponsors/medalSilver.svg} +0 -0
  119. /package/{dist/chevron-R2IYJD62.svg → components/features/chevron.svg} +0 -0
  120. /package/{dist/Inter-Var-IOAEQULN.ttf → css/Inter-Var.ttf} +0 -0
  121. /package/{dist/alignable-B4QZV4X7.svg → data/sponsorsList/companyLogos/alignable.svg} +0 -0
  122. /package/{dist/bluefin-JQABZFGV.svg → data/sponsorsList/companyLogos/bluefin.svg} +0 -0
  123. /package/{dist/burdaforward-EUGURYZY.png → data/sponsorsList/companyLogos/burdaforward.png} +0 -0
  124. /package/{dist/contra-WLZBOPBV.svg → data/sponsorsList/companyLogos/contra.svg} +0 -0
  125. /package/{dist/ecosia-OYRLTR5T.svg → data/sponsorsList/companyLogos/ecosia.svg} +0 -0
  126. /package/{dist/inlang-GFRWND6X.png → data/sponsorsList/companyLogos/inlang.png} +0 -0
  127. /package/{dist/optimizers-SFEZF3NW.svg → data/sponsorsList/companyLogos/optimizers.svg} +0 -0
  128. /package/{dist/sourcegraph-YR2HADLS.svg → data/sponsorsList/companyLogos/sourcegraph.svg} +0 -0
  129. /package/{dist/changelog-IPI5F42D.svg → icons/changelog.svg} +0 -0
  130. /package/{dist/discord-JD33TUSF.svg → icons/discord.svg} +0 -0
  131. /package/{dist/github-P5ZSKN2N.svg → icons/github.svg} +0 -0
  132. /package/{dist/heart-OINVKOXO.svg → icons/heart.svg} +0 -0
  133. /package/{dist/languages-KXPKJFQL.svg → icons/languages.svg} +0 -0
  134. /package/{dist/people-72KKQHU4.svg → icons/people.svg} +0 -0
  135. /package/{dist/twitter-I7DXDN3J.svg → icons/twitter.svg} +0 -0
  136. /package/{dist/chevron-K3WPYLOP.svg → navigation/navigation-fullscreen/chevron.svg} +0 -0
  137. /package/{dist/close-IQXTDOHV.svg → navigation/navigation-fullscreen/close.svg} +0 -0
  138. /package/{dist/compass-2RWQU3E4.svg → utils/Emoji/compass.svg} +0 -0
  139. /package/{dist/engine-6Q6VSCVA.png → utils/Emoji/engine.png} +0 -0
  140. /package/{dist/mechanical-arm-TR7IQQMG.svg → utils/Emoji/mechanical-arm.svg} +0 -0
  141. /package/{dist/road-fork-3WZLW3HB.svg → utils/Emoji/road-fork.svg} +0 -0
  142. /package/{dist/shield-CU45RG5C.svg → utils/Emoji/shield.svg} +0 -0
  143. /package/{dist/typescript-ALIPKLRM.svg → utils/Emoji/typescript.svg} +0 -0
@@ -1,4 +1,3 @@
1
- /* src/components/features/FeatureList.css */
2
1
  @media screen and (min-width: 840px) {
3
2
  .features-row {
4
3
  display: grid;
@@ -17,6 +16,7 @@
17
16
  grid-column: 1 / 3;
18
17
  }
19
18
  }
19
+
20
20
  @media screen and (min-width: 840px) {
21
21
  .features-row.single-column .feature {
22
22
  grid-column: 1 / span 2 !important;
@@ -25,11 +25,13 @@
25
25
  margin: auto !important;
26
26
  }
27
27
  }
28
+
28
29
  #features {
29
30
  margin: auto;
30
31
  margin-top: 0;
31
32
  max-width: 1080px;
32
33
  }
34
+
33
35
  #features summary p {
34
36
  margin: 10px 0;
35
37
  }
@@ -44,6 +46,7 @@
44
46
  .learn-more h3:first-of-type {
45
47
  margin-top: 15px;
46
48
  }
49
+
47
50
  .learn-more {
48
51
  border: var(--border-width) solid var(--border-color);
49
52
  padding: 10px 8px;
@@ -95,6 +98,8 @@ aside.learn-more.right-side {
95
98
  border-bottom: 0 !important;
96
99
  z-index: 1;
97
100
  }
101
+
102
+ /* Hide top border of .learn-more */
98
103
  .learn-more {
99
104
  position: relative;
100
105
  top: calc(-1 * var(--border-width));
@@ -103,8 +108,11 @@ aside.learn-more.right-side {
103
108
  position: relative;
104
109
  z-index: 1;
105
110
  }
111
+
106
112
  .feature .chevron {
107
- transition: filter 0.3s ease-in-out, transform 0.3s ease-in-out !important;
113
+ transition:
114
+ filter 0.3s ease-in-out,
115
+ transform 0.3s ease-in-out !important;
108
116
  }
109
117
  .feature.selected .chevron {
110
118
  transform: rotate(180deg);
@@ -0,0 +1,114 @@
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: React.ReactNode
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: React.ReactNode; rightSide: boolean }) {
109
+ return (
110
+ <aside className={'learn-more ' + (rightSide ? 'right-side' : '')} id={`learn-more-${name}`}>
111
+ {children}
112
+ </aside>
113
+ )
114
+ }
@@ -0,0 +1,66 @@
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
+ }
@@ -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 './features/FeatureList'
9
+ export * from './HorizontalLine'
10
+ export * from './Supporters'
11
+ export * from './Sponsors'
12
+ export * from './Contributors'
13
+ export * from './Consulting'
14
+ export * from './CodeBlockTransformer'
15
+ export * from './Comment'
@@ -0,0 +1,18 @@
1
+ export { getConfig }
2
+ import { assert, assertUsage } from '../utils/server'
3
+ import { Config } from '../types/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
@@ -0,0 +1,186 @@
1
+ import { assert, jsxToTextContent, objectAssign } from '../utils/server'
2
+ import type { Heading, HeadingDetached } from '../types/Heading'
3
+ import type { PageContextBuiltInServer } from 'vike/types'
4
+ import type { MarkdownHeading } from '../markdownHeadingsVitePlugin'
5
+ import type { Config } from '../types/Config'
6
+ import { getConfig } from './getConfig'
7
+ import { getHeadingsWithProcessedTitle, parseTitle } from '../parseTitle'
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 = PageContextBuiltInServer & {
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 processed = getHeadingsWithProcessedTitle(config)
27
+ const { headingsDetachedProcessed } = processed
28
+ let { headingsProcessed } = processed
29
+ const { activeHeading, activeNavigationHeading } = findHeading(
30
+ headingsProcessed,
31
+ headingsDetachedProcessed,
32
+ pageContext
33
+ )
34
+ let headingsOfDetachedPage: null | (Heading | HeadingDetached)[] = null
35
+ let headingsAll = [...headingsProcessed, ...headingsDetachedProcessed]
36
+ headingsAll = getHeadingsAll(headingsAll, pageContext, activeHeading)
37
+ if (activeNavigationHeading) {
38
+ headingsProcessed = getHeadingsAll(headingsProcessed, pageContext, activeNavigationHeading)
39
+ } else {
40
+ headingsOfDetachedPage = [activeHeading, ...getHeadingsOfTheCurrentPage(pageContext, activeHeading)]
41
+ }
42
+ const { title, isLandingPage, pageTitle } = getMetaData(
43
+ headingsDetachedProcessed,
44
+ activeNavigationHeading,
45
+ pageContext,
46
+ config
47
+ )
48
+ const { faviconUrl, algolia, tagline, twitterHandle, bannerUrl, websiteUrl } = config
49
+ const pageContextResolved = {}
50
+ objectAssign(pageContextResolved, {
51
+ ...pageContext,
52
+ meta: {
53
+ title,
54
+ faviconUrl,
55
+ twitterHandle,
56
+ bannerUrl,
57
+ websiteUrl,
58
+ tagline,
59
+ algolia
60
+ },
61
+ activeHeading,
62
+ headingsAll,
63
+ headingsProcessed,
64
+ headingsDetachedProcessed,
65
+ headingsOfDetachedPage,
66
+ isLandingPage,
67
+ pageTitle,
68
+ config
69
+ })
70
+ return pageContextResolved
71
+ }
72
+
73
+ function getMetaData(
74
+ headingsDetachedProcessed: HeadingDetached[],
75
+ activeNavigationHeading: Heading | null,
76
+ pageContext: { urlOriginal: string; exports: Exports },
77
+ config: Config
78
+ ) {
79
+ const url = pageContext.urlOriginal
80
+
81
+ let title: string
82
+ let pageTitle: string | JSX.Element | null
83
+ if (activeNavigationHeading) {
84
+ title = activeNavigationHeading.titleDocument || jsxToTextContent(activeNavigationHeading.title)
85
+ pageTitle = activeNavigationHeading.title
86
+ } else {
87
+ pageTitle = headingsDetachedProcessed.find((h) => h.url === url)!.title
88
+ title = jsxToTextContent(pageTitle)
89
+ }
90
+
91
+ const isLandingPage = url === '/'
92
+ if (!isLandingPage) {
93
+ title += ' | ' + config.projectInfo.projectName
94
+ }
95
+
96
+ if (isLandingPage) {
97
+ pageTitle = null
98
+ }
99
+
100
+ return { title, isLandingPage, pageTitle }
101
+ }
102
+
103
+ function findHeading(
104
+ headingsProcessed: Heading[],
105
+ headingsDetachedProcessed: HeadingDetached[],
106
+ pageContext: { urlOriginal: string; exports: Exports }
107
+ ): { activeHeading: Heading | HeadingDetached; activeNavigationHeading: Heading | null } {
108
+ let activeNavigationHeading: Heading | null = null
109
+ let activeHeading: Heading | HeadingDetached | null = null
110
+ assert(pageContext.urlOriginal)
111
+ const pageUrl = pageContext.urlOriginal
112
+ headingsProcessed.forEach((heading) => {
113
+ if (heading.url === pageUrl) {
114
+ activeNavigationHeading = heading
115
+ activeHeading = heading
116
+ assert(heading.level === 2, { pageUrl, heading })
117
+ }
118
+ })
119
+ if (!activeHeading) {
120
+ activeHeading = headingsDetachedProcessed.find(({ url }) => pageUrl === url) ?? null
121
+ }
122
+ if (!activeHeading) {
123
+ throw new Error(
124
+ [
125
+ `Heading not found for URL '${pageUrl}'`,
126
+ 'Heading is defined for following URLs:',
127
+ ...headingsProcessed
128
+ .map((h) => ` ${h.url}`)
129
+ .filter(Boolean)
130
+ .sort()
131
+ ].join('\n')
132
+ )
133
+ }
134
+ return { activeHeading, activeNavigationHeading }
135
+ }
136
+
137
+ function getHeadingsAll<T extends Heading | HeadingDetached>(
138
+ headingsProcessed: T[],
139
+ pageContext: { exports: Exports; urlOriginal: string },
140
+ activeHeading: T
141
+ ): T[] {
142
+ const headingsAll = headingsProcessed.slice()
143
+
144
+ const headingsOfTheCurrentPage = getHeadingsOfTheCurrentPage(pageContext, activeHeading)
145
+
146
+ const activeHeadingIdx = headingsAll.indexOf(activeHeading)
147
+ assert(activeHeadingIdx >= 0)
148
+ headingsOfTheCurrentPage.forEach((pageHeading, i) => {
149
+ headingsAll.splice(activeHeadingIdx + 1 + i, 0, pageHeading as T)
150
+ })
151
+
152
+ return headingsAll
153
+ }
154
+
155
+ function getHeadingsOfTheCurrentPage(
156
+ pageContext: { exports: Exports; urlOriginal: string },
157
+ currentHeading: Heading | HeadingDetached
158
+ ) {
159
+ const headingsOfCurrentPage: Heading[] = []
160
+
161
+ const headingsExport = pageContext.exports.headings ?? []
162
+
163
+ headingsExport.forEach((markdownHeading) => {
164
+ const title = parseTitle(markdownHeading.title)
165
+ const url: null | string = markdownHeading.headingId && '#' + markdownHeading.headingId
166
+ if (markdownHeading.headingLevel === 2) {
167
+ const heading: Heading = {
168
+ url,
169
+ title,
170
+ headingsBreadcrumb: [currentHeading, ...(currentHeading.headingsBreadcrumb ?? [])],
171
+ titleInNav: title,
172
+ level: 3
173
+ }
174
+ headingsOfCurrentPage.push(heading)
175
+ }
176
+ })
177
+
178
+ if (currentHeading?.sectionTitles) {
179
+ currentHeading.sectionTitles.forEach((sectionTitle) => {
180
+ const pageHeadingTitles = headingsExport.map((h) => h.title)
181
+ assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle })
182
+ })
183
+ }
184
+
185
+ return headingsOfCurrentPage
186
+ }
package/css/button.css ADDED
@@ -0,0 +1,7 @@
1
+ button,
2
+ a.button {
3
+ background-color: #fafafa;
4
+ border: 1px solid #aaa;
5
+ border-radius: 5px;
6
+ cursor: pointer;
7
+ }
@@ -0,0 +1,36 @@
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
+ }
@@ -0,0 +1,27 @@
1
+ code {
2
+ padding: 2px 5px;
3
+ }
4
+
5
+ /*
6
+ * Line breaks in `<code>`:
7
+ * - Avoid them on desktop
8
+ * - Allow them on mobile
9
+ * - Allo them for `<code long>`
10
+ */
11
+ code {
12
+ display: inline-block;
13
+ }
14
+ @media screen and (max-width: 500px) {
15
+ code {
16
+ word-break: break-word;
17
+ display: inline;
18
+ }
19
+ }
20
+ .inline-code-break code {
21
+ display: inline;
22
+ word-break: break-word;
23
+ }
24
+ code.long {
25
+ word-break: break-word;
26
+ display: inline;
27
+ }
package/css/code.css ADDED
@@ -0,0 +1,20 @@
1
+ @import './code/inline.css';
2
+ @import './code/block.css';
3
+
4
+ code {
5
+ /*
6
+ background-color: #f4f4f4;
7
+ 0.043137255 = 1 - (#f4 / #ff)
8
+ */
9
+ background-color: rgba(0, 0, 0, 0.043137255);
10
+ border-radius: 4px;
11
+ }
12
+
13
+ /* Inline */
14
+ code {
15
+ font-size: 1.1em;
16
+ }
17
+ /* Block */
18
+ pre > code {
19
+ font-size: 1em;
20
+ }
@@ -0,0 +1,29 @@
1
+ .colorize-on-hover,
2
+ .colorize-on-hover [class^='decolorize-'],
3
+ .colorize-on-hover [class*=' decolorize-'] {
4
+ transition: filter 0.3s ease-in-out;
5
+ }
6
+ .colorize-on-hover:hover,
7
+ .colorize-on-hover:hover [class^='decolorize-'],
8
+ .colorize-on-hover:hover [class*=' decolorize-'] {
9
+ filter: grayscale(0) opacity(1) !important;
10
+ }
11
+
12
+ .decolorize-7 {
13
+ filter: grayscale(1) opacity(0.7);
14
+ }
15
+ .decolorize-6 {
16
+ filter: grayscale(1) opacity(0.6);
17
+ }
18
+ .decolorize-5 {
19
+ filter: grayscale(1) opacity(0.5);
20
+ }
21
+ .decolorize-4 {
22
+ filter: grayscale(1) opacity(0.4);
23
+ }
24
+
25
+ /*
26
+ * Twitter opacity(0.7): #ababab > #868686
27
+ * == Following computation does NOT work ==
28
+ * Discord opacity(0.7): #6c6c6c > (0.7 * (#fff - #ababab) = #868686 = x * (#fff - #6c6c6c) <=> x = 0.7 * ((#fff - #ababab) / (#fff - #6c6c6c)) = 0.7 * ((255 - 171) / (255 - 108)) = 0.4)
29
+ */
package/css/font.css ADDED
@@ -0,0 +1,25 @@
1
+ body {
2
+ font-family: 'Inter';
3
+ }
4
+ button {
5
+ font-family: inherit;
6
+ }
7
+ body {
8
+ --color-text: #323d48;
9
+ color: var(--color-text);
10
+ line-height: 1.5;
11
+ }
12
+
13
+ @font-face {
14
+ font-family: 'Inter';
15
+ font-weight: 100 900;
16
+ font-stretch: 75% 125%;
17
+ font-style: oblique 0deg 12deg;
18
+ src: url('./Inter-Var.ttf') format('truetype-variations');
19
+ }
20
+
21
+ em,
22
+ i {
23
+ font-variation-settings: 'slnt' -10;
24
+ font-style: normal;
25
+ }
@@ -0,0 +1,45 @@
1
+ .doc-page h2,
2
+ .doc-page h3 {
3
+ margin-bottom: 16px;
4
+ }
5
+ .doc-page h2 {
6
+ margin-top: 50px;
7
+ }
8
+ .doc-page h3 {
9
+ margin-top: 40px;
10
+ }
11
+
12
+ .doc-page h1 + h2,
13
+ .doc-page h1 + h3,
14
+ .doc-page h2 + h3 {
15
+ margin-top: 0;
16
+ }
17
+
18
+ .doc-page h4 {
19
+ margin-top: 32px;
20
+ margin-bottom: 16px;
21
+ }
22
+
23
+ .doc-page h5 {
24
+ font-size: 0.94em;
25
+ color: #777;
26
+ margin-bottom: 10px;
27
+ }
28
+
29
+ /***************/
30
+ /** Clickable **/
31
+ /***************/
32
+ .doc-page h2[id],
33
+ .doc-page h3[id] {
34
+ cursor: pointer;
35
+ position: relative;
36
+ padding-left: 26px;
37
+ margin-left: -26px;
38
+ }
39
+ .doc-page h2[id]:hover::before,
40
+ .doc-page h3[id]:hover::before {
41
+ content: '#';
42
+ position: absolute;
43
+ left: calc(-1 * (0.75em - 26px));
44
+ color: #aaa;
45
+ }
package/css/index.css ADDED
@@ -0,0 +1,12 @@
1
+ @import './reset.css';
2
+ @import './colorize-on-hover.css';
3
+ @import './heading.css';
4
+ @import './button.css';
5
+ @import './link.css';
6
+ @import './font.css';
7
+ @import './code.css';
8
+ @import './table.css';
9
+ @import './tooltip.css';
10
+ @import '../algolia/DocSearch.css';
11
+ @import '../components/Note.css';
12
+ @import '../components/CodeBlockTransformer.css';
package/css/link.css ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ :root {
3
+ --link-color: #4747ff;
4
+ }
5
+ */
6
+
7
+ a {
8
+ /*
9
+ color: inherit;
10
+ color: var(--link-color);
11
+ */
12
+ color: #4747ff;
13
+ text-decoration: none;
14
+ }
15
+ a > button {
16
+ color: var(--color-text);
17
+ }
package/css/reset.css ADDED
@@ -0,0 +1,12 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+ body {
5
+ margin: 0;
6
+ }
7
+
8
+ /* Avoid tweet embeds to overflow the body width.
9
+ * Settings `overflow: hidden` to a container doesn't work (This is a CSS bug?) */
10
+ iframe {
11
+ max-width: 100%;
12
+ }