@brillout/docpress 0.1.14 → 0.1.17

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/dist/{chunk-GBXQT242.js → chunk-ZYYJWJMY.js} +38 -13
  2. package/dist/chunk-ZYYJWJMY.js.map +1 -0
  3. package/dist/{devServer-CXZI7V2M.js → devServer-J2XJQJGT.js} +2 -5
  4. package/dist/{devServer-CXZI7V2M.js.map → devServer-J2XJQJGT.js.map} +1 -1
  5. package/dist/index.d.ts +0 -136
  6. package/dist/index.js +27 -484
  7. package/dist/index.js.map +1 -1
  8. package/package.json +10 -13
  9. package/src/MobileHeader.tsx +68 -0
  10. package/src/PageLayout.css +41 -0
  11. package/src/PageLayout.tsx +37 -0
  12. package/src/algolia/DocSearch.css +29 -0
  13. package/src/algolia/DocSearch.ts +37 -0
  14. package/src/autoScrollNav.ts +22 -0
  15. package/src/cli/devServer.ts +31 -0
  16. package/src/cli/index.ts +29 -0
  17. package/src/components/CodeBlock.tsx +22 -0
  18. package/src/components/DocLink.tsx +108 -0
  19. package/src/components/EditPageNote.tsx +18 -0
  20. package/src/components/HorizontalLine.tsx +20 -0
  21. package/src/components/ImportMeta.tsx +11 -0
  22. package/src/components/Info.tsx +12 -0
  23. package/src/components/Link.tsx +18 -0
  24. package/src/components/Note.tsx +31 -0
  25. package/src/components/P.css +8 -0
  26. package/src/components/P.tsx +8 -0
  27. package/src/components/ReadingRecommendation.tsx +53 -0
  28. package/src/components/RepoLink.tsx +24 -0
  29. package/src/components/Sponsors/companyLogos/ccoli-logo.svg +1 -0
  30. package/src/components/Sponsors/companyLogos/ccoli-text.svg +1 -0
  31. package/{dist/ccoli-CHW3TQKS.svg → src/components/Sponsors/companyLogos/ccoli.svg} +0 -0
  32. package/{dist/contra-WLZBOPBV.svg → src/components/Sponsors/companyLogos/contra.svg} +0 -0
  33. package/{dist/mfqs-2EAEE7N6.svg → src/components/Sponsors/companyLogos/mfqs.svg} +0 -0
  34. package/src/components/Sponsors/label.draft.svg +108 -0
  35. package/{dist/label-MP75CTIA.svg → src/components/Sponsors/label.svg} +0 -0
  36. package/{dist/medalBronze-CO4CTUR4.svg → src/components/Sponsors/medalBronze.svg} +0 -0
  37. package/{dist/medalGold-UP6A73FL.svg → src/components/Sponsors/medalGold.svg} +0 -0
  38. package/{dist/medalSilver-FAPGGOBN.svg → src/components/Sponsors/medalSilver.svg} +0 -0
  39. package/src/components/Sponsors.tsx +242 -0
  40. package/{dist → src}/components/features/FeatureList.css +7 -2
  41. package/src/components/features/FeatureList.tsx +114 -0
  42. package/{dist/chevron-R2IYJD62.svg → src/components/features/chevron.svg} +0 -0
  43. package/src/components/features/initFeatureList.ts +66 -0
  44. package/src/components/index.ts +13 -0
  45. package/src/config/Config.ts +30 -0
  46. package/src/config/getConfig.ts +18 -0
  47. package/src/config/resolveConfig/resolveHeading.ts +0 -0
  48. package/src/config/resolvePageContext.ts +157 -0
  49. package/{dist/Inter-Var-IOAEQULN.ttf → src/css/Inter-Var.ttf} +0 -0
  50. package/src/css/button.css +7 -0
  51. package/src/css/code/block.css +36 -0
  52. package/src/css/code/inline.css +27 -0
  53. package/src/css/code.css +20 -0
  54. package/src/css/colorize-on-hover.css +29 -0
  55. package/src/css/font.css +19 -0
  56. package/src/css/heading.css +25 -0
  57. package/src/css/index.css +11 -0
  58. package/src/css/link.css +17 -0
  59. package/src/css/note.css +26 -0
  60. package/src/css/reset.css +12 -0
  61. package/src/css/table.css +14 -0
  62. package/src/css/tooltip.css +11 -0
  63. package/src/headings.ts +200 -0
  64. package/{dist/changelog-IPI5F42D.svg → src/icons/changelog.svg} +0 -0
  65. package/{dist/discord-JD33TUSF.svg → src/icons/discord.svg} +0 -0
  66. package/{dist/github-P5ZSKN2N.svg → src/icons/github.svg} +0 -0
  67. package/{dist/heart-OINVKOXO.svg → src/icons/heart.svg} +0 -0
  68. package/{dist/twitter-I7DXDN3J.svg → src/icons/twitter.svg} +0 -0
  69. package/src/index.ts +3 -0
  70. package/src/installSectionUrlHashs.ts +50 -0
  71. package/src/markdownHeadingsVitePlugin.ts +128 -0
  72. package/src/navigation/Navigation-highlight.css +41 -0
  73. package/src/navigation/Navigation-items.css +122 -0
  74. package/src/navigation/Navigation-layout.css +118 -0
  75. package/src/navigation/Navigation.client.old.ts +303 -0
  76. package/src/navigation/Navigation.client.ts +19 -0
  77. package/src/navigation/Navigation.css +12 -0
  78. package/src/navigation/Navigation.tsx +228 -0
  79. package/src/navigation/NavigationHeader.tsx +97 -0
  80. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
  81. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
  82. package/{dist/chevron-K3WPYLOP.svg → src/navigation/navigation-fullscreen/chevron.svg} +0 -0
  83. package/{dist/close-IQXTDOHV.svg → src/navigation/navigation-fullscreen/close.svg} +0 -0
  84. package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +115 -0
  85. package/src/parseEmojis.ts +33 -0
  86. package/src/renderer/_default.page.client.ts +4 -0
  87. package/src/renderer/_default.page.server.tsx +69 -0
  88. package/src/renderer/usePageContext.tsx +25 -0
  89. package/src/types.ts +2 -0
  90. package/src/utils/Emoji/Emoji.ts +216 -0
  91. package/src/utils/Emoji/assets.ts +9 -0
  92. package/{dist/compass-2RWQU3E4.svg → src/utils/Emoji/compass.svg} +0 -0
  93. package/{dist/engine-6Q6VSCVA.png → src/utils/Emoji/engine.png} +0 -0
  94. package/src/utils/Emoji/index.ts +1 -0
  95. package/{dist/mechanical-arm-TR7IQQMG.svg → src/utils/Emoji/mechanical-arm.svg} +0 -0
  96. package/src/utils/Emoji/mountain.svg +1 -0
  97. package/{dist/road-fork-3WZLW3HB.svg → src/utils/Emoji/road-fork.svg} +0 -0
  98. package/{dist/shield-CU45RG5C.svg → src/utils/Emoji/shield.svg} +0 -0
  99. package/{dist/typescript-ALIPKLRM.svg → src/utils/Emoji/typescript.svg} +0 -0
  100. package/src/utils/assert.ts +39 -0
  101. package/src/utils/client.ts +2 -0
  102. package/src/utils/crawlAllFiles.ts +17 -0
  103. package/src/utils/determineSectionUrlHash.ts +35 -0
  104. package/src/utils/filesystemPathHandling.ts +42 -0
  105. package/src/utils/filter.ts +12 -0
  106. package/src/utils/isBrowser.ts +5 -0
  107. package/src/utils/jsxToTextContent.ts +11 -0
  108. package/src/utils/objectAssign.ts +9 -0
  109. package/src/utils/server.ts +8 -0
  110. package/src/vite.config.ts +44 -0
  111. package/dist/chunk-7HKDCMSZ.js +0 -154
  112. package/dist/chunk-7HKDCMSZ.js.map +0 -1
  113. package/dist/chunk-G2A5MZJA.js +0 -48
  114. package/dist/chunk-G2A5MZJA.js.map +0 -1
  115. package/dist/chunk-GBXQT242.js.map +0 -1
  116. package/dist/chunk-JS5BGVDK.js +0 -178
  117. package/dist/chunk-JS5BGVDK.js.map +0 -1
  118. package/dist/chunk-OEVBWUR6.js +0 -92
  119. package/dist/chunk-OEVBWUR6.js.map +0 -1
  120. package/dist/chunk-TTLAZ2T2.js +0 -8
  121. package/dist/chunk-TTLAZ2T2.js.map +0 -1
  122. package/dist/cli/index.d.ts +0 -1
  123. package/dist/cli/index.js +0 -35
  124. package/dist/cli/index.js.map +0 -1
  125. package/dist/components/features/FeatureList.css.map +0 -1
  126. package/dist/components/features/FeatureList.d.ts +0 -13
  127. package/dist/components/features/FeatureList.js +0 -8
  128. package/dist/components/features/FeatureList.js.map +0 -1
  129. package/dist/components/features/initFeatureList.d.ts +0 -3
  130. package/dist/components/features/initFeatureList.js +0 -60
  131. package/dist/components/features/initFeatureList.js.map +0 -1
  132. package/dist/index.css +0 -121
  133. package/dist/index.css.map +0 -1
  134. package/dist/renderer/_default.page.client.css +0 -263
  135. package/dist/renderer/_default.page.client.css.map +0 -1
  136. package/dist/renderer/_default.page.client.d.ts +0 -1
  137. package/dist/renderer/_default.page.client.js +0 -180
  138. package/dist/renderer/_default.page.client.js.map +0 -1
  139. package/dist/renderer/_default.page.server.css +0 -312
  140. package/dist/renderer/_default.page.server.css.map +0 -1
  141. package/dist/renderer/_default.page.server.d.ts +0 -22
  142. package/dist/renderer/_default.page.server.js +0 -602
  143. package/dist/renderer/_default.page.server.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import { usePageContext } from './renderer/usePageContext'
3
+
4
+ export { MobileHeader }
5
+
6
+ function MobileHeader() {
7
+ const pageContext = usePageContext()
8
+ return (
9
+ <div
10
+ id="mobile-header"
11
+ style={{
12
+ height: 'var(--mobile-header-height)',
13
+ width: '100vw',
14
+ position: 'relative'
15
+ }}
16
+ >
17
+ <div
18
+ style={{
19
+ position: 'fixed',
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ background: 'white',
23
+ zIndex: 99,
24
+ top: 0,
25
+ left: 0,
26
+ height: 'var(--mobile-header-height)',
27
+ width: '100%',
28
+ borderBottom: '1px solid #ddd'
29
+ }}
30
+ >
31
+ <MenuToggle />
32
+ <a
33
+ href="/"
34
+ style={{
35
+ color: 'inherit',
36
+ display: 'flex',
37
+ alignItems: 'center',
38
+ justifyContent: 'left',
39
+ textDecoration: 'none'
40
+ }}
41
+ >
42
+ {pageContext.config.navHeaderMobile}
43
+ </a>
44
+ <div id="docsearch-mobile" />
45
+ </div>
46
+ </div>
47
+ )
48
+ }
49
+
50
+ function MenuToggle() {
51
+ return (
52
+ <div style={{ padding: 20, lineHeight: 0 }} id="menu-toggle">
53
+ <svg
54
+ style={{ width: 20 }}
55
+ className="icon"
56
+ xmlns="http://www.w3.org/2000/svg"
57
+ aria-hidden="true"
58
+ role="img"
59
+ viewBox="0 0 448 512"
60
+ >
61
+ <path
62
+ fill="currentColor"
63
+ d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
64
+ ></path>
65
+ </svg>
66
+ </div>
67
+ )
68
+ }
@@ -0,0 +1,41 @@
1
+ .doc-page #page-container {
2
+ padding-bottom: 100px;
3
+ }
4
+
5
+ #page-layout {
6
+ display: flex;
7
+ justify-content: center;
8
+ }
9
+ #page-layout > #navigation-wrapper,
10
+ #page-layout > #page-wrapper {
11
+ flex-grow: 1;
12
+ }
13
+ /* Avoid overflow, see https://stackoverflow.com/questions/36230944/prevent-flex-items-from-overflowing-a-container/66689926#66689926 */
14
+ #page-layout > #page-wrapper {
15
+ min-width: 0;
16
+ }
17
+
18
+ .doc-page #page-wrapper {
19
+ --main-view-max-width: 800px;
20
+ }
21
+ .landing-page #page-wrapper {
22
+ --main-view-max-width: 1010px;
23
+ }
24
+ #page-wrapper {
25
+ max-width: calc(var(--main-view-max-width) + 80px);
26
+ }
27
+ #page-content {
28
+ box-sizing: content-box;
29
+ max-width: var(--main-view-max-width);
30
+ padding: 20px var(--main-view-padding);
31
+ margin: auto;
32
+ }
33
+
34
+ #page-content {
35
+ --main-view-padding: 20px;
36
+ }
37
+ @media screen and (max-width: 1139px) {
38
+ #page-content {
39
+ --main-view-padding: 10px;
40
+ }
41
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import { Navigation, NavigationMask } from './navigation/Navigation'
3
+ import type { PageContextResolved } from './config/resolvePageContext'
4
+ import { MobileHeader } from './MobileHeader'
5
+ import { EditPageNote } from './components/EditPageNote'
6
+ import { PageContextProvider } from './renderer/usePageContext'
7
+ import './PageLayout.css'
8
+ import { NavigationFullscreenButton } from './navigation/navigation-fullscreen/NavigationFullscreenButton'
9
+
10
+ export { PageLayout }
11
+
12
+ function PageLayout({ pageContext, children }: { pageContext: PageContextResolved; children: JSX.Element }) {
13
+ const { isLandingPage, pageTitle } = pageContext
14
+ return (
15
+ <React.StrictMode>
16
+ <PageContextProvider pageContext={pageContext}>
17
+ <div id="page-layout" className={isLandingPage ? 'landing-page' : 'doc-page'}>
18
+ <div id="navigation-wrapper">
19
+ <Navigation pageContext={pageContext} />
20
+ </div>
21
+ <NavigationFullscreenButton />
22
+ <div id="page-wrapper">
23
+ <div id="page-container">
24
+ <MobileHeader />
25
+ <div id="page-content">
26
+ {pageTitle && <h1>{pageTitle}</h1>}
27
+ {children}
28
+ {!isLandingPage && <EditPageNote pageContext={pageContext} />}
29
+ </div>
30
+ </div>
31
+ <NavigationMask />
32
+ </div>
33
+ </div>
34
+ </PageContextProvider>
35
+ </React.StrictMode>
36
+ )
37
+ }
@@ -0,0 +1,29 @@
1
+ #docsearch-desktop {
2
+ max-width: 110px !important;
3
+ }
4
+ #docsearch-desktop .DocSearch-Button-Placeholder {
5
+ display: none;
6
+ padding: 0 !important;
7
+ }
8
+ #docsearch-desktop .DocSearch-Search-Icon {
9
+ margin-right: 6px !important;
10
+ }
11
+ #docsearch-desktop .DocSearch-Button {
12
+ margin-right: 3px !important;
13
+ margin-left: 1px !important;
14
+ }
15
+
16
+ #docsearch-mobile {
17
+ margin-left: auto !important;
18
+ padding-right: 20px !important;
19
+ }
20
+
21
+ #docsearch-mobile .DocSearch-Button {
22
+ margin-left: 0px !important;
23
+ }
24
+
25
+ @media screen and (max-width: 339px) {
26
+ #docsearch-mobile {
27
+ padding-right: 6px !important;
28
+ }
29
+ }
@@ -0,0 +1,37 @@
1
+ import { escapeInject } from 'vite-plugin-ssr'
2
+ import { PageContextResolved } from '../config/resolvePageContext'
3
+
4
+ export { getDocSearchCSS }
5
+ export { getDocSearchJS }
6
+
7
+ function getDocSearchCSS(pageContext: PageContextResolved) {
8
+ const docSearchCSS = !pageContext.meta.algolia
9
+ ? ''
10
+ : escapeInject`
11
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" />
12
+ `
13
+ return docSearchCSS
14
+ }
15
+
16
+ function getDocSearchJS(pageContext: PageContextResolved) {
17
+ const docSearchJS = !pageContext.meta.algolia
18
+ ? ''
19
+ : escapeInject`
20
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script>
21
+ <script type="text/javascript">
22
+ docsearch({
23
+ appId: '${pageContext.meta.algolia.appId}',
24
+ apiKey: '${pageContext.meta.algolia.apiKey}',
25
+ indexName: '${pageContext.meta.algolia.indexName}',
26
+ container: '#docsearch-desktop',
27
+ })
28
+ docsearch({
29
+ appId: '${pageContext.meta.algolia.appId}',
30
+ apiKey: '${pageContext.meta.algolia.apiKey}',
31
+ indexName: '${pageContext.meta.algolia.indexName}',
32
+ container: '#docsearch-mobile',
33
+ })
34
+ </script>
35
+ `
36
+ return docSearchJS
37
+ }
@@ -0,0 +1,22 @@
1
+ import { assert } from './utils/client'
2
+
3
+ autoScrollNav()
4
+
5
+ function autoScrollNav() {
6
+ const navigationEl = document.getElementById('navigation-content')
7
+ assert(navigationEl)
8
+ const href = window.location.pathname
9
+ const navLinks: HTMLElement[] = Array.from(navigationEl.querySelectorAll(`a[href="${href}"]`))
10
+ assert(navLinks.length <= 1, { navLinks, href })
11
+ const navLink = navLinks[0]
12
+ if (!navLink) return
13
+ navLink.scrollIntoView({
14
+ /*
15
+ behavior: 'smooth',
16
+ /*/
17
+ behavior: 'auto',
18
+ //*/
19
+ block: 'center',
20
+ inline: 'center'
21
+ })
22
+ }
@@ -0,0 +1,31 @@
1
+ import express from 'express'
2
+ import * as vite from 'vite'
3
+ import { renderPage } from 'vite-plugin-ssr'
4
+ import config from '../vite.config'
5
+ const viteVersion = (vite as { version?: string }).version || '2.?.?'
6
+
7
+ startServer()
8
+
9
+ async function startServer() {
10
+ const app = express()
11
+
12
+ const viteDevServer = await vite.createServer({
13
+ ...config,
14
+ server: { middlewareMode: viteVersion.startsWith('2') ? 'ssr' : true }
15
+ })
16
+ app.use(viteDevServer.middlewares)
17
+
18
+ app.get('*', async (req, res, next) => {
19
+ const pageContextInit = {
20
+ urlOriginal: req.originalUrl
21
+ }
22
+ const pageContext = await renderPage(pageContextInit)
23
+ if (!pageContext.httpResponse) return next()
24
+ const { body, statusCode, contentType } = pageContext.httpResponse
25
+ res.status(statusCode).type(contentType).send(body)
26
+ })
27
+
28
+ const port = 3000
29
+ app.listen(port)
30
+ console.log(`Server running at http://localhost:${port}`)
31
+ }
@@ -0,0 +1,29 @@
1
+ import { build, preview } from 'vite'
2
+ import config from '../vite.config'
3
+ import { prerender } from 'vite-plugin-ssr/prerender'
4
+ const args = process.argv.filter(Boolean).slice(2)
5
+ const isDev = args.includes('dev')
6
+ const isPreview = args.includes('preview')
7
+ const isBuild = args.includes('build')
8
+ Error.stackTraceLimit = Infinity
9
+
10
+ cli()
11
+
12
+ async function cli() {
13
+ if (isDev) {
14
+ await import('./devServer')
15
+ } else if (isBuild) {
16
+ await build(config)
17
+ await build({ ...config, build: { ssr: true } })
18
+ await prerender({ viteConfig: config })
19
+ } else if (isPreview) {
20
+ const server = await preview({ ...config, preview: { host: true } })
21
+ server.printUrls()
22
+ } else {
23
+ throw new Error(
24
+ `DocPress: unknown command \`$ docpress ${args.join(
25
+ ' '
26
+ )}\`. Known commands: \`$ docpress dev\` and \`$ docpress preview\`.`
27
+ )
28
+ }
29
+ }
@@ -0,0 +1,22 @@
1
+ export { CodeBlock }
2
+
3
+ import React from 'react'
4
+ import { assert, objectAssign } from '../utils/server'
5
+
6
+ function CodeBlock({ children, lineBreak }: { children: any; lineBreak?: true }) {
7
+ assert(lineBreak, '`lineBreak: true` is currently the only use case for <CodeBlock>')
8
+ const style = {}
9
+ if (lineBreak) {
10
+ objectAssign(style, {
11
+ wordWrap: 'break-word',
12
+ wordBreak: 'break-all',
13
+ whiteSpace: 'initial',
14
+ paddingRight: '16px !important'
15
+ })
16
+ }
17
+ return (
18
+ <pre>
19
+ <code style={style}>{children}</code>
20
+ </pre>
21
+ )
22
+ }
@@ -0,0 +1,108 @@
1
+ import React from 'react'
2
+ import { getHeadings, parseTitle, Heading, HeadingWithoutLink } from '../headings'
3
+ import { PageContextResolved } from '../config/resolvePageContext'
4
+ import { usePageContext } from '../renderer/usePageContext'
5
+ import { assert, assertUsage, determineSectionTitle, determineSectionUrlHash } from '../utils/server'
6
+
7
+ export { DocLink }
8
+
9
+ function DocLink({
10
+ href,
11
+ text,
12
+ noBreadcrumb,
13
+ doNotInferSectionTitle
14
+ }: {
15
+ href: string
16
+ text?: string | JSX.Element
17
+ noBreadcrumb?: true
18
+ doNotInferSectionTitle?: true
19
+ }) {
20
+ const pageContext = usePageContext()
21
+ return <a href={href}>{text || getTitle({ href, noBreadcrumb, pageContext, doNotInferSectionTitle })}</a>
22
+ }
23
+
24
+ function getTitle({
25
+ href,
26
+ noBreadcrumb,
27
+ pageContext,
28
+ doNotInferSectionTitle
29
+ }: {
30
+ href: string
31
+ noBreadcrumb: true | undefined
32
+ pageContext: PageContextResolved
33
+ doNotInferSectionTitle: true | undefined
34
+ }): string | JSX.Element {
35
+ let urlHash: string | null = null
36
+ let hrefWithoutHash: string = href
37
+ if (href.includes('#')) {
38
+ ;[hrefWithoutHash, urlHash] = href.split('#')
39
+ }
40
+ const heading = findHeading(hrefWithoutHash, pageContext)
41
+
42
+ const breadcrumbs: (string | JSX.Element)[] = []
43
+
44
+ if ('parentHeadings' in heading) {
45
+ breadcrumbs.push(
46
+ ...heading.parentHeadings
47
+ .slice()
48
+ .reverse()
49
+ .map(({ title }) => title)
50
+ )
51
+ }
52
+
53
+ breadcrumbs.push(heading.title)
54
+
55
+ if (urlHash) {
56
+ let sectionTitle: string | JSX.Element | undefined = undefined
57
+ if ('sectionTitles' in heading && heading.sectionTitles) {
58
+ heading.sectionTitles.forEach((title) => {
59
+ if (determineSectionUrlHash(title) === urlHash) {
60
+ sectionTitle = parseTitle(title)
61
+ }
62
+ })
63
+ }
64
+ if (!sectionTitle) {
65
+ assertUsage(
66
+ !doNotInferSectionTitle,
67
+ `Page section title not found for <Link href="\`${href}\`" doNotInferSectionTitle={true} />.`
68
+ )
69
+ sectionTitle = determineSectionTitle(href, pageContext.config.titleNormalCase)
70
+ }
71
+ breadcrumbs.push(sectionTitle)
72
+ }
73
+
74
+ {
75
+ const linkIsOnSamePage = heading.url === pageContext.urlPathname
76
+ if (noBreadcrumb || linkIsOnSamePage) {
77
+ return breadcrumbs[breadcrumbs.length - 1]
78
+ }
79
+ }
80
+
81
+ return (
82
+ <>
83
+ {breadcrumbs.map((title, i) => {
84
+ const seperator = i === 0 ? <></> : ' > '
85
+ return (
86
+ <React.Fragment key={i}>
87
+ {seperator}
88
+ {title}
89
+ </React.Fragment>
90
+ )
91
+ })}
92
+ </>
93
+ )
94
+ }
95
+
96
+ function findHeading(href: string, pageContext: PageContextResolved): Heading | HeadingWithoutLink {
97
+ assert(href.startsWith('/'), `\`href==='${href}'\` but should start with \`/\`.`)
98
+ const { headings, headingsWithoutLink } = getHeadings(pageContext.config)
99
+ {
100
+ const heading = headingsWithoutLink.find(({ url }) => href === url)
101
+ if (heading) {
102
+ return heading
103
+ }
104
+ }
105
+ const heading = headings.find(({ url }) => href === url)
106
+ assert(heading, `Could not find page \`${href}\`. Does it exist?`)
107
+ return heading
108
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+ import { RepoLink } from './RepoLink'
3
+ import { Emoji } from '../utils/server'
4
+
5
+ export { EditPageNote }
6
+
7
+ function EditPageNote({ pageContext }: { pageContext: { urlPathname: string } }) {
8
+ const text = (
9
+ <>
10
+ <Emoji name="writing-hang" /> Edit this page
11
+ </>
12
+ )
13
+ return (
14
+ <div style={{ marginTop: 50 }}>
15
+ <RepoLink path={'/docs/pages' + pageContext.urlPathname + '.page.server.mdx'} text={text} editMode={true} />
16
+ </div>
17
+ )
18
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+
3
+ export { HorizontalLine }
4
+
5
+ function HorizontalLine({ primary }: { primary?: true }) {
6
+ return (
7
+ <div className={'header-separator-line ' + (primary ? 'primary' : '')} style={{ textAlign: 'center' }}>
8
+ <hr
9
+ style={{
10
+ display: 'inline-block',
11
+ margin: 0,
12
+ border: 0,
13
+ borderTop: '1px solid #eee',
14
+ maxWidth: 500,
15
+ width: '80%'
16
+ }}
17
+ />
18
+ </div>
19
+ )
20
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { assert } from '../utils/server'
3
+
4
+ export { ImportMeta }
5
+
6
+ function ImportMeta({ prop }: { prop: string }) {
7
+ assert(!prop.startsWith('import'))
8
+ assert(!prop.startsWith('.'))
9
+ const text = 'imp' + 'ort.meta.' + prop
10
+ return <code>{text}</code>
11
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import { P } from './P'
3
+
4
+ export { Info }
5
+
6
+ function Info({ children }: { children: React.ReactNode }) {
7
+ return (
8
+ <blockquote>
9
+ <P>{children}</P>
10
+ </blockquote>
11
+ )
12
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+ import { DocLink } from './DocLink'
3
+ import { isRepoLink, RepoLink } from './RepoLink'
4
+
5
+ export { Link }
6
+
7
+ function Link(props: {
8
+ href: string
9
+ text?: string | JSX.Element
10
+ noBreadcrumb?: true
11
+ doNotInferSectionTitle?: true
12
+ }) {
13
+ if (isRepoLink(props.href)) {
14
+ return <RepoLink path={props.href} text={props.text} />
15
+ } else {
16
+ return <DocLink {...props} />
17
+ }
18
+ }
@@ -0,0 +1,31 @@
1
+ export { Note }
2
+
3
+ import React from 'react'
4
+ import { assert } from '../utils/server'
5
+
6
+ function Note({
7
+ type,
8
+ icon,
9
+ children
10
+ }: {
11
+ icon: JSX.Element | string
12
+ type?: 'error' | 'warning'
13
+ children: JSX.Element
14
+ }) {
15
+ assert(type === undefined || ['error', 'warning'].includes(type))
16
+ if (!icon) {
17
+ if (type === 'error') {
18
+ icon = ':no_entry:'
19
+ }
20
+ if (type === 'warning') {
21
+ icon = ':warning:'
22
+ }
23
+ }
24
+ return (
25
+ <blockquote className={type}>
26
+ <div style={{ marginBottom: 20 }} />
27
+ {icon} {children}
28
+ <div style={{ marginTop: 20 }} />
29
+ </blockquote>
30
+ )
31
+ }
@@ -0,0 +1,8 @@
1
+ /* Copied from Chrome's user agent stylesheet */
2
+ div.paragraph {
3
+ display: block;
4
+ margin-block-start: 1em;
5
+ margin-block-end: 1em;
6
+ margin-inline-start: 0px;
7
+ margin-inline-end: 0px;
8
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react'
2
+ import './P.css'
3
+
4
+ export { P }
5
+
6
+ function P(props: React.HTMLProps<HTMLDivElement>) {
7
+ return <div {...props} className={'paragraph'} />
8
+ }
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { Info } from './Info'
3
+ import { Link } from './Link'
4
+
5
+ export { ReadingRecommendation }
6
+
7
+ function ReadingRecommendation({ tour, links }: { tour?: true; links: string[] }) {
8
+ const multiple = links.length + (tour ? 1 : 0) > 1
9
+ return (
10
+ <Info>
11
+ {multiple ? ' ' : ''}
12
+ <b>Reading Recommendation{multiple ? '.' : ': '}</b>
13
+ {(() => {
14
+ if (!multiple) {
15
+ const link = tour ? <TourLink /> : <Link href={links[0]} />
16
+ return (
17
+ <>
18
+ {link}
19
+ {'.'}
20
+ </>
21
+ )
22
+ }
23
+ return (
24
+ <ul
25
+ style={{
26
+ marginLeft: 18,
27
+ marginTop: 11
28
+ }}
29
+ >
30
+ {tour && (
31
+ <li>
32
+ <TourLink />
33
+ </li>
34
+ )}
35
+ {links.map((link, i) => (
36
+ <li key={i}>
37
+ <Link href={link} />
38
+ </li>
39
+ ))}
40
+ </ul>
41
+ )
42
+ })()}
43
+ </Info>
44
+ )
45
+ }
46
+
47
+ function TourLink() {
48
+ return (
49
+ <>
50
+ <Link href={'/react-tour'} noBreadcrumb={true} /> or <Link href={'/vue-tour'} noBreadcrumb={true} />
51
+ </>
52
+ )
53
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react'
2
+ import { assert } from '../utils/server'
3
+ import { usePageContext } from '../renderer/usePageContext'
4
+
5
+ export { RepoLink }
6
+ export { isRepoLink }
7
+
8
+ function isRepoLink(href: string) {
9
+ return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some((start) => href.startsWith(start))
10
+ }
11
+
12
+ function RepoLink({ path, text, editMode }: { path: string; text?: string | JSX.Element; editMode?: true }) {
13
+ const pageContext = usePageContext()
14
+ assert(isRepoLink(path), { path })
15
+ text = text || path
16
+ if (!path.startsWith('/')) {
17
+ path = '/' + path
18
+ }
19
+ const viewMode = (editMode && 'edit') || (path.endsWith('/') && 'tree') || 'blob'
20
+ const { githubRepository } = pageContext.config.projectInfo
21
+ assert(githubRepository.startsWith('https://github.com/'))
22
+ const href = `${githubRepository}/${viewMode}/main${path}`
23
+ return <a href={href}>{text}</a>
24
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 156.62 156.96"><path d="M156.62 78.65c0-12.01-8.81-22.1-20.27-24.12 6.68-9.55 5.74-22.49-2.84-31.08-8.27-8.57-21.41-9.52-31.02-2.88C100.6 8.95 90.44-.01 78.32-.01S56.22 8.8 54.2 20.26c-9.55-6.68-22.49-5.74-31.08 2.84-8.71 8.71-9.56 22.19-2.31 31.33C9.08 56.24 0 66.45 0 78.65s8.83 21.91 20.32 24.05c-6.73 9.56-5.81 22.54 2.79 31.15 8.6 8.3 21.58 9.18 31.14 3.19 2.16 11.3 12.16 19.93 24.05 19.93s22.2-9.17 24.15-20.78c9.39 6.86 22.74 5.98 31.39-2.67 8.51-8.51 9.51-21.3 3.03-30.83 11.21-2.23 19.74-12.19 19.74-24.02Z" style="fill: rgb(117, 50, 168);"></path><path class="logo_svg__cls-1" fill="white" d="M61.33 72.59c.2-2.08 2.06-3.61 4.15-3.61h3.12c1.67 0 2.7-1.88 1.75-3.25-2.01-2.91-5.38-4.8-9.2-4.74-6.07.09-10.84 5.29-10.84 11.36v12.27c0 6.06 4.74 11.25 10.79 11.36s11.21-4.85 11.21-11v-3.96c0-2.23-1.81-4.04-4.04-4.04h-2.96c-2.34 0-4.21-2.01-3.98-4.39ZM95.33 72.59c.2-2.08 2.06-3.61 4.15-3.61h3.12c1.67 0 2.7-1.88 1.75-3.25-2.01-2.91-5.38-4.8-9.2-4.74-6.07.09-10.84 5.29-10.84 11.36v12.27c0 6.06 4.74 11.25 10.79 11.36s11.21-4.85 11.21-11v-3.96c0-2.23-1.81-4.04-4.04-4.04h-2.96c-2.34 0-4.21-2.01-3.98-4.39Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 366.81 127.09"><path fill="rgb(16, 24, 32)" d="M138 127.09a50.79 50.79 0 0 1-19.75-3.65 43 43 0 0 1-14.94-10.19 47 47 0 0 1-9.54-14.86 48.21 48.21 0 0 1 2.41-40.51 43.6 43.6 0 0 1 16.4-16.73q10.65-6.28 25.25-6.29t25.07 6.36a44.36 44.36 0 0 1 7 5.26 9 9 0 0 1-3.53 15.1l-3.51 1.07a10.47 10.47 0 0 1-10.37-2.41 19.48 19.48 0 0 0-4.23-3.13 21.52 21.52 0 0 0-10.64-2.67 22.56 22.56 0 0 0-11.94 3.29 22.79 22.79 0 0 0-8.5 9.27 29.85 29.85 0 0 0-3.09 13.9 28.79 28.79 0 0 0 3.17 13.73 24.89 24.89 0 0 0 8.5 9.43 21.35 21.35 0 0 0 11.86 3.46 22.14 22.14 0 0 0 7.81-1.38 22.61 22.61 0 0 0 6.61-3.78c.4-.32.77-.66 1.12-1a10.1 10.1 0 0 1 10-2.4l3.12 1a9.31 9.31 0 0 1 3.72 15.69l-.12.11a43.46 43.46 0 0 1-13.88 8.33 50.78 50.78 0 0 1-18 3ZM47.57 127.09a50.82 50.82 0 0 1-19.75-3.65 43 43 0 0 1-14.94-10.19 47.8 47.8 0 0 1-7.13-55.37 43.63 43.63 0 0 1 16.41-16.73q10.64-6.28 25.24-6.29t25.08 6.36a44.36 44.36 0 0 1 7 5.26A9 9 0 0 1 76 61.58l-3.5 1.07a10.49 10.49 0 0 1-10.4-2.41 19.42 19.42 0 0 0-4.22-3.13 21.59 21.59 0 0 0-10.65-2.67 22.59 22.59 0 0 0-11.94 3.29 22.86 22.86 0 0 0-8.5 9.27 29.85 29.85 0 0 0-3.09 13.9 28.8 28.8 0 0 0 3.18 13.73 24.89 24.89 0 0 0 8.5 9.43 21.34 21.34 0 0 0 11.85 3.46 22.19 22.19 0 0 0 7.82-1.38 22.61 22.61 0 0 0 6.61-3.78c.39-.32.76-.66 1.12-1a10.08 10.08 0 0 1 10-2.4l3.12 1a9.3 9.3 0 0 1 3.64 15.74l-.12.11a43.35 43.35 0 0 1-13.91 8.33 50.74 50.74 0 0 1-17.94 2.95ZM227.72 127.09a50.84 50.84 0 0 1-19.72-3.65 42.76 42.76 0 0 1-14.85-10.1 45.4 45.4 0 0 1-9.36-14.78 47.41 47.41 0 0 1-3.27-17.49 47.89 47.89 0 0 1 3.27-17.67 45.4 45.4 0 0 1 9.36-14.78A42.76 42.76 0 0 1 208 38.52a50.84 50.84 0 0 1 19.76-3.66 50.15 50.15 0 0 1 19.66 3.66A43.62 43.62 0 0 1 271.6 63.4a49.09 49.09 0 0 1 3.18 17.67 48.6 48.6 0 0 1-3.18 17.49 44.37 44.37 0 0 1-9.28 14.78 42.67 42.67 0 0 1-14.85 10.1 50.82 50.82 0 0 1-19.75 3.65Zm-23.53-46a29.53 29.53 0 0 0 3.09 13.74 23.7 23.7 0 0 0 8.41 9.35 22.08 22.08 0 0 0 12 3.37 21.34 21.34 0 0 0 11.85-3.46 25 25 0 0 0 8.5-9.43 28.8 28.8 0 0 0 3.18-13.73 28.93 28.93 0 0 0-3.18-13.65 24.18 24.18 0 0 0-8.5-9.43 22.55 22.55 0 0 0-23.88.08 24.27 24.27 0 0 0-8.41 9.43 29.51 29.51 0 0 0-3.06 13.7ZM294.62 0a18.06 18.06 0 0 1 18.06 18.06v78.77q0 6.21 2.06 8.36a7.48 7.48 0 0 0 5.67 2.15 24.64 24.64 0 0 0 5.67-.68h.06a5 5 0 0 1 6.1 4l1.39 7.87a5 5 0 0 1-3.3 5.56 49.5 49.5 0 0 1-6.83 1.8 59.09 59.09 0 0 1-11.16 1.2q-10.83 0-16.75-5.76t-5.92-16.45V5a5 5 0 0 1 4.95-5ZM343.79 11.42A11.42 11.42 0 0 1 355.21 0h.18a11.42 11.42 0 0 1 11.42 11.42 11.42 11.42 0 0 1-11.42 11.42h-.18a11.42 11.42 0 0 1-11.42-11.42Zm0 109V40.33a5 5 0 0 1 5-4.95 18.07 18.07 0 0 1 18.06 18.06v67a5 5 0 0 1-5 5h-13.1a5 5 0 0 1-4.96-5.02Z"></path></svg>