@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
@@ -0,0 +1,156 @@
1
+ import { assert, jsxToTextContent, objectAssign } from '../utils'
2
+ import { getHeadings, HeadingWithoutLink, parseTitle } from '../headings'
3
+ import type { Heading } from '../headings'
4
+ import type { PageContextBuiltIn } from 'vite-plugin-ssr'
5
+ import type { MarkdownHeading } from '../../vite.config/markdownHeadings'
6
+ import type { Config } from './Config'
7
+ import { getConfig } from './getConfig'
8
+
9
+ export { resolvePageContext }
10
+ export type { PageContextOriginal }
11
+ export type { PageContextResolved }
12
+ export type { Heading }
13
+
14
+ type ReactComponent = () => JSX.Element
15
+ type Exports = {
16
+ headings?: MarkdownHeading[]
17
+ }
18
+ type PageContextOriginal = PageContextBuiltIn & {
19
+ Page: ReactComponent
20
+ exports: Exports
21
+ }
22
+ type PageContextResolved = ReturnType<typeof resolvePageContext>
23
+
24
+ function resolvePageContext(pageContext: PageContextOriginal) {
25
+ const config = getConfig()
26
+ const { headings, headingsWithoutLink } = getHeadings(config)
27
+ const activeHeading = findActiveHeading(headings, headingsWithoutLink, pageContext)
28
+ const headingsWithSubHeadings = getHeadingsWithSubHeadings(headings, pageContext, activeHeading)
29
+ const { title, isLandingPage, pageTitle, isDetachedPage } = getMetaData(
30
+ headingsWithoutLink,
31
+ activeHeading,
32
+ pageContext,
33
+ config
34
+ )
35
+ const { faviconUrl, algolia, tagline, twitterHandle, bannerUrl, websiteUrl } = config
36
+ const pageContextResolved = {}
37
+ objectAssign(pageContextResolved, {
38
+ ...pageContext,
39
+ meta: {
40
+ title,
41
+ faviconUrl,
42
+ twitterHandle, bannerUrl,
43
+ websiteUrl,
44
+ tagline,
45
+ algolia
46
+ },
47
+ headings,
48
+ headingsWithSubHeadings,
49
+ isLandingPage,
50
+ isDetachedPage,
51
+ pageTitle,
52
+ config
53
+ })
54
+ return pageContextResolved
55
+ }
56
+
57
+ function getMetaData(
58
+ headingsWithoutLink: HeadingWithoutLink[],
59
+ activeHeading: Heading | null,
60
+ pageContext: { urlOriginal: string; exports: Exports },
61
+ config: Config
62
+ ) {
63
+ const url = pageContext.urlOriginal
64
+
65
+ let title: string
66
+ let pageTitle: string | JSX.Element | null
67
+ let isDetachedPage: boolean
68
+ if (activeHeading) {
69
+ title = activeHeading.titleDocument || jsxToTextContent(activeHeading.title)
70
+ pageTitle = activeHeading.title
71
+ isDetachedPage = false
72
+ } else {
73
+ pageTitle = headingsWithoutLink.find((h) => h.url === url)!.title
74
+ title = jsxToTextContent(pageTitle)
75
+ isDetachedPage = true
76
+ }
77
+
78
+ const isLandingPage = url === '/'
79
+ if (!isLandingPage) {
80
+ title += ' | ' + config.projectInfo.projectName
81
+ }
82
+
83
+ if (isLandingPage) {
84
+ pageTitle = null
85
+ }
86
+
87
+ return { title, isLandingPage, pageTitle, isDetachedPage }
88
+ }
89
+
90
+ function findActiveHeading(
91
+ headings: Heading[],
92
+ headingsWithoutLink: HeadingWithoutLink[],
93
+ pageContext: { urlOriginal: string; exports: Exports }
94
+ ): Heading | null {
95
+ let activeHeading: Heading | null = null
96
+ assert(pageContext.urlOriginal)
97
+ const pageUrl = pageContext.urlOriginal
98
+ headings.forEach((heading) => {
99
+ if (heading.url === pageUrl) {
100
+ activeHeading = heading
101
+ assert(heading.level === 2, { pageUrl, heading })
102
+ }
103
+ })
104
+ const debugInfo = {
105
+ msg: 'Heading not found for url: ' + pageUrl,
106
+ urls: headings.map((h) => h.url),
107
+ url: pageUrl
108
+ }
109
+ assert(activeHeading || headingsWithoutLink.find(({ url }) => pageUrl === url), debugInfo)
110
+ return activeHeading
111
+ }
112
+
113
+ function getHeadingsWithSubHeadings(
114
+ headings: Heading[],
115
+ pageContext: { exports: Exports; urlOriginal: string },
116
+ activeHeading: Heading | null
117
+ ): Heading[] {
118
+ const headingsWithSubHeadings = headings.slice()
119
+ if (activeHeading === null) return headingsWithSubHeadings
120
+ const activeHeadingIdx = headingsWithSubHeadings.indexOf(activeHeading)
121
+ assert(activeHeadingIdx >= 0)
122
+ const pageHeadings = pageContext.exports.headings || []
123
+ pageHeadings.forEach((pageHeading, i) => {
124
+ const title = parseTitle(pageHeading.title)
125
+ const url = '#' + pageHeading.id
126
+ assert(
127
+ pageHeading.headingLevel !== 3,
128
+ 'Wrong page heading level `' +
129
+ pageHeading.headingLevel +
130
+ '` (it should be `<h2>`) for sub-heading `' +
131
+ pageHeading.title +
132
+ '` of page `' +
133
+ pageContext.urlOriginal +
134
+ '`.'
135
+ )
136
+ if (pageHeading.headingLevel === 2) {
137
+ const heading: Heading = {
138
+ url,
139
+ title,
140
+ parentHeadings: [activeHeading, ...activeHeading.parentHeadings],
141
+ titleInNav: title,
142
+ level: 3
143
+ }
144
+ headingsWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, heading)
145
+ }
146
+ })
147
+
148
+ if (activeHeading?.sectionTitles) {
149
+ activeHeading.sectionTitles.forEach((sectionTitle) => {
150
+ const pageHeadingTitles = pageHeadings.map((h) => h.title)
151
+ assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle })
152
+ })
153
+ }
154
+
155
+ return headingsWithSubHeadings
156
+ }
Binary file
@@ -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
+ }
@@ -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
+ */
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1,25 @@
1
+ .doc-page h2 {
2
+ margin-top: 50px;
3
+ margin-bottom: 16px;
4
+ }
5
+ .doc-page h2[id] {
6
+ cursor: pointer;
7
+ position: relative;
8
+ padding-left: 20px;
9
+ margin-left: -20px;
10
+ }
11
+ .doc-page h2[id]:hover::before {
12
+ content: '#';
13
+ position: absolute;
14
+ left: calc(-1 * (0.75em - 20px));
15
+ color: #aaa;
16
+ }
17
+
18
+ .doc-page h1 + h2 {
19
+ margin-top: 0;
20
+ }
21
+
22
+ .doc-page h4 {
23
+ margin-top: 32px;
24
+ margin-bottom: 16px;
25
+ }
@@ -0,0 +1,10 @@
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 './note.css';
9
+ @import './table.css';
10
+ @import './tooltip.css';
@@ -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
+ }
@@ -0,0 +1,26 @@
1
+ blockquote {
2
+ --color: 0, 0, 0;
3
+ --color-strengh-bg: 0.7;
4
+ --color-strengh-border: 1.5;
5
+ border-left: 8px solid rgba(var(--color), calc(0.06 * var(--color-strengh-border)));
6
+ background-color: rgba(var(--color), calc(0.03 * var(--color-strengh-bg)));
7
+ margin-left: 0;
8
+ padding: 4px 16px;
9
+ }
10
+ blockquote.error {
11
+ --color-strengh-bg: 1.7;
12
+ --color-strengh-border: 6;
13
+ --color: 190, 25, 49;
14
+ }
15
+ blockquote.warning {
16
+ --color-strengh-bg: 4;
17
+ --color-strengh-border: 8;
18
+ --color: 255, 204, 50;
19
+ }
20
+ blockquote > p:first-child::before,
21
+ /* blockquote > p:first-of-type::before, */
22
+ blockquote > div.paragraph:first-child::before {
23
+ font-family: emoji;
24
+ content: 'ℹ️';
25
+ margin-right: 4px;
26
+ }
@@ -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
+ }
@@ -0,0 +1,14 @@
1
+ table th {
2
+ background-color: #f7f7f7;
3
+ }
4
+ table {
5
+ border-collapse: collapse;
6
+ }
7
+ table td,
8
+ table th {
9
+ padding: 8px;
10
+ border: 1px solid #ccc;
11
+ }
12
+ table th {
13
+ text-align: left;
14
+ }
@@ -0,0 +1,11 @@
1
+ @import 'balloon-css';
2
+
3
+ :root {
4
+ --balloon-color: #444;
5
+ --balloon-move: 2px;
6
+ --balloon-font-size: 14px;
7
+ --balloon-border-radius: 5px;
8
+ }
9
+ [aria-label][data-balloon-pos]:after {
10
+ font-family: 'Inter';
11
+ }
@@ -0,0 +1,206 @@
1
+ import React from 'react'
2
+ import { assert } from './utils'
3
+ import { Emoji, EmojiName } from './utils/Emoji'
4
+
5
+ export { getHeadings }
6
+ export { parseTitle }
7
+
8
+ export type Heading = Omit<HeadingDefinition, 'title' | 'titleInNav'> & {
9
+ title: JSX.Element
10
+ titleInNav: JSX.Element
11
+ parentHeadings: Heading[]
12
+ // Not sure why this is needed
13
+ isListTitle?: true
14
+ sectionTitles?: string[]
15
+ }
16
+ export type HeadingWithoutLink = {
17
+ url: string
18
+ title: string | JSX.Element
19
+ }
20
+ export type HeadingDefinition = HeadingBase &
21
+ (
22
+ | ({ level: 1; titleEmoji: EmojiName } & HeadingAbstract)
23
+ | ({ level: 4 } & HeadingAbstract)
24
+ | {
25
+ level: 2
26
+ isListTitle?: true
27
+ sectionTitles?: string[]
28
+ url: string
29
+ }
30
+ | {
31
+ level: 3
32
+ url: string
33
+ }
34
+ )
35
+ type HeadingBase = {
36
+ title: string
37
+ level: number
38
+ url?: string
39
+ titleDocument?: string
40
+ titleInNav?: string
41
+ // titleSize?: string
42
+ }
43
+ type HeadingAbstract = {
44
+ url?: undefined
45
+ titleDocument?: undefined
46
+ titleInNav?: undefined
47
+ }
48
+
49
+ function getHeadings(config: { headings: HeadingDefinition[]; headingsWithoutLink: HeadingWithoutLink[] }): {
50
+ headings: Heading[]
51
+ headingsWithoutLink: HeadingWithoutLink[]
52
+ } {
53
+ const headingsWithoutParent: Omit<Heading, 'parentHeadings'>[] = config.headings.map((heading: HeadingDefinition) => {
54
+ const titleProcessed: JSX.Element = parseTitle(heading.title)
55
+
56
+ const titleInNav = heading.titleInNav || heading.title
57
+ let titleInNavProcessed: JSX.Element
58
+ if ('isListTitle' in heading) {
59
+ assert(heading.isListTitle === true)
60
+ let titleParsed: JSX.Element = parseTitle(titleInNav)
61
+ // if (heading.titleSize) {
62
+ // titleParsed = React.createElement('span', { style: { fontSize: heading.titleSize } }, titleParsed)
63
+ // }
64
+ titleInNavProcessed = React.createElement(React.Fragment, {}, [getListPrefix(), titleParsed])
65
+ } else {
66
+ titleInNavProcessed = parseTitle(titleInNav)
67
+ }
68
+ if ('titleEmoji' in heading) {
69
+ assert(heading.titleEmoji)
70
+ titleInNavProcessed = withEmoji(heading.titleEmoji, titleInNavProcessed)
71
+ }
72
+
73
+ const headingProcessed: Omit<Heading, 'parentHeadings'> = {
74
+ ...heading,
75
+ title: titleProcessed,
76
+ titleInNav: titleInNavProcessed
77
+ }
78
+ return headingProcessed
79
+ })
80
+
81
+ const headings: Heading[] = []
82
+ headingsWithoutParent.forEach((heading) => {
83
+ const parentHeadings = findParentHeadings(heading, headings)
84
+ headings.push({ ...heading, parentHeadings })
85
+ })
86
+
87
+ const headingsWithoutLink = config.headingsWithoutLink.map((headingsWithoutLink) => {
88
+ const { url, title } = headingsWithoutLink
89
+ assert(
90
+ headings.find((heading) => heading.url === url) === undefined,
91
+ `remove ${headingsWithoutLink.url} from headingsWithoutLink`
92
+ )
93
+ const titleProcessed = typeof title === 'string' ? parseTitle(title) : title
94
+ return {
95
+ ...headingsWithoutLink,
96
+ title: titleProcessed
97
+ }
98
+ })
99
+
100
+ assertHeadingsUrl([...headings, ...headingsWithoutLink])
101
+ return { headings, headingsWithoutLink }
102
+ }
103
+
104
+ function findParentHeadings(heading: Omit<Heading, 'parentHeadings'>, headings: Heading[]) {
105
+ const parentHeadings: Heading[] = []
106
+ let levelCurrent = heading.level
107
+ let listTitleParentFound = false
108
+ headings
109
+ .slice()
110
+ .reverse()
111
+ .forEach((parentCandidate) => {
112
+ let isListTitleParent = false
113
+ if (
114
+ !listTitleParentFound &&
115
+ levelCurrent === heading.level &&
116
+ parentCandidate.level === heading.level &&
117
+ !parentCandidate.isListTitle &&
118
+ heading.isListTitle
119
+ ) {
120
+ isListTitleParent = true
121
+ listTitleParentFound = true
122
+ }
123
+
124
+ const isParent = parentCandidate.level < levelCurrent
125
+
126
+ if (isParent || isListTitleParent) {
127
+ levelCurrent = parentCandidate.level
128
+ parentHeadings.push(parentCandidate)
129
+ }
130
+ })
131
+ return parentHeadings
132
+ }
133
+
134
+ function assertHeadingsUrl(headings: { url?: string }[]) {
135
+ const urls: Record<string, true> = {}
136
+ headings.forEach((heading) => {
137
+ if (heading.url) {
138
+ const { url } = heading
139
+ assert(url.startsWith('/'))
140
+ assert(!urls[url], { url })
141
+ urls[url] = true
142
+ }
143
+ })
144
+ }
145
+
146
+ function getListPrefix() {
147
+ const nonBreakingSpace = String.fromCodePoint(0x00a0)
148
+ const bulletPoint = String.fromCodePoint(0x2022)
149
+ return nonBreakingSpace + bulletPoint + nonBreakingSpace
150
+ }
151
+
152
+ function parseTitle(title: string): JSX.Element {
153
+ type Part = { nodeType: 'text' | 'code'; content: string }
154
+ const parts: Part[] = []
155
+ let current: Part | undefined
156
+ title.split('').forEach((letter) => {
157
+ if (letter === '`') {
158
+ if (current?.nodeType === 'code') {
159
+ // </code>
160
+ parts.push(current)
161
+ current = undefined
162
+ } else {
163
+ // <code>
164
+ if (current) {
165
+ parts.push(current)
166
+ }
167
+ current = { nodeType: 'code', content: '' }
168
+ }
169
+ } else {
170
+ if (!current) {
171
+ current = { nodeType: 'text', content: '' }
172
+ }
173
+ current.content += letter
174
+ }
175
+ })
176
+ if (current) {
177
+ parts.push(current)
178
+ }
179
+
180
+ const titleJsx = React.createElement(
181
+ React.Fragment,
182
+ {},
183
+ ...parts.map((part) => {
184
+ if (part.nodeType === 'code') {
185
+ return React.createElement('code', {}, part.content)
186
+ } else {
187
+ assert(part.nodeType === 'text')
188
+ return part.content
189
+ }
190
+ })
191
+ )
192
+
193
+ return titleJsx
194
+ }
195
+
196
+ function withEmoji(name: EmojiName, title: string | JSX.Element): JSX.Element {
197
+ const style = { fontSize: '1.4em' }
198
+ //return React.createElement(React.Fragment, null, Emoji({ name, style }), ' ', title)
199
+ return React.createElement(
200
+ 'span',
201
+ { style },
202
+ Emoji({ name }),
203
+ ' ',
204
+ React.createElement('span', { style: { fontSize: '1rem' } }, title)
205
+ )
206
+ }
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="17.284" height="17.284" version="1.1" viewBox="0 0 17.284 17.284" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><defs><clipPath id="clipPath1075"><path d="m789.58 466.67h62.5v62.5h-62.5z" clip-rule="evenodd"/></clipPath></defs><g fill="#323d48" transform="matrix(.33185 0 0 .33185 -263.75 -156.59)" clip-path="url(#clipPath1075)"><g transform="matrix(2.6042,0,0,2.6042,789.58,466.67)"><path d="m12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10-10-4.477-10-10h2c0 4.418 3.582 8 8 8s8-3.582 8-8-3.582-8-8-8c-2.464 0-4.668 1.114-6.135 2.865l2.135 2.135h-6v-6l2.447 2.446c1.833-2.11 4.537-3.446 7.553-3.446zm1 5v4.585l3.243 3.243-1.415 1.415-3.828-3.83v-5.413z"/></g></g></svg>
@@ -0,0 +1,10 @@
1
+ <svg width="71" height="55" viewBox="0 0 71 55" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0)">
3
+ <path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#5865F2"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0">
7
+ <rect width="71" height="55" fill="white"/>
8
+ </clipPath>
9
+ </defs>
10
+ </svg>