@brillout/docpress 0.1.20 → 0.2.1
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/bin.js +1 -1
- package/{src/css/Inter-Var.ttf → dist/Inter-Var-IOAEQULN.ttf} +0 -0
- package/{src/components/Sponsors/companyLogos/ccoli.svg → dist/ccoli-CHW3TQKS.svg} +0 -0
- package/{src/icons/changelog.svg → dist/changelog-IPI5F42D.svg} +0 -0
- package/{src/navigation/navigation-fullscreen/chevron.svg → dist/chevron-K3WPYLOP.svg} +0 -0
- package/{src/components/features/chevron.svg → dist/chevron-R2IYJD62.svg} +0 -0
- package/dist/chunk-7HKDCMSZ.js +154 -0
- package/dist/chunk-7HKDCMSZ.js.map +1 -0
- package/dist/chunk-C3OIVLKV.js +75 -0
- package/dist/chunk-C3OIVLKV.js.map +1 -0
- package/dist/chunk-G2A5MZJA.js +48 -0
- package/dist/chunk-G2A5MZJA.js.map +1 -0
- package/dist/chunk-H5CO4N2X.js +174 -0
- package/dist/chunk-H5CO4N2X.js.map +1 -0
- package/dist/chunk-TTLAZ2T2.js +8 -0
- package/dist/chunk-TTLAZ2T2.js.map +1 -0
- package/dist/{chunk-ZYYJWJMY.js → chunk-XUTBTIEE.js} +15 -42
- package/dist/chunk-XUTBTIEE.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/{src/navigation/navigation-fullscreen/close.svg → dist/close-IQXTDOHV.svg} +0 -0
- package/{src/utils/Emoji/compass.svg → dist/compass-2RWQU3E4.svg} +0 -0
- package/{src → dist}/components/features/FeatureList.css +2 -7
- package/dist/components/features/FeatureList.css.map +1 -0
- package/dist/components/features/FeatureList.d.ts +13 -0
- package/dist/components/features/FeatureList.js +8 -0
- package/dist/components/features/FeatureList.js.map +1 -0
- package/dist/components/features/initFeatureList.d.ts +3 -0
- package/dist/components/features/initFeatureList.js +60 -0
- package/dist/components/features/initFeatureList.js.map +1 -0
- package/{src/components/Sponsors/companyLogos/contra.svg → dist/contra-WLZBOPBV.svg} +0 -0
- package/dist/{devServer-J2XJQJGT.js → devServer-534L4U45.js} +5 -2
- package/dist/{devServer-J2XJQJGT.js.map → devServer-534L4U45.js.map} +1 -1
- package/{src/icons/discord.svg → dist/discord-JD33TUSF.svg} +0 -0
- package/{src/utils/Emoji/engine.png → dist/engine-6Q6VSCVA.png} +0 -0
- package/{src/icons/github.svg → dist/github-P5ZSKN2N.svg} +0 -0
- package/{src/icons/heart.svg → dist/heart-OINVKOXO.svg} +0 -0
- package/dist/index.css +121 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +459 -26
- package/dist/index.js.map +1 -1
- package/{src/components/Sponsors/label.svg → dist/label-MP75CTIA.svg} +0 -0
- package/{src/utils/Emoji/mechanical-arm.svg → dist/mechanical-arm-TR7IQQMG.svg} +0 -0
- package/{src/components/Sponsors/medalBronze.svg → dist/medalBronze-CO4CTUR4.svg} +0 -0
- package/{src/components/Sponsors/medalGold.svg → dist/medalGold-UP6A73FL.svg} +0 -0
- package/{src/components/Sponsors/medalSilver.svg → dist/medalSilver-FAPGGOBN.svg} +0 -0
- package/{src/components/Sponsors/companyLogos/mfqs.svg → dist/mfqs-2EAEE7N6.svg} +0 -0
- package/dist/renderer/_default.page.client.css +264 -0
- package/dist/renderer/_default.page.client.css.map +1 -0
- package/dist/renderer/_default.page.client.d.ts +1 -0
- package/dist/renderer/_default.page.client.js +180 -0
- package/dist/renderer/_default.page.client.js.map +1 -0
- package/dist/renderer/_default.page.server.css +312 -0
- package/dist/renderer/_default.page.server.css.map +1 -0
- package/dist/renderer/_default.page.server.d.ts +22 -0
- package/dist/renderer/_default.page.server.js +591 -0
- package/dist/renderer/_default.page.server.js.map +1 -0
- package/{src/utils/Emoji/road-fork.svg → dist/road-fork-3WZLW3HB.svg} +0 -0
- package/{src/utils/Emoji/shield.svg → dist/shield-CU45RG5C.svg} +0 -0
- package/{src/icons/twitter.svg → dist/twitter-I7DXDN3J.svg} +0 -0
- package/{src/utils/Emoji/typescript.svg → dist/typescript-ALIPKLRM.svg} +0 -0
- package/package.json +12 -9
- package/dist/chunk-ZYYJWJMY.js.map +0 -1
- package/src/MobileHeader.tsx +0 -68
- package/src/PageLayout.css +0 -41
- package/src/PageLayout.tsx +0 -37
- package/src/algolia/DocSearch.css +0 -29
- package/src/algolia/DocSearch.ts +0 -37
- package/src/autoScrollNav.ts +0 -22
- package/src/cli/devServer.ts +0 -31
- package/src/cli/index.ts +0 -29
- package/src/components/CodeBlock.tsx +0 -22
- package/src/components/DocLink.tsx +0 -108
- package/src/components/EditPageNote.tsx +0 -18
- package/src/components/HorizontalLine.tsx +0 -20
- package/src/components/ImportMeta.tsx +0 -11
- package/src/components/Info.tsx +0 -12
- package/src/components/Link.tsx +0 -18
- package/src/components/Note.tsx +0 -31
- package/src/components/P.css +0 -8
- package/src/components/P.tsx +0 -8
- package/src/components/ReadingRecommendation.tsx +0 -53
- package/src/components/RepoLink.tsx +0 -24
- package/src/components/Sponsors/companyLogos/ccoli-logo.svg +0 -1
- package/src/components/Sponsors/companyLogos/ccoli-text.svg +0 -1
- package/src/components/Sponsors/label.draft.svg +0 -108
- package/src/components/Sponsors.tsx +0 -242
- package/src/components/features/FeatureList.tsx +0 -114
- package/src/components/features/initFeatureList.ts +0 -66
- package/src/components/index.ts +0 -13
- package/src/config/Config.ts +0 -30
- package/src/config/getConfig.ts +0 -18
- package/src/config/resolveConfig/resolveHeading.ts +0 -0
- package/src/config/resolvePageContext.ts +0 -157
- package/src/css/button.css +0 -7
- package/src/css/code/block.css +0 -36
- package/src/css/code/inline.css +0 -27
- package/src/css/code.css +0 -20
- package/src/css/colorize-on-hover.css +0 -29
- package/src/css/font.css +0 -19
- package/src/css/heading.css +0 -25
- package/src/css/index.css +0 -11
- package/src/css/link.css +0 -17
- package/src/css/note.css +0 -26
- package/src/css/reset.css +0 -12
- package/src/css/table.css +0 -14
- package/src/css/tooltip.css +0 -11
- package/src/headings.ts +0 -200
- package/src/index.ts +0 -3
- package/src/installSectionUrlHashs.ts +0 -50
- package/src/markdownHeadingsVitePlugin.ts +0 -128
- package/src/navigation/Navigation-highlight.css +0 -41
- package/src/navigation/Navigation-items.css +0 -122
- package/src/navigation/Navigation-layout.css +0 -118
- package/src/navigation/Navigation.client.old.ts +0 -303
- package/src/navigation/Navigation.client.ts +0 -19
- package/src/navigation/Navigation.css +0 -12
- package/src/navigation/Navigation.tsx +0 -228
- package/src/navigation/NavigationHeader.tsx +0 -97
- package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +0 -32
- package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +0 -44
- package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +0 -115
- package/src/parseEmojis.ts +0 -33
- package/src/renderer/_default.page.client.ts +0 -4
- package/src/renderer/_default.page.server.tsx +0 -69
- package/src/renderer/usePageContext.tsx +0 -25
- package/src/types.ts +0 -2
- package/src/utils/Emoji/Emoji.ts +0 -216
- package/src/utils/Emoji/assets.ts +0 -9
- package/src/utils/Emoji/index.ts +0 -1
- package/src/utils/Emoji/mountain.svg +0 -1
- package/src/utils/assert.ts +0 -39
- package/src/utils/client.ts +0 -2
- package/src/utils/crawlAllFiles.ts +0 -17
- package/src/utils/determineSectionUrlHash.ts +0 -35
- package/src/utils/filesystemPathHandling.ts +0 -42
- package/src/utils/filter.ts +0 -12
- package/src/utils/isBrowser.ts +0 -5
- package/src/utils/jsxToTextContent.ts +0 -11
- package/src/utils/objectAssign.ts +0 -9
- package/src/utils/server.ts +0 -8
- package/src/vite.config.ts +0 -44
package/src/headings.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { assert, Emoji, EmojiName } from './utils/server'
|
|
3
|
-
|
|
4
|
-
export { getHeadings }
|
|
5
|
-
export { parseTitle }
|
|
6
|
-
|
|
7
|
-
export type Heading = Omit<HeadingDefinition, 'title' | 'titleInNav'> & {
|
|
8
|
-
title: JSX.Element
|
|
9
|
-
titleInNav: JSX.Element
|
|
10
|
-
parentHeadings: Heading[]
|
|
11
|
-
// Not sure why this is needed
|
|
12
|
-
isListTitle?: true
|
|
13
|
-
sectionTitles?: string[]
|
|
14
|
-
}
|
|
15
|
-
export type HeadingWithoutLink = {
|
|
16
|
-
url: string
|
|
17
|
-
title: string | JSX.Element
|
|
18
|
-
}
|
|
19
|
-
export type HeadingDefinition = HeadingBase &
|
|
20
|
-
(
|
|
21
|
-
| ({ level: 1; titleEmoji: EmojiName } & HeadingAbstract)
|
|
22
|
-
| ({ level: 4 } & HeadingAbstract)
|
|
23
|
-
| {
|
|
24
|
-
level: 2
|
|
25
|
-
isListTitle?: true
|
|
26
|
-
sectionTitles?: string[]
|
|
27
|
-
url: string
|
|
28
|
-
}
|
|
29
|
-
| {
|
|
30
|
-
level: 3
|
|
31
|
-
url: string
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
type HeadingBase = {
|
|
35
|
-
title: string
|
|
36
|
-
level: number
|
|
37
|
-
url?: string
|
|
38
|
-
titleDocument?: string
|
|
39
|
-
titleInNav?: string
|
|
40
|
-
// titleSize?: string
|
|
41
|
-
}
|
|
42
|
-
type HeadingAbstract = {
|
|
43
|
-
url?: undefined
|
|
44
|
-
titleDocument?: undefined
|
|
45
|
-
titleInNav?: undefined
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getHeadings(config: { headings: HeadingDefinition[]; headingsWithoutLink: HeadingWithoutLink[] }): {
|
|
49
|
-
headings: Heading[]
|
|
50
|
-
headingsWithoutLink: HeadingWithoutLink[]
|
|
51
|
-
} {
|
|
52
|
-
const headingsWithoutParent: Omit<Heading, 'parentHeadings'>[] = config.headings.map((heading: HeadingDefinition) => {
|
|
53
|
-
const titleProcessed: JSX.Element = parseTitle(heading.title)
|
|
54
|
-
|
|
55
|
-
const titleInNav = heading.titleInNav || heading.title
|
|
56
|
-
let titleInNavProcessed: JSX.Element
|
|
57
|
-
if ('isListTitle' in heading) {
|
|
58
|
-
assert(heading.isListTitle === true)
|
|
59
|
-
let titleParsed: JSX.Element = parseTitle(titleInNav)
|
|
60
|
-
// if (heading.titleSize) {
|
|
61
|
-
// titleParsed = React.createElement('span', { style: { fontSize: heading.titleSize } }, titleParsed)
|
|
62
|
-
// }
|
|
63
|
-
titleInNavProcessed = React.createElement(React.Fragment, {}, getListPrefix(), titleParsed)
|
|
64
|
-
} else {
|
|
65
|
-
titleInNavProcessed = parseTitle(titleInNav)
|
|
66
|
-
}
|
|
67
|
-
if ('titleEmoji' in heading) {
|
|
68
|
-
assert(heading.titleEmoji)
|
|
69
|
-
titleInNavProcessed = withEmoji(heading.titleEmoji, titleInNavProcessed)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const headingProcessed: Omit<Heading, 'parentHeadings'> = {
|
|
73
|
-
...heading,
|
|
74
|
-
title: titleProcessed,
|
|
75
|
-
titleInNav: titleInNavProcessed
|
|
76
|
-
}
|
|
77
|
-
return headingProcessed
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const headings: Heading[] = []
|
|
81
|
-
headingsWithoutParent.forEach((heading) => {
|
|
82
|
-
const parentHeadings = findParentHeadings(heading, headings)
|
|
83
|
-
headings.push({ ...heading, parentHeadings })
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const headingsWithoutLink = config.headingsWithoutLink.map((headingsWithoutLink) => {
|
|
87
|
-
const { url, title } = headingsWithoutLink
|
|
88
|
-
assert(
|
|
89
|
-
headings.find((heading) => heading.url === url) === undefined,
|
|
90
|
-
`remove ${headingsWithoutLink.url} from headingsWithoutLink`
|
|
91
|
-
)
|
|
92
|
-
const titleProcessed = typeof title === 'string' ? parseTitle(title) : title
|
|
93
|
-
return {
|
|
94
|
-
...headingsWithoutLink,
|
|
95
|
-
title: titleProcessed
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
assertHeadingsUrl([...headings, ...headingsWithoutLink])
|
|
100
|
-
return { headings, headingsWithoutLink }
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function findParentHeadings(heading: Omit<Heading, 'parentHeadings'>, headings: Heading[]) {
|
|
104
|
-
const parentHeadings: Heading[] = []
|
|
105
|
-
let levelCurrent = heading.level
|
|
106
|
-
let listTitleParentFound = false
|
|
107
|
-
headings
|
|
108
|
-
.slice()
|
|
109
|
-
.reverse()
|
|
110
|
-
.forEach((parentCandidate) => {
|
|
111
|
-
let isListTitleParent = false
|
|
112
|
-
if (
|
|
113
|
-
!listTitleParentFound &&
|
|
114
|
-
levelCurrent === heading.level &&
|
|
115
|
-
parentCandidate.level === heading.level &&
|
|
116
|
-
!parentCandidate.isListTitle &&
|
|
117
|
-
heading.isListTitle
|
|
118
|
-
) {
|
|
119
|
-
isListTitleParent = true
|
|
120
|
-
listTitleParentFound = true
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const isParent = parentCandidate.level < levelCurrent
|
|
124
|
-
|
|
125
|
-
if (isParent || isListTitleParent) {
|
|
126
|
-
levelCurrent = parentCandidate.level
|
|
127
|
-
parentHeadings.push(parentCandidate)
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
return parentHeadings
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function assertHeadingsUrl(headings: { url?: string }[]) {
|
|
134
|
-
const urls: Record<string, true> = {}
|
|
135
|
-
headings.forEach((heading) => {
|
|
136
|
-
if (heading.url) {
|
|
137
|
-
const { url } = heading
|
|
138
|
-
assert(url.startsWith('/'))
|
|
139
|
-
assert(!urls[url], { url })
|
|
140
|
-
urls[url] = true
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function getListPrefix() {
|
|
146
|
-
const nonBreakingSpace = String.fromCodePoint(0x00a0)
|
|
147
|
-
const bulletPoint = String.fromCodePoint(0x2022)
|
|
148
|
-
return nonBreakingSpace + bulletPoint + nonBreakingSpace
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function parseTitle(title: string): JSX.Element {
|
|
152
|
-
type Part = { nodeType: 'text' | 'code'; content: string }
|
|
153
|
-
const parts: Part[] = []
|
|
154
|
-
let current: Part | undefined
|
|
155
|
-
title.split('').forEach((letter) => {
|
|
156
|
-
if (letter === '`') {
|
|
157
|
-
if (current?.nodeType === 'code') {
|
|
158
|
-
// </code>
|
|
159
|
-
parts.push(current)
|
|
160
|
-
current = undefined
|
|
161
|
-
} else {
|
|
162
|
-
// <code>
|
|
163
|
-
if (current) {
|
|
164
|
-
parts.push(current)
|
|
165
|
-
}
|
|
166
|
-
current = { nodeType: 'code', content: '' }
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
if (!current) {
|
|
170
|
-
current = { nodeType: 'text', content: '' }
|
|
171
|
-
}
|
|
172
|
-
current.content += letter
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
if (current) {
|
|
176
|
-
parts.push(current)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const titleJsx = React.createElement(
|
|
180
|
-
React.Fragment,
|
|
181
|
-
{},
|
|
182
|
-
...parts.map((part, i) =>
|
|
183
|
-
React.createElement(part.nodeType === 'code' ? 'code' : React.Fragment, { key: i }, part.content)
|
|
184
|
-
)
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
return titleJsx
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function withEmoji(name: EmojiName, title: string | JSX.Element): JSX.Element {
|
|
191
|
-
const style = { fontSize: '1.4em' }
|
|
192
|
-
//return React.createElement(React.Fragment, null, Emoji({ name, style }), ' ', title)
|
|
193
|
-
return React.createElement(
|
|
194
|
-
'span',
|
|
195
|
-
{ style },
|
|
196
|
-
Emoji({ name }),
|
|
197
|
-
' ',
|
|
198
|
-
React.createElement('span', { style: { fontSize: '1rem' } }, title)
|
|
199
|
-
)
|
|
200
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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 navigationEl = document.getElementById('navigation-content')
|
|
15
|
-
assert(navigationEl)
|
|
16
|
-
const docSections = Array.from(document.querySelectorAll('h2'))
|
|
17
|
-
docSections.forEach((docSection) => {
|
|
18
|
-
const docTitle = docSection.textContent
|
|
19
|
-
assert(docTitle)
|
|
20
|
-
assert(docSection.id, { docSection })
|
|
21
|
-
const urlHash = '#' + docSection.id
|
|
22
|
-
assertNavLink(navigationEl, urlHash)
|
|
23
|
-
docSection.onclick = () => {
|
|
24
|
-
window.location.hash = urlHash
|
|
25
|
-
// The browser doesn't jump if hash doesn't change
|
|
26
|
-
jumpToSection()
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function assertNavLink(navigationEl: HTMLElement, urlHash: string) {
|
|
32
|
-
const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${window.location.pathname}"]`))
|
|
33
|
-
assert(parentNavLinkMatch.length <= 1)
|
|
34
|
-
if (parentNavLinkMatch.length === 0) return
|
|
35
|
-
const navLinks: HTMLElement[] = Array.from(navigationEl.querySelectorAll(`a[href="${urlHash}"]`))
|
|
36
|
-
assert(navLinks.length === 1, { urlHash })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function jumpToSection() {
|
|
40
|
-
const { hash } = window.location
|
|
41
|
-
if (hash === '' || hash === '#') {
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
assert(hash.startsWith('#'))
|
|
45
|
-
const target = document.getElementById(hash.slice(1))
|
|
46
|
-
if (!target) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
target.scrollIntoView()
|
|
50
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { assert, determineSectionUrlHash } from '../src/utils/server'
|
|
2
|
-
|
|
3
|
-
export { markdownHeadingsVitePlugin }
|
|
4
|
-
export type { MarkdownHeading }
|
|
5
|
-
|
|
6
|
-
type MarkdownHeading = {
|
|
7
|
-
title: string
|
|
8
|
-
id: string
|
|
9
|
-
headingLevel: number
|
|
10
|
-
titleAddendum?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function markdownHeadingsVitePlugin() {
|
|
14
|
-
return {
|
|
15
|
-
name: 'mdx-headings',
|
|
16
|
-
enforce: 'pre',
|
|
17
|
-
transform: async (code: string, id: string) => {
|
|
18
|
-
if (!id.includes('.page.') || !id.endsWith('.mdx')) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
const codeNew = transform(code)
|
|
22
|
-
return codeNew
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function transform(code: string) {
|
|
28
|
-
const headings: MarkdownHeading[] = []
|
|
29
|
-
let isCodeBlock = false
|
|
30
|
-
let codeNew = code
|
|
31
|
-
.split('\n')
|
|
32
|
-
.map((line) => {
|
|
33
|
-
// Skip code blocks, e.g.
|
|
34
|
-
// ~~~md
|
|
35
|
-
// # Markdown Example
|
|
36
|
-
// Bla
|
|
37
|
-
// ~~~
|
|
38
|
-
if (line.startsWith('~~~') || line.startsWith('```')) {
|
|
39
|
-
isCodeBlock = !isCodeBlock
|
|
40
|
-
return line
|
|
41
|
-
}
|
|
42
|
-
if (isCodeBlock) {
|
|
43
|
-
return line
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (line.startsWith('#')) {
|
|
47
|
-
const { id, headingLevel, title, headingHtml } = parseMarkdownHeading(line)
|
|
48
|
-
headings.push({ id, headingLevel, title })
|
|
49
|
-
return headingHtml
|
|
50
|
-
}
|
|
51
|
-
if (line.startsWith('<h')) {
|
|
52
|
-
assert(false, { line })
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return line
|
|
56
|
-
})
|
|
57
|
-
.join('\n')
|
|
58
|
-
const headingsExportCode = `export const headings = [${headings
|
|
59
|
-
.map((heading) => JSON.stringify(heading))
|
|
60
|
-
.join(', ')}];`
|
|
61
|
-
codeNew += `\n\n${headingsExportCode}\n`
|
|
62
|
-
return codeNew
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function parseMarkdownHeading(line: string): MarkdownHeading & { headingHtml: string } {
|
|
66
|
-
const [lineBegin, ...lineWords] = line.split(' ')
|
|
67
|
-
assert(lineBegin.split('#').join('') === '', { line, lineWords })
|
|
68
|
-
const headingLevel = lineBegin.length
|
|
69
|
-
|
|
70
|
-
const titleMdx = lineWords.join(' ')
|
|
71
|
-
assert(!titleMdx.startsWith(' '), { line, lineWords })
|
|
72
|
-
assert(titleMdx, { line, lineWords })
|
|
73
|
-
|
|
74
|
-
const id = determineSectionUrlHash(titleMdx)
|
|
75
|
-
const title = titleMdx
|
|
76
|
-
|
|
77
|
-
const headingHtml = `<h${headingLevel} id="${id}">${parseTitle(title)}</h${headingLevel}>`
|
|
78
|
-
|
|
79
|
-
const heading = { headingLevel, title, id, headingHtml }
|
|
80
|
-
return heading
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function parseTitle(titleMarkdown: string): string {
|
|
84
|
-
type Part = { nodeType: 'text' | 'code'; content: string }
|
|
85
|
-
const parts: Part[] = []
|
|
86
|
-
let current: Part | undefined
|
|
87
|
-
titleMarkdown.split('').forEach((letter) => {
|
|
88
|
-
if (letter === '`') {
|
|
89
|
-
if (current?.nodeType === 'code') {
|
|
90
|
-
// </code>
|
|
91
|
-
parts.push(current)
|
|
92
|
-
current = undefined
|
|
93
|
-
} else {
|
|
94
|
-
// <code>
|
|
95
|
-
if (current) {
|
|
96
|
-
parts.push(current)
|
|
97
|
-
}
|
|
98
|
-
current = { nodeType: 'code', content: '' }
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
if (!current) {
|
|
102
|
-
current = { nodeType: 'text', content: '' }
|
|
103
|
-
}
|
|
104
|
-
current.content += letter
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
if (current) {
|
|
108
|
-
parts.push(current)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const titleHtml = parts
|
|
112
|
-
.map((part) => {
|
|
113
|
-
if (part.nodeType === 'code') {
|
|
114
|
-
return `<code>${serializeText(part.content)}</code>`
|
|
115
|
-
} else {
|
|
116
|
-
assert(part.nodeType === 'text', { parts })
|
|
117
|
-
return serializeText(part.content)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
.join('')
|
|
121
|
-
|
|
122
|
-
return titleHtml
|
|
123
|
-
|
|
124
|
-
function serializeText(text: string) {
|
|
125
|
-
const textEscaped = text.split("'").join("\\'")
|
|
126
|
-
return `{'${textEscaped}'}`
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
.nav-item {
|
|
3
|
-
border-top: 1px solid transparent;
|
|
4
|
-
}
|
|
5
|
-
.nav-item.is-active {
|
|
6
|
-
border-color: #eaeaea;
|
|
7
|
-
}
|
|
8
|
-
.nav-item[is-active] {
|
|
9
|
-
background-color: attr(is-active)
|
|
10
|
-
}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
#navigation-container:not(:hover) ::-webkit-scrollbar {
|
|
15
|
-
display: none;
|
|
16
|
-
}
|
|
17
|
-
#navigation-container ::-webkit-scrollbar-thumb {
|
|
18
|
-
opacity: 0;
|
|
19
|
-
}
|
|
20
|
-
#navigation-container ::-webkit-scrollbar-track {
|
|
21
|
-
opacity: 0;
|
|
22
|
-
}
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
.nav-tree:not(.expanded) > .nav-tree {
|
|
27
|
-
edisplay: none;
|
|
28
|
-
background:red;
|
|
29
|
-
}
|
|
30
|
-
*/
|
|
31
|
-
/*
|
|
32
|
-
.nav-tree.expanded,
|
|
33
|
-
.nav-tree.expanded > .nav-tree {
|
|
34
|
-
display: inherit;
|
|
35
|
-
}
|
|
36
|
-
.nav-tree.expanded,
|
|
37
|
-
.nav-tree.expanded > .nav-tree {
|
|
38
|
-
display: inherit;
|
|
39
|
-
background:red;
|
|
40
|
-
}
|
|
41
|
-
*/
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
.nav-item {
|
|
2
|
-
display: block;
|
|
3
|
-
white-space: nowrap;
|
|
4
|
-
overflow-x: hidden;
|
|
5
|
-
--padding-left-global: 9px;
|
|
6
|
-
--padding-left-additional: 0px;
|
|
7
|
-
}
|
|
8
|
-
.nav-item code {
|
|
9
|
-
font-size: 0.9em;
|
|
10
|
-
}
|
|
11
|
-
.nav-item-h1 + .nav-item-h4 {
|
|
12
|
-
margin-top: -2px;
|
|
13
|
-
}
|
|
14
|
-
.nav-item-h4 {
|
|
15
|
-
margin-top: 14px;
|
|
16
|
-
margin-bottom: -1px;
|
|
17
|
-
color: #999;
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
font-weight: 400;
|
|
20
|
-
letter-spacing: 0.15ch;
|
|
21
|
-
padding-left: var(--padding-left-global);
|
|
22
|
-
padding-right: 4px;
|
|
23
|
-
text-decoration: none;
|
|
24
|
-
}
|
|
25
|
-
.nav-column:first-of-type > .nav-h1-group:first-of-type > .nav-item-h1:first-of-type {
|
|
26
|
-
margin-top: 20px;
|
|
27
|
-
}
|
|
28
|
-
.nav-item-h1 {
|
|
29
|
-
margin-top: 30px;
|
|
30
|
-
font-size: 15.4px;
|
|
31
|
-
text-transform: uppercase;
|
|
32
|
-
font-weight: 600;
|
|
33
|
-
letter-spacing: 0.15ch;
|
|
34
|
-
color: var(--color-text);
|
|
35
|
-
padding: 12px 0;
|
|
36
|
-
padding-left: calc(var(--padding-left-global) - 2px);
|
|
37
|
-
padding-right: 4px;
|
|
38
|
-
text-decoration: none;
|
|
39
|
-
}
|
|
40
|
-
.nav-item-h2 {
|
|
41
|
-
text-decoration: none;
|
|
42
|
-
font-size: 14.4px;
|
|
43
|
-
font-weight: 400;
|
|
44
|
-
letter-spacing: 0.15ch;
|
|
45
|
-
color: var(--color-text);
|
|
46
|
-
padding-left: var(--padding-left-global);
|
|
47
|
-
padding-right: 0;
|
|
48
|
-
--padding: 4px;
|
|
49
|
-
padding-top: var(--padding);
|
|
50
|
-
padding-bottom: var(--padding);
|
|
51
|
-
}
|
|
52
|
-
.nav-item-h3 {
|
|
53
|
-
font-size: 12px;
|
|
54
|
-
font-weight: 400;
|
|
55
|
-
letter-spacing: 0.15ch;
|
|
56
|
-
color: var(--color-text);
|
|
57
|
-
text-decoration: none;
|
|
58
|
-
--padding: 5px;
|
|
59
|
-
|
|
60
|
-
background-color: #f9f9f9;
|
|
61
|
-
padding: var(--padding) 0;
|
|
62
|
-
padding-left: calc(var(--padding-left-global) + var(--padding-left-additional));
|
|
63
|
-
}
|
|
64
|
-
html.navigation-fullscreen .nav-item-h3 {
|
|
65
|
-
border-right: 4px solid #eee;
|
|
66
|
-
}
|
|
67
|
-
.nav-item-h3.nav-item-first-of-its-kind {
|
|
68
|
-
padding-top: calc(var(--padding) * 1.6);
|
|
69
|
-
}
|
|
70
|
-
.nav-item-h3.nav-item-last-of-its-kind {
|
|
71
|
-
padding-bottom: calc(var(--padding) * 2);
|
|
72
|
-
}
|
|
73
|
-
.nav-item-h2,
|
|
74
|
-
.nav-item-h3 {
|
|
75
|
-
position: relative;
|
|
76
|
-
}
|
|
77
|
-
/*
|
|
78
|
-
.nav-item-h2.is-active .nav-item-text{
|
|
79
|
-
background-color: var(--background-color);
|
|
80
|
-
}
|
|
81
|
-
*/
|
|
82
|
-
.nav-item-h2.is-active {
|
|
83
|
-
background-color: var(--background-color);
|
|
84
|
-
}
|
|
85
|
-
.nav-item-h3.is-active:before {
|
|
86
|
-
display: block;
|
|
87
|
-
content: '';
|
|
88
|
-
position: absolute;
|
|
89
|
-
width: 4px;
|
|
90
|
-
left: 0;
|
|
91
|
-
top: 0;
|
|
92
|
-
height: 100%;
|
|
93
|
-
background-color: var(--background-color);
|
|
94
|
-
z-index: 10;
|
|
95
|
-
}
|
|
96
|
-
.nav-item-h3.is-active-last:after {
|
|
97
|
-
display: block;
|
|
98
|
-
content: '';
|
|
99
|
-
position: absolute;
|
|
100
|
-
height: 4px;
|
|
101
|
-
left: 0;
|
|
102
|
-
bottom: 0;
|
|
103
|
-
width: 100%;
|
|
104
|
-
background-color: var(--background-color);
|
|
105
|
-
z-index: 10;
|
|
106
|
-
border-bottom-left-radius: 5px;
|
|
107
|
-
}
|
|
108
|
-
html.navigation-fullscreen .nav-item {
|
|
109
|
-
--expend-border-radius: 5px;
|
|
110
|
-
}
|
|
111
|
-
.nav-item.is-active-first {
|
|
112
|
-
border-top-left-radius: 5px;
|
|
113
|
-
border-top-right-radius: var(--expend-border-radius);
|
|
114
|
-
}
|
|
115
|
-
.nav-item.is-active-last,
|
|
116
|
-
.nav-item.is-active-last:before {
|
|
117
|
-
border-bottom-left-radius: 5px;
|
|
118
|
-
border-bottom-right-radius: var(--expend-border-radius);
|
|
119
|
-
}
|
|
120
|
-
.nav-item-h3.nav-item-parent-is-list-heading {
|
|
121
|
-
--padding-left-additional: 21px;
|
|
122
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--mobile-header-height: 60px;
|
|
3
|
-
--navigation-min-height: 300px;
|
|
4
|
-
--navigation-max-height: 350px;
|
|
5
|
-
}
|
|
6
|
-
#navigation-wrapper {
|
|
7
|
-
min-width: var(--navigation-min-height);
|
|
8
|
-
}
|
|
9
|
-
.doc-page #navigation-wrapper {
|
|
10
|
-
max-width: var(--navigation-max-height);
|
|
11
|
-
}
|
|
12
|
-
.landing-page #navigation-wrapper {
|
|
13
|
-
/* prettier-ignore */
|
|
14
|
-
max-width: min(var(--navigation-max-height), max(var(--navigation-min-height), calc(var(--navigation-min-height) + 100vw - 1240px)));
|
|
15
|
-
}
|
|
16
|
-
#navigation-container {
|
|
17
|
-
/* `position: fixed` doesn't inherit the parent's width */
|
|
18
|
-
position: sticky;
|
|
19
|
-
overflow-y: auto;
|
|
20
|
-
overscroll-behavior: contain;
|
|
21
|
-
border-right: 1px solid #eee;
|
|
22
|
-
}
|
|
23
|
-
#navigation-mask {
|
|
24
|
-
position: fixed;
|
|
25
|
-
width: 100vw;
|
|
26
|
-
height: 100vh;
|
|
27
|
-
top: 0;
|
|
28
|
-
left: 0;
|
|
29
|
-
z-index: 2;
|
|
30
|
-
}
|
|
31
|
-
/* `1140px` is the breaking point that preserves the width of code blocks. */
|
|
32
|
-
/* BEFORE EDITING THIS: also change the `1139px` value below */
|
|
33
|
-
@media screen and (min-width: 1140px) {
|
|
34
|
-
#mobile-header {
|
|
35
|
-
display: none !important;
|
|
36
|
-
}
|
|
37
|
-
#navigation-container {
|
|
38
|
-
height: 100vh;
|
|
39
|
-
top: 0;
|
|
40
|
-
}
|
|
41
|
-
#navigation-mask {
|
|
42
|
-
display: none;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
#navigation-container {
|
|
46
|
-
transition: transform 0.25s ease;
|
|
47
|
-
background: white;
|
|
48
|
-
z-index: 3;
|
|
49
|
-
}
|
|
50
|
-
#page-wrapper {
|
|
51
|
-
margin-left: calc(-1 * var(--navigation-fullscreen-button-width));
|
|
52
|
-
}
|
|
53
|
-
@media screen and (max-width: 1139px) {
|
|
54
|
-
#navigation-header-logo,
|
|
55
|
-
#docsearch {
|
|
56
|
-
display: none !important;
|
|
57
|
-
}
|
|
58
|
-
#navigation-wrapper {
|
|
59
|
-
min-width: 0px !important;
|
|
60
|
-
max-width: 0px !important;
|
|
61
|
-
}
|
|
62
|
-
#navigation-fullscreen-button {
|
|
63
|
-
display: none;
|
|
64
|
-
}
|
|
65
|
-
#page-wrapper {
|
|
66
|
-
margin-left: 0 !important;
|
|
67
|
-
}
|
|
68
|
-
#navigation-container {
|
|
69
|
-
--width: min(100vw, 350px);
|
|
70
|
-
width: var(--width);
|
|
71
|
-
left: 0;
|
|
72
|
-
height: calc(100vh - var(--mobile-header-height));
|
|
73
|
-
top: var(--mobile-header-height);
|
|
74
|
-
padding-top: 20px;
|
|
75
|
-
/* `position: sticky` doesn't seem to work on mobile */
|
|
76
|
-
position: fixed;
|
|
77
|
-
}
|
|
78
|
-
body:not(.show-menu) #navigation-container {
|
|
79
|
-
transform: translateX(calc(-1 * var(--width)));
|
|
80
|
-
}
|
|
81
|
-
body:not(.show-menu) #navigation-mask {
|
|
82
|
-
display: none;
|
|
83
|
-
}
|
|
84
|
-
#mobile-header {
|
|
85
|
-
display: inherit;
|
|
86
|
-
}
|
|
87
|
-
.doc-page h2 {
|
|
88
|
-
--padding-top: calc(var(--mobile-header-height) + 12px) !important;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
html.navigation-fullscreen #navigation-container {
|
|
93
|
-
width: 100vw;
|
|
94
|
-
height: 100vh;
|
|
95
|
-
overflow-y: scroll;
|
|
96
|
-
position: fixed;
|
|
97
|
-
top: 0;
|
|
98
|
-
left: 0;
|
|
99
|
-
background-color: white;
|
|
100
|
-
}
|
|
101
|
-
html.navigation-fullscreen #navigation-header {
|
|
102
|
-
display: none !important;
|
|
103
|
-
}
|
|
104
|
-
html.navigation-fullscreen #navigation-content {
|
|
105
|
-
display: flex;
|
|
106
|
-
margin: auto; /* A `max-width` is set by src/navigation/navigation-fullscreen/initNavigationFullscreen.ts */
|
|
107
|
-
}
|
|
108
|
-
html.navigation-fullscreen #navigation-content > .nav-column {
|
|
109
|
-
flex-grow: 1;
|
|
110
|
-
max-width: 350px;
|
|
111
|
-
}
|
|
112
|
-
html.navigation-fullscreen .nav-column > .nav-h1-group:first-child > .nav-item-h1:first-child {
|
|
113
|
-
margin-top: 0px;
|
|
114
|
-
}
|
|
115
|
-
html.navigation-fullscreen {
|
|
116
|
-
/* disable scroll of main view */
|
|
117
|
-
overflow: hidden !important;
|
|
118
|
-
}
|