@brillout/docpress 0.0.45

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 (107) hide show
  1. package/cli.mjs +2 -0
  2. package/dist/cli/chunk-KZROB63P.js +8 -0
  3. package/dist/cli/configFile.js +6 -0
  4. package/dist/cli/devServer.js +31 -0
  5. package/dist/cli/index.js +37 -0
  6. package/index.ts +2 -0
  7. package/mdx.d.ts +6 -0
  8. package/package.json +73 -0
  9. package/readme.md +3 -0
  10. package/src/MobileHeader.tsx +68 -0
  11. package/src/PageLayout.css +32 -0
  12. package/src/PageLayout.tsx +43 -0
  13. package/src/algolia/DocSearch.css +29 -0
  14. package/src/algolia/DocSearch.ts +37 -0
  15. package/src/autoScrollNav.ts +22 -0
  16. package/src/components/ContactUs.tsx +19 -0
  17. package/src/components/DocLink.tsx +108 -0
  18. package/src/components/EditPageNote.tsx +18 -0
  19. package/src/components/HorizontalLine.tsx +20 -0
  20. package/src/components/ImportMeta.tsx +11 -0
  21. package/src/components/Info.tsx +12 -0
  22. package/src/components/Link.tsx +18 -0
  23. package/src/components/Note.tsx +31 -0
  24. package/src/components/P.css +8 -0
  25. package/src/components/P.tsx +8 -0
  26. package/src/components/ReadingRecommendation.tsx +53 -0
  27. package/src/components/RepoLink.tsx +24 -0
  28. package/src/components/Sponsors/companyLogos/ccoli-logo.svg +1 -0
  29. package/src/components/Sponsors/companyLogos/ccoli-text.svg +1 -0
  30. package/src/components/Sponsors/companyLogos/ccoli.svg +9 -0
  31. package/src/components/Sponsors/companyLogos/contra.svg +1 -0
  32. package/src/components/Sponsors/companyLogos/mfqs.svg +1 -0
  33. package/src/components/Sponsors/label.draft.svg +108 -0
  34. package/src/components/Sponsors/label.svg +5 -0
  35. package/src/components/Sponsors/medalBronze.svg +65 -0
  36. package/src/components/Sponsors/medalGold.svg +65 -0
  37. package/src/components/Sponsors/medalSilver.svg +65 -0
  38. package/src/components/Sponsors.tsx +240 -0
  39. package/src/components/TextContactUs.tsx +15 -0
  40. package/src/components/features/FeatureList.css +117 -0
  41. package/src/components/features/FeatureList.tsx +114 -0
  42. package/src/components/features/chevron.svg +7 -0
  43. package/src/components/features/initFeatureList.ts +61 -0
  44. package/src/components/index.ts +14 -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 +156 -0
  49. package/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 +10 -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 +206 -0
  64. package/src/icons/changelog.svg +2 -0
  65. package/src/icons/discord.svg +10 -0
  66. package/src/icons/github.svg +74 -0
  67. package/src/icons/heart.svg +1 -0
  68. package/src/icons/twitter.svg +16 -0
  69. package/src/index.ts +3 -0
  70. package/src/installSectionUrlHashs.ts +50 -0
  71. package/src/navigation/Navigation-highlight.css +41 -0
  72. package/src/navigation/Navigation-items.css +122 -0
  73. package/src/navigation/Navigation-layout.css +119 -0
  74. package/src/navigation/Navigation.client.old.ts +303 -0
  75. package/src/navigation/Navigation.client.ts +19 -0
  76. package/src/navigation/Navigation.css +8 -0
  77. package/src/navigation/Navigation.tsx +228 -0
  78. package/src/navigation/NavigationHeader.tsx +97 -0
  79. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.css +32 -0
  80. package/src/navigation/navigation-fullscreen/NavigationFullscreenButton.tsx +44 -0
  81. package/src/navigation/navigation-fullscreen/chevron.svg +1 -0
  82. package/src/navigation/navigation-fullscreen/close.svg +4 -0
  83. package/src/navigation/navigation-fullscreen/initNavigationFullscreen.ts +115 -0
  84. package/src/parseEmojis.ts +33 -0
  85. package/src/renderer/_default.page.client.ts +7 -0
  86. package/src/renderer/_default.page.server.tsx +69 -0
  87. package/src/renderer/usePageContext.tsx +25 -0
  88. package/src/types.ts +2 -0
  89. package/src/utils/Emoji/Emoji.ts +216 -0
  90. package/src/utils/Emoji/assets.ts +9 -0
  91. package/src/utils/Emoji/compass.svg +1 -0
  92. package/src/utils/Emoji/engine.png +0 -0
  93. package/src/utils/Emoji/index.ts +1 -0
  94. package/src/utils/Emoji/mechanical-arm.svg +1 -0
  95. package/src/utils/Emoji/mountain.svg +1 -0
  96. package/src/utils/Emoji/road-fork.svg +17 -0
  97. package/src/utils/Emoji/shield.svg +1 -0
  98. package/src/utils/Emoji/typescript.svg +1 -0
  99. package/src/utils/assert.ts +39 -0
  100. package/src/utils/determineSectionUrlHash.ts +35 -0
  101. package/src/utils/filter.ts +12 -0
  102. package/src/utils/index.ts +6 -0
  103. package/src/utils/isBrowser.ts +5 -0
  104. package/src/utils/jsxToTextContent.ts +11 -0
  105. package/src/utils/objectAssign.ts +6 -0
  106. package/vite.config/markdownHeadings.ts +128 -0
  107. package/vite.config.ts +42 -0
package/cli.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './dist/cli/index.js'
@@ -0,0 +1,8 @@
1
+ // cli/configFile.ts
2
+ import { createRequire } from "module";
3
+ var require2 = createRequire(import.meta.url);
4
+ var configFile = require2.resolve("../../vite.config.ts");
5
+
6
+ export {
7
+ configFile
8
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ configFile
3
+ } from "./chunk-KZROB63P.js";
4
+ export {
5
+ configFile
6
+ };
@@ -0,0 +1,31 @@
1
+ import {
2
+ configFile
3
+ } from "./chunk-KZROB63P.js";
4
+
5
+ // cli/devServer.ts
6
+ import express from "express";
7
+ import * as vite from "vite";
8
+ import { renderPage } from "vite-plugin-ssr";
9
+ var viteVersion = vite.version || "2.?.?";
10
+ startServer();
11
+ async function startServer() {
12
+ const app = express();
13
+ const viteDevServer = await vite.createServer({
14
+ configFile,
15
+ server: { middlewareMode: viteVersion.startsWith("2") ? "ssr" : true }
16
+ });
17
+ app.use(viteDevServer.middlewares);
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)
24
+ return next();
25
+ const { body, statusCode, contentType } = pageContext.httpResponse;
26
+ res.status(statusCode).type(contentType).send(body);
27
+ });
28
+ const port = 3e3;
29
+ app.listen(port);
30
+ console.log(`Server running at http://localhost:${port}`);
31
+ }
@@ -0,0 +1,37 @@
1
+ import {
2
+ configFile
3
+ } from "./chunk-KZROB63P.js";
4
+
5
+ // cli/index.ts
6
+ import { build, preview } from "vite";
7
+ import { prerender } from "vite-plugin-ssr/prerender";
8
+ var args = process.argv.filter(Boolean).slice(2);
9
+ var isDev = args.includes("dev");
10
+ var isPreview = args.includes("preview");
11
+ var isBuild = args.includes("build");
12
+ Error.stackTraceLimit = Infinity;
13
+ cli();
14
+ async function cli() {
15
+ if (isDev) {
16
+ await import("./devServer.js");
17
+ } else if (isBuild) {
18
+ const commonConfig = {
19
+ configFile,
20
+ vitePluginSsr: {
21
+ disableAutoFullBuild: true
22
+ }
23
+ };
24
+ await build({ ...commonConfig });
25
+ await build({ ...commonConfig, build: { ssr: true } });
26
+ await prerender({ viteConfig: { configFile } });
27
+ } else if (isPreview) {
28
+ const server = await preview({ configFile, preview: { host: true } });
29
+ server.printUrls();
30
+ } else {
31
+ throw new Error(
32
+ `DocPress: unknown command \`$ docpress ${args.join(
33
+ " "
34
+ )}\`. Known commands: \`$ docpress dev\` and \`$ docpress preview\`.`
35
+ );
36
+ }
37
+ }
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Needed for users using TypeScript wihout `package.json#exports` enabled (e.g. <= TS 4.6, or TS 4.7 without `"module": "node16"` / `"module": "nodenext"`)
2
+ export * from './src/index'
package/mdx.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ declare module '*.mdx' {
2
+ import { FunctionComponent } from 'react'
3
+ const value: FunctionComponent
4
+ export default value
5
+ export const headings: { level: number; title: string; id: string; titleAddendum?: string }[]
6
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@brillout/docpress",
3
+ "version": "0.0.45",
4
+ "exports": {
5
+ ".": "./src/index.ts",
6
+ "./client/initFeatureList": {
7
+ "browser": "./src/components/features/initFeatureList.ts"
8
+ },
9
+ "./style.css": {
10
+ "browser": "./src/css/index.css"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "// === DocPress Demo ===": "",
15
+ "dev": "pnpm run build && pnpm run demo:dev",
16
+ "preview": "pnpm run build && pnpm run demo:preview",
17
+ "demo:dev": "docpress dev",
18
+ "demo:preview": "docpress build && docpress preview",
19
+ "// === DocPress Source Code ===": "",
20
+ "build": "rm -rf dist/ && tsup ./cli/ --format esm --out-dir ./dist/cli/",
21
+ "reset": "git clean -Xdf && pnpm install",
22
+ "// === Release ===": "",
23
+ "prepublishOnly": "pnpm run build",
24
+ "release": "npm version patch && npm publish && git push && git push --tags"
25
+ },
26
+ "dependencies": {
27
+ "@mdx-js/mdx": "^2.0.0",
28
+ "@mdx-js/react": "^2.0.0",
29
+ "@mdx-js/rollup": "^2.0.0",
30
+ "@vitejs/plugin-react": "^2.0.1",
31
+ "balloon-css": "^1.2.0",
32
+ "express": "^4.17.1",
33
+ "rehype-pretty-code": "^0.3.2",
34
+ "remark-gfm": "^3.0.1",
35
+ "shiki": "^0.10.1",
36
+ "twemoji": "^13.1.0",
37
+ "vite": "^3.0.9",
38
+ "vite-plugin-ssr": "^0.4.28"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "18",
42
+ "react-dom": "18"
43
+ },
44
+ "devDependencies": {
45
+ "@types/express": "^4.17.13",
46
+ "@types/node": "^15.12.1",
47
+ "@types/react": "^17.0.44",
48
+ "@types/react-dom": "^17.0.6",
49
+ "react": "^18.1.0",
50
+ "react-dom": "^18.1.0",
51
+ "rollup": "^2.74.1",
52
+ "tsup": "^6.0.1",
53
+ "typescript": "^4.5.4",
54
+ "docpress": "link:"
55
+ },
56
+ "bin": {
57
+ "docpress": "./cli.mjs"
58
+ },
59
+ "files": [
60
+ "src/*",
61
+ "*.ts",
62
+ "dist/*",
63
+ "cli.mjs",
64
+ "vite.config.ts",
65
+ "vite.config/*"
66
+ ],
67
+ "type": "module",
68
+ "license": "MIT",
69
+ "repository": "https://github.com/brillout/docpress",
70
+ "publishConfig": {
71
+ "access": "public"
72
+ }
73
+ }
package/readme.md ADDED
@@ -0,0 +1,3 @@
1
+ Doc generator of `https://vite-plugin-ssr.com` and `https://telefunc.com`.
2
+
3
+ Do not use this. Consider this code private-use only (while public-readable).
@@ -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,32 @@
1
+ .doc-page #page-container {
2
+ padding-bottom: 100px;
3
+ }
4
+
5
+ #page-wrapper {
6
+ flex-grow: 1;
7
+ }
8
+
9
+ .doc-page #page-wrapper {
10
+ --main-view-max-width: 800px;
11
+ }
12
+ .landing-page #page-wrapper {
13
+ --main-view-max-width: 1010px;
14
+ }
15
+ #page-wrapper {
16
+ max-width: calc(var(--main-view-max-width) + 80px);
17
+ }
18
+ #page-content {
19
+ box-sizing: content-box;
20
+ max-width: var(--main-view-max-width);
21
+ padding: 20px var(--main-view-padding);
22
+ margin: auto;
23
+ }
24
+
25
+ #page-content {
26
+ --main-view-padding: 20px;
27
+ }
28
+ @media screen and (max-width: 1139px) {
29
+ #page-content {
30
+ --main-view-padding: 10px;
31
+ }
32
+ }
@@ -0,0 +1,43 @@
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
18
+ style={{
19
+ display: 'flex',
20
+ justifyContent: 'center'
21
+ }}
22
+ className={isLandingPage ? 'landing-page' : 'doc-page'}
23
+ >
24
+ <div id="navigation-wrapper">
25
+ <Navigation pageContext={pageContext} />
26
+ </div>
27
+ <NavigationFullscreenButton />
28
+ <div id="page-wrapper">
29
+ <div id="page-container">
30
+ <MobileHeader />
31
+ <div id="page-content">
32
+ {pageTitle && <h1>{pageTitle}</h1>}
33
+ {children}
34
+ {!isLandingPage && <EditPageNote pageContext={pageContext} />}
35
+ </div>
36
+ </div>
37
+ <NavigationMask />
38
+ </div>
39
+ </div>
40
+ </PageContextProvider>
41
+ </React.StrictMode>
42
+ )
43
+ }
@@ -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'
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,19 @@
1
+ import React from 'react'
2
+ import { TextContactUs } from './TextContactUs'
3
+
4
+ export { ContactUs }
5
+
6
+ function ContactUs({ text }: { text: string }) {
7
+ const style: React.CSSProperties = {
8
+ fontSize: '1.5em',
9
+ textAlign: 'center',
10
+ margin: 'auto',
11
+ padding: 'var(--header-padding)',
12
+ maxWidth: 'var(--header-max-width)'
13
+ }
14
+ return (
15
+ <p style={style}>
16
+ {text} <TextContactUs />
17
+ </p>
18
+ )
19
+ }
@@ -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'
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
+ `Link to \`${href}\` has option \`doNotInferSectionTitle\` but \`sectionTitle\` isn't defined.`
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/Emoji'
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'
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
+ import React from 'react'
2
+ import { assert } from '../utils'
3
+
4
+ export { Note }
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
+ }