@brillout/docpress 0.6.21 → 0.7.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.
Files changed (110) hide show
  1. package/+config.ts +26 -3
  2. package/MobileHeader.tsx +5 -3
  3. package/PageLayout.tsx +28 -19
  4. package/algolia/DocSearch.css +6 -9
  5. package/autoScrollNav.ts +4 -3
  6. package/components/FeatureList/FeatureList.client.ts +6 -11
  7. package/components/Link.tsx +9 -9
  8. package/config/getConfig.ts +2 -1
  9. package/config/resolveHeadingsData.ts +22 -38
  10. package/config/resolvePageContext.ts +4 -6
  11. package/dist/+config.d.ts +25 -3
  12. package/dist/+config.js +7 -3
  13. package/dist/components/CodeBlockTransformer.d.ts +7 -0
  14. package/dist/components/CodeBlockTransformer.js +9 -0
  15. package/dist/components/Comment.d.ts +5 -0
  16. package/dist/components/Comment.js +6 -0
  17. package/dist/components/Consulting.d.ts +4 -0
  18. package/dist/components/Consulting.js +39 -0
  19. package/dist/components/Contributors.d.ts +7 -0
  20. package/dist/components/Contributors.js +74 -0
  21. package/dist/components/FileRemoved.d.ts +9 -0
  22. package/dist/components/FileRemoved.js +28 -0
  23. package/dist/components/HorizontalLine.d.ts +5 -0
  24. package/dist/components/HorizontalLine.js +15 -0
  25. package/dist/components/ImportMeta.d.ts +5 -0
  26. package/dist/components/ImportMeta.js +10 -0
  27. package/dist/components/Link.d.ts +16 -0
  28. package/dist/components/Link.js +108 -0
  29. package/dist/components/Note.d.ts +22 -0
  30. package/dist/components/Note.js +93 -0
  31. package/dist/components/P.d.ts +4 -0
  32. package/dist/components/P.js +17 -0
  33. package/dist/components/ReadingRecommendation.d.ts +6 -0
  34. package/dist/components/ReadingRecommendation.js +40 -0
  35. package/dist/components/RepoLink.d.ts +9 -0
  36. package/dist/components/RepoLink.js +22 -0
  37. package/dist/components/Sponsors.d.ts +22 -0
  38. package/dist/components/Sponsors.js +161 -0
  39. package/dist/components/Supporters.d.ts +32 -0
  40. package/dist/components/Supporters.js +80 -0
  41. package/dist/components/index.d.ts +15 -0
  42. package/dist/components/index.js +15 -0
  43. package/dist/config/getConfig.d.ts +3 -0
  44. package/dist/config/getConfig.js +14 -0
  45. package/dist/config/resolveHeadingsData.d.ts +16 -0
  46. package/dist/config/resolveHeadingsData.js +216 -0
  47. package/dist/config/resolvePageContext.d.ts +38 -0
  48. package/dist/config/resolvePageContext.js +23 -0
  49. package/dist/data/maintainersList.d.ts +9 -0
  50. package/dist/data/maintainersList.js +83 -0
  51. package/dist/data/sponsorsList.d.ts +3 -0
  52. package/dist/data/sponsorsList.js +151 -0
  53. package/dist/navigation/Navigation.d.ts +20 -0
  54. package/dist/navigation/Navigation.js +134 -0
  55. package/dist/navigation/NavigationHeader.d.ts +4 -0
  56. package/dist/navigation/NavigationHeader.js +85 -0
  57. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +6 -0
  58. package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +22 -0
  59. package/dist/parsePageSections.js +7 -3
  60. package/dist/parseTitle.d.ts +5 -0
  61. package/dist/parseTitle.js +52 -0
  62. package/dist/renderer/usePageContext.d.ts +17 -0
  63. package/dist/renderer/usePageContext.js +26 -0
  64. package/dist/types/Config.d.ts +30 -0
  65. package/dist/types/Config.js +1 -0
  66. package/dist/types/Heading.d.ts +43 -0
  67. package/dist/types/Heading.js +1 -0
  68. package/dist/utils/Emoji/Emoji.d.ts +8 -0
  69. package/dist/utils/Emoji/Emoji.js +191 -0
  70. package/dist/utils/Emoji/assets.d.ts +6 -0
  71. package/dist/utils/Emoji/assets.js +7 -0
  72. package/dist/utils/Emoji/index.d.ts +1 -0
  73. package/dist/utils/Emoji/index.js +1 -0
  74. package/dist/utils/assert.js +43 -8
  75. package/dist/utils/client.d.ts +2 -0
  76. package/dist/utils/client.js +2 -0
  77. package/dist/utils/filter.d.ts +2 -0
  78. package/dist/utils/filter.js +11 -0
  79. package/dist/utils/isBrowser.d.ts +2 -0
  80. package/dist/utils/isBrowser.js +4 -0
  81. package/dist/utils/jsxToTextContent.d.ts +2 -0
  82. package/dist/utils/jsxToTextContent.js +12 -0
  83. package/dist/utils/objectAssign.d.ts +2 -0
  84. package/dist/utils/objectAssign.js +5 -0
  85. package/dist/utils/server.d.ts +7 -0
  86. package/dist/utils/server.js +7 -0
  87. package/dist/vite.config.js +5 -3
  88. package/installSectionUrlHashs.ts +7 -13
  89. package/navigation/Navigation.tsx +28 -19
  90. package/navigation/NavigationHeader.tsx +33 -4
  91. package/navigation/initMobileNavigation.ts +2 -11
  92. package/navigation/initPressKit.ts +5 -2
  93. package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +12 -5
  94. package/package.json +21 -15
  95. package/parsePageSections.ts +6 -1
  96. package/renderer/getPageElement.tsx +16 -0
  97. package/renderer/onBeforeRender.ts +12 -0
  98. package/renderer/onRenderClient.tsx +90 -0
  99. package/renderer/onRenderHtml.tsx +10 -22
  100. package/renderer/usePageContext.tsx +20 -0
  101. package/tsconfig.config.json +1 -1
  102. package/tsconfig.json +1 -1
  103. package/types/Config.ts +6 -20
  104. package/types/Heading.ts +5 -5
  105. package/utils/assert.ts +44 -8
  106. package/utils/jsxToTextContent.ts +1 -1
  107. package/vite.config.ts +5 -3
  108. package/algolia/DocSearch.ts +0 -62
  109. package/navigation/Navigation.client.ts +0 -7
  110. package/renderer/client.ts +0 -4
package/+config.ts CHANGED
@@ -1,13 +1,36 @@
1
1
  import type { Config } from 'vike/types'
2
+ import type { Exports } from './config/resolvePageContext'
2
3
 
3
4
  export default {
4
5
  // @ts-ignore Remove this ts-ignore once Vike's new version is released.
5
6
  name: '@brillout/docpress',
6
7
  onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
7
- client: 'import:@brillout/docpress/renderer/client:doesNotExist',
8
+ onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
9
+ onBeforeRender: 'import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender',
10
+ clientRouting: true,
11
+ hydrationCanBeAborted: true,
12
+ passToClient: ['pageContextResolved'],
8
13
  meta: {
9
- Page: {
10
- env: { client: false, server: true },
14
+ NavHeader: {
15
+ env: { client: true, server: true },
11
16
  },
12
17
  },
13
18
  } satisfies Config
19
+
20
+ type ReactComponent = () => JSX.Element
21
+ declare global {
22
+ namespace Vike {
23
+ interface PageContext {
24
+ Page: ReactComponent
25
+ exports: Exports
26
+ }
27
+ interface Config {
28
+ NavHeader?: {
29
+ NavHeader: ReactComponent
30
+ navHeaderWrapperStyle?: React.CSSProperties
31
+ NavHeaderMobile: ReactComponent
32
+ navHeaderMobileWrapperStyle?: React.CSSProperties
33
+ }
34
+ }
35
+ }
36
+ }
package/MobileHeader.tsx CHANGED
@@ -1,10 +1,12 @@
1
1
  import React from 'react'
2
- import { usePageContext } from './renderer/usePageContext'
2
+ import { usePageContext, usePageContext2 } from './renderer/usePageContext'
3
3
 
4
4
  export { MobileHeader }
5
5
 
6
6
  function MobileHeader() {
7
7
  const pageContext = usePageContext()
8
+ const pageContext2 = usePageContext2()
9
+ const { NavHeaderMobile } = pageContext2.config.NavHeader!
8
10
  return (
9
11
  <div
10
12
  id="mobile-header"
@@ -37,10 +39,10 @@ function MobileHeader() {
37
39
  alignItems: 'center',
38
40
  justifyContent: 'left',
39
41
  textDecoration: 'none',
40
- ...pageContext.config.navHeaderMobileWrapperStyle,
42
+ ...pageContext2.config.NavHeader?.navHeaderMobileWrapperStyle,
41
43
  }}
42
44
  >
43
- {pageContext.config.navHeaderMobile}
45
+ <NavHeaderMobile />
44
46
  </a>
45
47
  </div>
46
48
  </div>
package/PageLayout.tsx CHANGED
@@ -3,37 +3,46 @@ import { Navigation, NavigationMask } from './navigation/Navigation'
3
3
  import type { PageContextResolved } from './config/resolvePageContext'
4
4
  import { MobileHeader } from './MobileHeader'
5
5
  import { EditPageNote } from './components/EditPageNote'
6
- import { PageContextProvider } from './renderer/usePageContext'
6
+ import { PageContextProvider, PageContextProvider2 } from './renderer/usePageContext'
7
7
  import './PageLayout.css'
8
8
  import { NavigationFullscreenButton } from './navigation/navigation-fullscreen/NavigationFullscreenButton'
9
+ import type { PageContext } from 'vike/types'
10
+ import { parseTitle } from './parseTitle'
9
11
 
10
12
  export { PageLayout }
11
13
 
12
- function PageLayout({ pageContext, children }: { pageContext: PageContextResolved; children: React.ReactNode }) {
14
+ function PageLayout({
15
+ pageContext,
16
+ children,
17
+ pageContext2,
18
+ }: { pageContext: PageContextResolved; children: React.ReactNode; pageContext2: PageContext }) {
13
19
  const { isLandingPage, pageTitle, navigationData } = pageContext
20
+ const pageTitleParsed = pageTitle && parseTitle(pageTitle)
14
21
  const { globalNote } = pageContext.config
15
22
  return (
16
23
  <React.StrictMode>
17
- <PageContextProvider pageContext={pageContext}>
18
- <div className={`page-layout ${isLandingPage ? 'landing-page' : 'doc-page'}`}>
19
- <div id="navigation-wrapper">
20
- <Navigation {...pageContext.navigationData} />
21
- </div>
22
- <NavigationFullscreenButton />
23
- <div className="page-wrapper">
24
- <div className="page-container">
25
- <MobileHeader />
26
- <div className="page-content">
27
- {globalNote}
28
- {pageTitle && <h1 id={`${navigationData.currentUrl.replace('/', '')}`}>{pageTitle}</h1>}
29
- {children}
30
- {!isLandingPage && <EditPageNote pageContext={pageContext} />}
24
+ <PageContextProvider2 pageContext={pageContext2}>
25
+ <PageContextProvider pageContext={pageContext}>
26
+ <div className={`page-layout ${isLandingPage ? 'landing-page' : 'doc-page'}`}>
27
+ <div id="navigation-wrapper">
28
+ <Navigation {...pageContext.navigationData} />
29
+ </div>
30
+ <NavigationFullscreenButton />
31
+ <div className="page-wrapper">
32
+ <div className="page-container">
33
+ <MobileHeader />
34
+ <div className="page-content">
35
+ {globalNote}
36
+ {pageTitleParsed && <h1 id={`${navigationData.currentUrl.replace('/', '')}`}>{pageTitleParsed}</h1>}
37
+ {children}
38
+ {!isLandingPage && <EditPageNote pageContext={pageContext} />}
39
+ </div>
31
40
  </div>
41
+ <NavigationMask />
32
42
  </div>
33
- <NavigationMask />
34
43
  </div>
35
- </div>
36
- </PageContextProvider>
44
+ </PageContextProvider>
45
+ </PageContextProvider2>
37
46
  </React.StrictMode>
38
47
  )
39
48
  }
@@ -8,14 +8,11 @@
8
8
  padding-right: 6px !important;
9
9
  }
10
10
 
11
- #docsearch-desktop {
12
- max-width: 110px !important;
13
- }
14
- #docsearch-desktop .DocSearch-Button-Placeholder,
15
- #docsearch-desktop .DocSearch-Button-Keys {
16
- display: none;
11
+ .DocSearch-Button-Placeholder,
12
+ .DocSearch-Button-Keys {
13
+ display: none !important;
17
14
  }
18
- #docsearch-desktop .DocSearch-Button {
15
+ .DocSearch-Button {
19
16
  background: transparent !important;
20
17
  padding: 0 !important;
21
18
  position: relative;
@@ -24,11 +21,11 @@
24
21
  border: none !important;
25
22
  box-shadow: none !important;
26
23
  }
27
- #docsearch-desktop .DocSearch-Search-Icon {
24
+ .DocSearch-Search-Icon {
28
25
  height: 21px !important;
29
26
  width: 21px !important;
30
27
  }
31
- #docsearch-desktop .DocSearch-Button {
28
+ .DocSearch-Button {
32
29
  margin-right: 3px !important;
33
30
  margin-left: 1px !important;
34
31
  }
package/autoScrollNav.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { assert } from './utils/client'
1
+ export { autoScrollNav }
2
2
 
3
- autoScrollNav()
3
+ import { assert } from './utils/client'
4
4
 
5
5
  function autoScrollNav() {
6
6
  const navigationEl = document.getElementById('navigation-content-main')
@@ -31,6 +31,7 @@ function autoScrollNav() {
31
31
  block: 'center',
32
32
  inline: 'start',
33
33
  })
34
- // Avoid scrollIntoView() from scrolling the main view. Alternatively, we could use scrollIntoViewIfNeeded() (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded) which doesn't scroll the main view but Firefox doesn't support it.
34
+ // Avoid scrollIntoView() from scrolling the main view.
35
+ // - Alternatively scrollIntoViewIfNeeded() (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded) would work (it doesn't scroll the main view) but Firefox doesn't support it.
35
36
  document.documentElement.scrollTop = scrollTopOriginal
36
37
  }
@@ -1,17 +1,16 @@
1
- import { assert } from '../../utils/client'
1
+ export { addTwitterWidgets }
2
+ export { addFeatureClickHandlers }
2
3
 
3
- addTwitterWidgets()
4
- addFeatureClickHandlers()
5
- window.__docpress_hydrationFinished = true
4
+ import { assert } from '../../utils/client'
6
5
 
7
6
  function addTwitterWidgets() {
8
7
  loadScript('https://platform.twitter.com/widgets.js')
9
8
  }
10
9
 
11
10
  function addFeatureClickHandlers() {
12
- const featureEls: HTMLElement[] = Array.from(
13
- document.getElementById('features')!.querySelectorAll('.feature.has-learn-more'),
14
- )
11
+ const featuresEl = document.getElementById('features')
12
+ if (!featuresEl) return
13
+ const featureEls: HTMLElement[] = Array.from(featuresEl.querySelectorAll('.feature.has-learn-more'))
15
14
  featureEls.forEach((featureEl) => {
16
15
  featureEl.onclick = () => {
17
16
  expandLearnMore(featureEl)
@@ -59,7 +58,3 @@ function loadScript(scriptUrl: string): void {
59
58
  function getComputedStyle(el: HTMLElement, styleProp: string) {
60
59
  return window.document.defaultView!.getComputedStyle(el).getPropertyValue(styleProp)
61
60
  }
62
-
63
- declare global {
64
- var __docpress_hydrationFinished: undefined | true
65
- }
@@ -48,25 +48,25 @@ function getLinkText({
48
48
  noBreadcrumb: true | undefined
49
49
  pageContext: PageContextResolved
50
50
  doNotInferSectionTitle: true | undefined
51
- }): string | JSX.Element {
51
+ }): JSX.Element {
52
52
  const { hrefPathname, hrefHash } = parseHref(href)
53
53
 
54
54
  const linkData = findLinkData(hrefPathname || pageContext.urlPathname, pageContext)
55
55
  const isLinkOnSamePage = linkData.url === pageContext.urlPathname
56
56
  if (!hrefPathname) assert(isLinkOnSamePage)
57
57
 
58
- const breadcrumbParts: (string | JSX.Element)[] = []
58
+ const breadcrumbParts: JSX.Element[] = []
59
59
  if (linkData.linkBreadcrumb) {
60
- breadcrumbParts.push(...(linkData.linkBreadcrumb ?? []).slice().reverse())
60
+ breadcrumbParts.push(...(linkData.linkBreadcrumb ?? []).slice().reverse().map(parseTitle))
61
61
  }
62
- breadcrumbParts.push(linkData.title)
62
+ breadcrumbParts.push(parseTitle(linkData.title))
63
63
 
64
64
  if (hrefHash) {
65
- let sectionTitle: string | JSX.Element | undefined = undefined
65
+ let sectionTitle: JSX.Element | undefined = undefined
66
66
  assert(!hrefHash.startsWith('#'))
67
67
  if (isLinkOnSamePage) {
68
68
  const linkDataPageSection = findLinkData(`#${hrefHash}`, pageContext)
69
- sectionTitle = linkDataPageSection.title
69
+ sectionTitle = parseTitle(linkDataPageSection.title)
70
70
  } else if ('sectionTitles' in linkData && linkData.sectionTitles) {
71
71
  linkData.sectionTitles.forEach((title) => {
72
72
  if (determineSectionUrlHash(title) === hrefHash) {
@@ -79,7 +79,7 @@ function getLinkText({
79
79
  !doNotInferSectionTitle,
80
80
  `Page section title not found for <Link href="\`${href}\`" doNotInferSectionTitle={true} />.`,
81
81
  )
82
- sectionTitle = determineSectionTitle(href)
82
+ sectionTitle = <>{determineSectionTitle(href)}</>
83
83
  }
84
84
  breadcrumbParts.push(sectionTitle)
85
85
  }
@@ -107,8 +107,8 @@ function getLinkText({
107
107
 
108
108
  type LinkData = {
109
109
  url?: null | string
110
- title: JSX.Element
111
- linkBreadcrumb: null | JSX.Element[]
110
+ title: string
111
+ linkBreadcrumb: null | string[]
112
112
  sectionTitles?: string[]
113
113
  }
114
114
 
@@ -12,7 +12,8 @@ function getConfig(): Config {
12
12
  files.length === 1,
13
13
  `Found multiple \`docpress.config.js\` files: ${files.map((f) => `\`${f}\``).join(', ')}. Define only one instead.`,
14
14
  )
15
- const config = (Object.values(globResult)[0] as any).default as Config
15
+ const exports: any = Object.values(globResult)[0]
16
+ const config: Config = exports.default || exports.config
16
17
  assert(config)
17
18
  return config
18
19
  }
@@ -9,17 +9,17 @@ import type {
9
9
  } from '../types/Heading'
10
10
  import type { Config } from '../types/Config'
11
11
  import { getConfig } from './getConfig'
12
- import { parseTitle, withEmoji } from '../parseTitle'
13
12
  import { NavigationData, NavItem } from '../navigation/Navigation'
14
13
  import type { LinkData } from '../components'
15
14
  import type { Exports, PageContextOriginal } from './resolvePageContext'
16
15
  import pc from '@brillout/picocolors'
16
+ import { parseTitle } from '../parseTitle'
17
17
 
18
18
  type PageSectionResolved = {
19
19
  url: string | null
20
- title: JSX.Element
21
- titleInNav: JSX.Element
22
- linkBreadcrumb: JSX.Element[]
20
+ title: string
21
+ titleInNav: string
22
+ linkBreadcrumb: string[]
23
23
  pageSectionLevel: number
24
24
  }
25
25
 
@@ -123,15 +123,15 @@ function pageSectionToLinkData(pageSection: PageSectionResolved): LinkData {
123
123
 
124
124
  function getTitles(
125
125
  activeHeading: HeadingResolved | HeadingDetachedResolved,
126
- pageContext: { urlOriginal: string },
126
+ pageContext: { urlPathname: string },
127
127
  config: Config,
128
128
  ) {
129
- const url = pageContext.urlOriginal
129
+ const url = pageContext.urlPathname
130
130
  const isLandingPage = url === '/'
131
131
 
132
132
  const { title } = activeHeading
133
133
  let pageTitle = isLandingPage ? null : title
134
- let documentTitle = activeHeading.titleDocument || jsxToTextContent(title)
134
+ let documentTitle = activeHeading.titleDocument || jsxToTextContent(parseTitle(title))
135
135
 
136
136
  if (!isLandingPage) {
137
137
  documentTitle += ' | ' + config.projectInfo.projectName
@@ -147,25 +147,25 @@ function getTitles(
147
147
  function getActiveHeading(
148
148
  headingsResolved: HeadingResolved[],
149
149
  headingsDetachedResolved: HeadingDetachedResolved[],
150
- pageContext: { urlOriginal: string; exports: Exports },
150
+ pageContext: { urlPathname: string; exports: Exports },
151
151
  ) {
152
152
  let activeHeading: HeadingResolved | HeadingDetachedResolved | null = null
153
- const { urlOriginal } = pageContext
154
- assert(urlOriginal)
153
+ const { urlPathname } = pageContext
154
+ assert(urlPathname)
155
155
  headingsResolved.forEach((heading) => {
156
- if (heading.url === urlOriginal) {
156
+ if (heading.url === urlPathname) {
157
157
  activeHeading = heading
158
- assert(heading.level === 2, { pageUrl: urlOriginal, heading })
158
+ assert(heading.level === 2, { pageUrl: urlPathname, heading })
159
159
  }
160
160
  })
161
161
  const isDetachedPage = !activeHeading
162
162
  if (!activeHeading) {
163
- activeHeading = headingsDetachedResolved.find(({ url }) => urlOriginal === url) ?? null
163
+ activeHeading = headingsDetachedResolved.find(({ url }) => urlPathname === url) ?? null
164
164
  }
165
165
  if (!activeHeading) {
166
166
  throw new Error(
167
167
  [
168
- `URL ${pc.bold(urlOriginal)} not found in following URLs:`,
168
+ `URL ${pc.bold(urlPathname)} not found in following URLs:`,
169
169
  ...headingsResolved
170
170
  .map((h) => ` ${h.url}`)
171
171
  .filter(Boolean)
@@ -177,19 +177,19 @@ function getActiveHeading(
177
177
  }
178
178
 
179
179
  function getPageSectionsResolved(
180
- pageContext: { exports: Exports; urlOriginal: string },
180
+ pageContext: { exports: Exports },
181
181
  activeHeading: HeadingResolved | HeadingDetachedResolved,
182
182
  ): PageSectionResolved[] {
183
183
  const pageSections = pageContext.exports.pageSectionsExport ?? []
184
184
 
185
185
  const pageSectionsResolved = pageSections.map((pageSection) => {
186
- const pageSectionTitleJsx = parseTitle(pageSection.pageSectionTitle)
186
+ const { pageSectionTitle } = pageSection
187
187
  const url: null | string = pageSection.pageSectionId === null ? null : '#' + pageSection.pageSectionId
188
188
  const pageSectionResolved: PageSectionResolved = {
189
189
  url,
190
- title: pageSectionTitleJsx,
190
+ title: pageSectionTitle,
191
191
  linkBreadcrumb: [activeHeading.title, ...(activeHeading.linkBreadcrumb ?? [])],
192
- titleInNav: pageSectionTitleJsx,
192
+ titleInNav: pageSectionTitle,
193
193
  pageSectionLevel: pageSection.pageSectionLevel,
194
194
  }
195
195
  return pageSectionResolved
@@ -205,10 +205,6 @@ function getPageSectionsResolved(
205
205
  return pageSectionsResolved
206
206
  }
207
207
 
208
- /**
209
- * - Parse title (from `string` to `JSX.Element`)
210
- * - Determine navigation breadcrumbs
211
- */
212
208
  function getHeadingsResolved(config: {
213
209
  headings: HeadingDefinition[]
214
210
  headingsDetached: HeadingDetachedDefinition[]
@@ -218,20 +214,10 @@ function getHeadingsResolved(config: {
218
214
  } {
219
215
  const headingsWithoutBreadcrumb: Omit<HeadingResolved, 'linkBreadcrumb'>[] = config.headings.map(
220
216
  (heading: HeadingDefinition) => {
221
- const titleParsed: JSX.Element = parseTitle(heading.title)
222
-
223
217
  const titleInNav = heading.titleInNav || heading.title
224
- let titleInNavParsed: JSX.Element
225
- titleInNavParsed = parseTitle(titleInNav)
226
- if ('titleEmoji' in heading) {
227
- assert(heading.titleEmoji)
228
- titleInNavParsed = withEmoji(heading.titleEmoji, titleInNavParsed)
229
- }
230
-
231
218
  const headingResolved: Omit<HeadingResolved, 'linkBreadcrumb'> = {
232
219
  ...heading,
233
- title: titleParsed,
234
- titleInNav: titleInNavParsed,
220
+ titleInNav,
235
221
  }
236
222
  return headingResolved
237
223
  },
@@ -247,17 +233,15 @@ function getHeadingsResolved(config: {
247
233
  })
248
234
 
249
235
  const headingsDetachedResolved = config.headingsDetached.map((headingsDetached) => {
250
- const { url, title } = headingsDetached
236
+ const { url } = headingsDetached
251
237
  assert(
252
238
  headingsResolved.find((heading) => heading.url === url) === undefined,
253
239
  `remove ${headingsDetached.url} from headingsDetached`,
254
240
  )
255
- const titleParsed = typeof title === 'string' ? parseTitle(title) : title
256
241
  return {
257
242
  ...headingsDetached,
258
243
  level: 2 as const,
259
- title: titleParsed,
260
- titleInNav: titleParsed,
244
+ titleInNav: headingsDetached.title,
261
245
  linkBreadcrumb: null,
262
246
  }
263
247
  })
@@ -266,7 +250,7 @@ function getHeadingsResolved(config: {
266
250
  }
267
251
 
268
252
  function getHeadingsBreadcrumb(heading: Omit<HeadingResolved, 'linkBreadcrumb'>, headings: HeadingResolved[]) {
269
- const linkBreadcrumb: JSX.Element[] = []
253
+ const linkBreadcrumb: string[] = []
270
254
  let levelCurrent = heading.level
271
255
  headings
272
256
  .slice()
@@ -9,14 +9,12 @@ import type { PageSection } from '../parsePageSections'
9
9
  import { getConfig } from './getConfig'
10
10
  import { resolveHeadingsData } from './resolveHeadingsData'
11
11
 
12
- type ReactComponent = () => JSX.Element
13
12
  type Exports = {
14
13
  pageSectionsExport?: PageSection[]
15
14
  }
16
- type PageContextOriginal = PageContextServer & {
17
- Page: ReactComponent
18
- exports: Exports
19
- }
15
+ // TODO/refactor: remove PageContextOriginal in favor of using PageContextServer
16
+ type PageContextOriginal = PageContextServer
17
+
20
18
  type PageContextResolved = ReturnType<typeof resolvePageContext>
21
19
 
22
20
  function resolvePageContext(pageContext: PageContextOriginal) {
@@ -27,7 +25,7 @@ function resolvePageContext(pageContext: PageContextOriginal) {
27
25
  const config = getConfig()
28
26
  const { faviconUrl, algolia, tagline, twitterHandle, bannerUrl, websiteUrl } = config
29
27
  objectAssign(pageContextResolved, {
30
- ...pageContext,
28
+ urlPathname: pageContext.urlPathname, // TODO: remove
31
29
  meta: {
32
30
  faviconUrl,
33
31
  twitterHandle,
package/dist/+config.d.ts CHANGED
@@ -1,14 +1,36 @@
1
+ import type { Exports } from './config/resolvePageContext';
1
2
  declare const _default: {
2
3
  name: string;
3
4
  onRenderHtml: "import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml";
4
- client: string;
5
+ onRenderClient: "import:@brillout/docpress/renderer/onRenderClient:onRenderClient";
6
+ onBeforeRender: "import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender";
7
+ clientRouting: true;
8
+ hydrationCanBeAborted: true;
9
+ passToClient: string[];
5
10
  meta: {
6
- Page: {
11
+ NavHeader: {
7
12
  env: {
8
- client: false;
13
+ client: true;
9
14
  server: true;
10
15
  };
11
16
  };
12
17
  };
13
18
  };
14
19
  export default _default;
20
+ type ReactComponent = () => JSX.Element;
21
+ declare global {
22
+ namespace Vike {
23
+ interface PageContext {
24
+ Page: ReactComponent;
25
+ exports: Exports;
26
+ }
27
+ interface Config {
28
+ NavHeader?: {
29
+ NavHeader: ReactComponent;
30
+ navHeaderWrapperStyle?: React.CSSProperties;
31
+ NavHeaderMobile: ReactComponent;
32
+ navHeaderMobileWrapperStyle?: React.CSSProperties;
33
+ };
34
+ }
35
+ }
36
+ }
package/dist/+config.js CHANGED
@@ -2,10 +2,14 @@ export default {
2
2
  // @ts-ignore Remove this ts-ignore once Vike's new version is released.
3
3
  name: '@brillout/docpress',
4
4
  onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
5
- client: 'import:@brillout/docpress/renderer/client:doesNotExist',
5
+ onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
6
+ onBeforeRender: 'import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender',
7
+ clientRouting: true,
8
+ hydrationCanBeAborted: true,
9
+ passToClient: ['pageContextResolved'],
6
10
  meta: {
7
- Page: {
8
- env: { client: false, server: true },
11
+ NavHeader: {
12
+ env: { client: true, server: true },
9
13
  },
10
14
  },
11
15
  };
@@ -0,0 +1,7 @@
1
+ export { CodeBlockTransformer };
2
+ import React from 'react';
3
+ type LineBreak = 'white-space' | 'break-word';
4
+ declare function CodeBlockTransformer({ children, lineBreak }: {
5
+ children: React.ReactNode;
6
+ lineBreak: LineBreak;
7
+ }): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ export { CodeBlockTransformer };
2
+ import React from 'react';
3
+ import { assert } from '../utils/server';
4
+ function CodeBlockTransformer(_a) {
5
+ var children = _a.children, lineBreak = _a.lineBreak;
6
+ assert(lineBreak === 'white-space' || lineBreak === 'break-word', '`lineBreak` is currently the only use case for <CodeBlockTransformer>');
7
+ var className = "with-line-break_".concat(lineBreak);
8
+ return React.createElement("div", { className: className }, children);
9
+ }
@@ -0,0 +1,5 @@
1
+ export { Comment };
2
+ import React from 'react';
3
+ declare function Comment({ children }: {
4
+ children: React.ReactNode;
5
+ }): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ export { Comment };
2
+ import React from 'react';
3
+ function Comment(_a) {
4
+ var children = _a.children;
5
+ return React.createElement(React.Fragment, null);
6
+ }
@@ -0,0 +1,4 @@
1
+ export { Consulting, Consultants };
2
+ import React from 'react';
3
+ declare function Consulting(): React.JSX.Element;
4
+ declare function Consultants(): React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ export { Consulting, Consultants };
2
+ import React from 'react';
3
+ import iconPeople from '../icons/people.svg';
4
+ import { usePageContext } from '../renderer/usePageContext';
5
+ import { SupporterSection, SectionDescription, CallToAction } from './Supporters';
6
+ import { Maintainer } from './Contributors';
7
+ import { maintainers } from '../data/maintainersList';
8
+ import { Link } from './Link';
9
+ var consultingPageHref = '/consulting';
10
+ function Consulting() {
11
+ var pageContext = usePageContext();
12
+ var projectInfo = pageContext.config.projectInfo;
13
+ var projectName = projectInfo.projectName;
14
+ return (React.createElement(SupporterSection, null,
15
+ React.createElement(CallToAction, { iconUrl: iconPeople, text: "Consulting", href: consultingPageHref }),
16
+ React.createElement("div", null),
17
+ React.createElement(SectionDescription, null,
18
+ "For questions and issues related to ",
19
+ projectName,
20
+ ", open a",
21
+ ' ',
22
+ React.createElement("a", { href: projectInfo.githubDiscussions || projectInfo.githubIssues }, "GitHub Discussion"),
23
+ ". For advanced help or help not directly related to ",
24
+ projectName,
25
+ ", the ",
26
+ projectName,
27
+ " team offers",
28
+ ' ',
29
+ React.createElement(Link, { href: consultingPageHref, noBreadcrumb: true }, "consulting"),
30
+ ".")));
31
+ }
32
+ function Consultants() {
33
+ return (React.createElement(SupporterSection, null,
34
+ React.createElement("div", { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'end' } }, maintainers
35
+ .filter(function (maintainer) {
36
+ return !!maintainer.consultingUrl;
37
+ })
38
+ .map(function (maintainer, i) { return (React.createElement(Maintainer, { maintainer: maintainer, key: i })); }))));
39
+ }
@@ -0,0 +1,7 @@
1
+ export { Contributors, Maintainer };
2
+ import React from 'react';
3
+ import { maintainers } from '../data/maintainersList';
4
+ declare function Contributors(): React.JSX.Element;
5
+ declare function Maintainer({ maintainer }: {
6
+ maintainer: (typeof maintainers)[0];
7
+ }): React.JSX.Element;