@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.
- package/+config.ts +26 -3
- package/MobileHeader.tsx +5 -3
- package/PageLayout.tsx +28 -19
- package/algolia/DocSearch.css +6 -9
- package/autoScrollNav.ts +4 -3
- package/components/FeatureList/FeatureList.client.ts +6 -11
- package/components/Link.tsx +9 -9
- package/config/getConfig.ts +2 -1
- package/config/resolveHeadingsData.ts +22 -38
- package/config/resolvePageContext.ts +4 -6
- package/dist/+config.d.ts +25 -3
- package/dist/+config.js +7 -3
- package/dist/components/CodeBlockTransformer.d.ts +7 -0
- package/dist/components/CodeBlockTransformer.js +9 -0
- package/dist/components/Comment.d.ts +5 -0
- package/dist/components/Comment.js +6 -0
- package/dist/components/Consulting.d.ts +4 -0
- package/dist/components/Consulting.js +39 -0
- package/dist/components/Contributors.d.ts +7 -0
- package/dist/components/Contributors.js +74 -0
- package/dist/components/FileRemoved.d.ts +9 -0
- package/dist/components/FileRemoved.js +28 -0
- package/dist/components/HorizontalLine.d.ts +5 -0
- package/dist/components/HorizontalLine.js +15 -0
- package/dist/components/ImportMeta.d.ts +5 -0
- package/dist/components/ImportMeta.js +10 -0
- package/dist/components/Link.d.ts +16 -0
- package/dist/components/Link.js +108 -0
- package/dist/components/Note.d.ts +22 -0
- package/dist/components/Note.js +93 -0
- package/dist/components/P.d.ts +4 -0
- package/dist/components/P.js +17 -0
- package/dist/components/ReadingRecommendation.d.ts +6 -0
- package/dist/components/ReadingRecommendation.js +40 -0
- package/dist/components/RepoLink.d.ts +9 -0
- package/dist/components/RepoLink.js +22 -0
- package/dist/components/Sponsors.d.ts +22 -0
- package/dist/components/Sponsors.js +161 -0
- package/dist/components/Supporters.d.ts +32 -0
- package/dist/components/Supporters.js +80 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.js +15 -0
- package/dist/config/getConfig.d.ts +3 -0
- package/dist/config/getConfig.js +14 -0
- package/dist/config/resolveHeadingsData.d.ts +16 -0
- package/dist/config/resolveHeadingsData.js +216 -0
- package/dist/config/resolvePageContext.d.ts +38 -0
- package/dist/config/resolvePageContext.js +23 -0
- package/dist/data/maintainersList.d.ts +9 -0
- package/dist/data/maintainersList.js +83 -0
- package/dist/data/sponsorsList.d.ts +3 -0
- package/dist/data/sponsorsList.js +151 -0
- package/dist/navigation/Navigation.d.ts +20 -0
- package/dist/navigation/Navigation.js +134 -0
- package/dist/navigation/NavigationHeader.d.ts +4 -0
- package/dist/navigation/NavigationHeader.js +85 -0
- package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.d.ts +6 -0
- package/dist/navigation/navigation-fullscreen/NavigationFullscreenButton.js +22 -0
- package/dist/parsePageSections.js +7 -3
- package/dist/parseTitle.d.ts +5 -0
- package/dist/parseTitle.js +52 -0
- package/dist/renderer/usePageContext.d.ts +17 -0
- package/dist/renderer/usePageContext.js +26 -0
- package/dist/types/Config.d.ts +30 -0
- package/dist/types/Config.js +1 -0
- package/dist/types/Heading.d.ts +43 -0
- package/dist/types/Heading.js +1 -0
- package/dist/utils/Emoji/Emoji.d.ts +8 -0
- package/dist/utils/Emoji/Emoji.js +191 -0
- package/dist/utils/Emoji/assets.d.ts +6 -0
- package/dist/utils/Emoji/assets.js +7 -0
- package/dist/utils/Emoji/index.d.ts +1 -0
- package/dist/utils/Emoji/index.js +1 -0
- package/dist/utils/assert.js +43 -8
- package/dist/utils/client.d.ts +2 -0
- package/dist/utils/client.js +2 -0
- package/dist/utils/filter.d.ts +2 -0
- package/dist/utils/filter.js +11 -0
- package/dist/utils/isBrowser.d.ts +2 -0
- package/dist/utils/isBrowser.js +4 -0
- package/dist/utils/jsxToTextContent.d.ts +2 -0
- package/dist/utils/jsxToTextContent.js +12 -0
- package/dist/utils/objectAssign.d.ts +2 -0
- package/dist/utils/objectAssign.js +5 -0
- package/dist/utils/server.d.ts +7 -0
- package/dist/utils/server.js +7 -0
- package/dist/vite.config.js +5 -3
- package/installSectionUrlHashs.ts +7 -13
- package/navigation/Navigation.tsx +28 -19
- package/navigation/NavigationHeader.tsx +33 -4
- package/navigation/initMobileNavigation.ts +2 -11
- package/navigation/initPressKit.ts +5 -2
- package/navigation/navigation-fullscreen/initNavigationFullscreen.ts +12 -5
- package/package.json +21 -15
- package/parsePageSections.ts +6 -1
- package/renderer/getPageElement.tsx +16 -0
- package/renderer/onBeforeRender.ts +12 -0
- package/renderer/onRenderClient.tsx +90 -0
- package/renderer/onRenderHtml.tsx +10 -22
- package/renderer/usePageContext.tsx +20 -0
- package/tsconfig.config.json +1 -1
- package/tsconfig.json +1 -1
- package/types/Config.ts +6 -20
- package/types/Heading.ts +5 -5
- package/utils/assert.ts +44 -8
- package/utils/jsxToTextContent.ts +1 -1
- package/vite.config.ts +5 -3
- package/algolia/DocSearch.ts +0 -62
- package/navigation/Navigation.client.ts +0 -7
- 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
|
-
|
|
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
|
-
|
|
10
|
-
env: { client:
|
|
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
|
-
...
|
|
42
|
+
...pageContext2.config.NavHeader?.navHeaderMobileWrapperStyle,
|
|
41
43
|
}}
|
|
42
44
|
>
|
|
43
|
-
|
|
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({
|
|
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
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<div
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<div className="page-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
</
|
|
36
|
-
</
|
|
44
|
+
</PageContextProvider>
|
|
45
|
+
</PageContextProvider2>
|
|
37
46
|
</React.StrictMode>
|
|
38
47
|
)
|
|
39
48
|
}
|
package/algolia/DocSearch.css
CHANGED
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
padding-right: 6px !important;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
.DocSearch-Search-Icon {
|
|
28
25
|
height: 21px !important;
|
|
29
26
|
width: 21px !important;
|
|
30
27
|
}
|
|
31
|
-
|
|
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
|
-
|
|
1
|
+
export { autoScrollNav }
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
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
|
-
|
|
1
|
+
export { addTwitterWidgets }
|
|
2
|
+
export { addFeatureClickHandlers }
|
|
2
3
|
|
|
3
|
-
|
|
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
|
|
13
|
-
|
|
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
|
-
}
|
package/components/Link.tsx
CHANGED
|
@@ -48,25 +48,25 @@ function getLinkText({
|
|
|
48
48
|
noBreadcrumb: true | undefined
|
|
49
49
|
pageContext: PageContextResolved
|
|
50
50
|
doNotInferSectionTitle: true | undefined
|
|
51
|
-
}):
|
|
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:
|
|
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:
|
|
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:
|
|
111
|
-
linkBreadcrumb: null |
|
|
110
|
+
title: string
|
|
111
|
+
linkBreadcrumb: null | string[]
|
|
112
112
|
sectionTitles?: string[]
|
|
113
113
|
}
|
|
114
114
|
|
package/config/getConfig.ts
CHANGED
|
@@ -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
|
|
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:
|
|
21
|
-
titleInNav:
|
|
22
|
-
linkBreadcrumb:
|
|
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: {
|
|
126
|
+
pageContext: { urlPathname: string },
|
|
127
127
|
config: Config,
|
|
128
128
|
) {
|
|
129
|
-
const url = pageContext.
|
|
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: {
|
|
150
|
+
pageContext: { urlPathname: string; exports: Exports },
|
|
151
151
|
) {
|
|
152
152
|
let activeHeading: HeadingResolved | HeadingDetachedResolved | null = null
|
|
153
|
-
const {
|
|
154
|
-
assert(
|
|
153
|
+
const { urlPathname } = pageContext
|
|
154
|
+
assert(urlPathname)
|
|
155
155
|
headingsResolved.forEach((heading) => {
|
|
156
|
-
if (heading.url ===
|
|
156
|
+
if (heading.url === urlPathname) {
|
|
157
157
|
activeHeading = heading
|
|
158
|
-
assert(heading.level === 2, { pageUrl:
|
|
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 }) =>
|
|
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(
|
|
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
|
|
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
|
|
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:
|
|
190
|
+
title: pageSectionTitle,
|
|
191
191
|
linkBreadcrumb: [activeHeading.title, ...(activeHeading.linkBreadcrumb ?? [])],
|
|
192
|
-
titleInNav:
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
NavHeader: {
|
|
7
12
|
env: {
|
|
8
|
-
client:
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
env: { client:
|
|
11
|
+
NavHeader: {
|
|
12
|
+
env: { client: true, server: true },
|
|
9
13
|
},
|
|
10
14
|
},
|
|
11
15
|
};
|
|
@@ -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,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;
|