@brillout/docpress 0.13.2 → 0.15.0
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 +11 -16
- package/EditLink.tsx +1 -1
- package/ExternalLinks.tsx +8 -16
- package/Layout.tsx +26 -26
- package/MenuModal.tsx +1 -1
- package/NavItemComponent.tsx +1 -1
- package/components/Link.tsx +4 -4
- package/components/RepoLink.tsx +2 -3
- package/{renderer/determineNavItemsColumnLayout.ts → determineNavItemsColumnLayout.ts} +2 -3
- package/dist/+config.d.ts +9 -20
- package/dist/+config.js +3 -11
- package/dist/NavItemComponent.js +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/RepoLink.js +2 -3
- package/dist/{renderer/determineNavItemsColumnLayout.d.ts → determineNavItemsColumnLayout.d.ts} +1 -1
- package/dist/{renderer/determineNavItemsColumnLayout.js → determineNavItemsColumnLayout.js} +1 -2
- package/dist/parsePageSections.js +1 -1
- package/dist/renderer/usePageContext.d.ts +17 -10
- package/dist/renderer/usePageContext.js +11 -19
- package/dist/resolveConf.d.ts +19 -0
- package/dist/{config/resolveHeadingsData.js → resolveConf.js} +25 -30
- package/dist/types/Config.d.ts +19 -24
- package/dist/types/Heading.d.ts +9 -14
- package/docsearch/DocSearchInstall.tsx +1 -1
- package/index.ts +5 -1
- package/installSectionUrlHashs.ts +1 -0
- package/package.json +7 -9
- package/parsePageSections.ts +1 -1
- package/renderer/getPageElement.tsx +7 -15
- package/renderer/onCreatePageContext.ts +8 -0
- package/renderer/onRenderClient.tsx +2 -8
- package/renderer/onRenderHtml.tsx +56 -29
- package/renderer/usePageContext.tsx +12 -28
- package/{config/resolveHeadingsData.ts → resolveConf.ts} +31 -53
- package/tsconfig.config.json +1 -4
- package/tsconfig.json +1 -0
- package/types/Config.ts +24 -24
- package/types/Heading.ts +13 -20
- package/config/resolveConfig/resolveHeading.ts +0 -0
- package/config/resolvePageContext.ts +0 -49
- package/dist/config/resolveHeadingsData.d.ts +0 -24
- package/dist/config/resolvePageContext.d.ts +0 -41
- package/dist/config/resolvePageContext.js +0 -25
- package/renderer/onBeforeRender.ts +0 -12
package/+config.ts
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
export { config as default }
|
|
2
2
|
|
|
3
|
-
import type { Config
|
|
4
|
-
import type { Exports } from './config/resolvePageContext'
|
|
3
|
+
import type { Config } from 'vike/types'
|
|
5
4
|
import { viteConfig } from './vite.config.js'
|
|
6
5
|
import type { Config as DocpressConfig } from './types/Config'
|
|
6
|
+
import type { PageSection } from './parsePageSections'
|
|
7
|
+
import type { Conf } from './resolveConf.js'
|
|
7
8
|
|
|
8
9
|
const config = {
|
|
9
10
|
name: '@brillout/docpress',
|
|
10
|
-
require: { vike: '>=0.4.
|
|
11
|
+
require: { vike: '>=0.4.234' },
|
|
11
12
|
vite: viteConfig as Record<string, unknown>,
|
|
12
13
|
prerender: { noExtraDir: true },
|
|
13
14
|
onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
|
|
14
15
|
onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
|
|
15
|
-
|
|
16
|
-
Layout: 'import:@brillout/docpress/Layout:Layout',
|
|
16
|
+
onCreatePageContext: 'import:@brillout/docpress/renderer/onCreatePageContext:onCreatePageContext',
|
|
17
17
|
clientRouting: true,
|
|
18
18
|
hydrationCanBeAborted: true,
|
|
19
|
-
passToClient: ['pageContextResolved'],
|
|
20
19
|
meta: {
|
|
21
|
-
Layout: {
|
|
22
|
-
env: { client: true, server: true },
|
|
23
|
-
},
|
|
24
|
-
TopNavigation: {
|
|
25
|
-
env: { client: true, server: true },
|
|
26
|
-
},
|
|
27
20
|
docpress: {
|
|
28
|
-
env: { server: true },
|
|
21
|
+
env: { server: true, client: true },
|
|
29
22
|
global: true,
|
|
30
23
|
},
|
|
31
24
|
},
|
|
@@ -40,12 +33,14 @@ declare global {
|
|
|
40
33
|
namespace Vike {
|
|
41
34
|
interface PageContext {
|
|
42
35
|
Page: ReactComponent
|
|
43
|
-
|
|
36
|
+
conf: Conf
|
|
44
37
|
}
|
|
45
38
|
interface Config {
|
|
46
|
-
Layout?: ReactComponent | null | ImportString
|
|
47
|
-
TopNavigation?: ReactComponent
|
|
48
39
|
docpress?: DocpressConfig
|
|
49
40
|
}
|
|
41
|
+
interface ConfigResolved {
|
|
42
|
+
docpress: DocpressConfig
|
|
43
|
+
pageSectionsExport: PageSection[] | undefined
|
|
44
|
+
}
|
|
50
45
|
}
|
|
51
46
|
}
|
package/EditLink.tsx
CHANGED
|
@@ -22,7 +22,7 @@ function EditLink({ className, style }: { className?: string; style: React.CSSPr
|
|
|
22
22
|
)
|
|
23
23
|
const { urlPathname } = pageContext
|
|
24
24
|
const fsPath = urlPathname === '/' ? '/index/+Page.tsx' : `${urlPathname}/+Page.mdx`
|
|
25
|
-
const docsDir = pageContext.config.docsDir ?? 'docs'
|
|
25
|
+
const docsDir = pageContext.globalContext.config.docpress.docsDir ?? 'docs'
|
|
26
26
|
const editLink = getRepoHref(`/${docsDir}/pages${fsPath}`, true)
|
|
27
27
|
return (
|
|
28
28
|
<a href={editLink} className={className} style={{ display: 'flex', alignItems: 'center', ...style }}>
|
package/ExternalLinks.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import '@docsearch/css'
|
|
|
12
12
|
|
|
13
13
|
function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
14
14
|
const pageContext = usePageContext()
|
|
15
|
-
const {
|
|
15
|
+
const { github, discord, bluesky, i18n, twitter } = pageContext.globalContext.config.docpress
|
|
16
16
|
const iconI18n = !i18n ? null : (
|
|
17
17
|
<LinkIcon
|
|
18
18
|
className="decolorize-4"
|
|
@@ -31,18 +31,10 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
31
31
|
}}
|
|
32
32
|
>
|
|
33
33
|
{iconI18n}
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<LinkIcon className="decolorize-4" icon={
|
|
38
|
-
{projectInfo.blueskyHandle && (
|
|
39
|
-
<LinkIcon
|
|
40
|
-
className="decolorize-6"
|
|
41
|
-
icon={iconBluesky}
|
|
42
|
-
href={`https://bsky.app/profile/${projectInfo.blueskyHandle}`}
|
|
43
|
-
/>
|
|
44
|
-
)}
|
|
45
|
-
<LinkIcon className="decolorize-4" icon={iconGithub} href={projectInfo.githubRepository} />
|
|
34
|
+
{discord && <LinkIcon className="decolorize-6" icon={iconDiscord} href={discord} />}
|
|
35
|
+
{twitter && <LinkIcon className="decolorize-4" icon={iconTwitter} href={`https://x.com/${twitter.slice(1)}`} />}
|
|
36
|
+
{bluesky && <LinkIcon className="decolorize-6" icon={iconBluesky} href={`https://bsky.app/profile/${bluesky}`} />}
|
|
37
|
+
<LinkIcon className="decolorize-4" icon={iconGithub} href={github} />
|
|
46
38
|
<ChangelogButton />
|
|
47
39
|
</div>
|
|
48
40
|
)
|
|
@@ -50,10 +42,10 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
50
42
|
|
|
51
43
|
function ChangelogButton() {
|
|
52
44
|
const pageContext = usePageContext()
|
|
53
|
-
const {
|
|
45
|
+
const { version, github } = pageContext.globalContext.config.docpress
|
|
54
46
|
return (
|
|
55
47
|
<a
|
|
56
|
-
href={`${
|
|
48
|
+
href={`${github}/blob/main/CHANGELOG.md`}
|
|
57
49
|
className="colorize-on-hover"
|
|
58
50
|
style={{
|
|
59
51
|
display: 'flex',
|
|
@@ -72,7 +64,7 @@ function ChangelogButton() {
|
|
|
72
64
|
}}
|
|
73
65
|
>
|
|
74
66
|
<span id="version-number" className="decolorize-7">
|
|
75
|
-
v{
|
|
67
|
+
v{version}
|
|
76
68
|
</span>
|
|
77
69
|
<img className="decolorize-6" src={iconChangelog} height={16} style={{ marginLeft: 6 }} />
|
|
78
70
|
</div>
|
package/Layout.tsx
CHANGED
|
@@ -10,7 +10,7 @@ export { blockMargin }
|
|
|
10
10
|
import React from 'react'
|
|
11
11
|
import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemComponent'
|
|
12
12
|
import { parseMarkdownMini } from './parseMarkdownMini'
|
|
13
|
-
import { usePageContext
|
|
13
|
+
import { usePageContext } from './renderer/usePageContext'
|
|
14
14
|
import { ExternalLinks } from './ExternalLinks'
|
|
15
15
|
import { coseMenuModalOnMouseLeave, openMenuModal, toggleMenuModal } from './MenuModal/toggleMenuModal'
|
|
16
16
|
import { MenuModal } from './MenuModal'
|
|
@@ -47,7 +47,7 @@ const whitespaceBuster2: React.CSSProperties = {
|
|
|
47
47
|
|
|
48
48
|
function Layout({ children }: { children: React.ReactNode }) {
|
|
49
49
|
const pageContext = usePageContext()
|
|
50
|
-
const { isLandingPage } = pageContext
|
|
50
|
+
const { isLandingPage } = pageContext.conf
|
|
51
51
|
|
|
52
52
|
let content: React.JSX.Element
|
|
53
53
|
if (isLandingPage) {
|
|
@@ -86,7 +86,8 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
86
86
|
function LayoutDocsPage({ children }: { children: React.ReactNode }) {
|
|
87
87
|
const pageContext = usePageContext()
|
|
88
88
|
const hideNavLeftAlways =
|
|
89
|
-
pageContext.pageDesign?.hideMenuLeft ||
|
|
89
|
+
pageContext.conf.pageDesign?.hideMenuLeft ||
|
|
90
|
+
(pageContext.conf.navItemsDetached && pageContext.conf.navItemsDetached.length <= 1)
|
|
90
91
|
return (
|
|
91
92
|
<>
|
|
92
93
|
<Style>{getStyle()}</Style>
|
|
@@ -155,11 +156,13 @@ function LayoutLandingPage({ children }: { children: React.ReactNode }) {
|
|
|
155
156
|
|
|
156
157
|
function PageContent({ children }: { children: React.ReactNode }) {
|
|
157
158
|
const pageContext = usePageContext()
|
|
158
|
-
const { isLandingPage, pageTitle } = pageContext
|
|
159
|
+
const { isLandingPage, pageTitle } = pageContext.conf
|
|
159
160
|
const pageTitleParsed = pageTitle && parseMarkdownMini(pageTitle)
|
|
160
|
-
|
|
161
|
+
/*
|
|
162
|
+
const { globalNote } = pageContext.globalContext.config.docpress
|
|
163
|
+
*/
|
|
161
164
|
const ifDocPage = (style: React.CSSProperties) => (isLandingPage ? {} : style)
|
|
162
|
-
const contentMaxWidth = pageContext.pageDesign?.contentMaxWidth ?? mainViewWidthMax
|
|
165
|
+
const contentMaxWidth = pageContext.conf.pageDesign?.contentMaxWidth ?? mainViewWidthMax
|
|
163
166
|
return (
|
|
164
167
|
<div
|
|
165
168
|
className="page-wrapper low-prio-grow"
|
|
@@ -184,8 +187,8 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
184
187
|
}),
|
|
185
188
|
}}
|
|
186
189
|
>
|
|
187
|
-
{globalNote}
|
|
188
|
-
{pageTitleParsed && !pageContext.pageDesign?.hideTitle && (
|
|
190
|
+
{/* globalNote */}
|
|
191
|
+
{pageTitleParsed && !pageContext.conf.pageDesign?.hideTitle && (
|
|
189
192
|
<div>
|
|
190
193
|
<EditLink className="show-only-on-desktop" style={{ float: 'right', marginTop: 6, padding: 10 }} />
|
|
191
194
|
<h1 id={`${pageContext.urlPathname.replace('/', '')}`}>{pageTitleParsed}</h1>
|
|
@@ -199,7 +202,7 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
199
202
|
|
|
200
203
|
function NavLeft() {
|
|
201
204
|
const pageContext = usePageContext()
|
|
202
|
-
const { navItemsAll, navItemsDetached } = pageContext
|
|
205
|
+
const { navItemsAll, navItemsDetached } = pageContext.conf
|
|
203
206
|
return (
|
|
204
207
|
<>
|
|
205
208
|
<div
|
|
@@ -278,12 +281,9 @@ const menuLinkStyle: React.CSSProperties = {
|
|
|
278
281
|
|
|
279
282
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
280
283
|
const pageContext = usePageContext()
|
|
281
|
-
const
|
|
282
|
-
const {
|
|
283
|
-
const { isLandingPage } = pageContext
|
|
284
|
-
const { navMaxWidth } = pageContext.config
|
|
284
|
+
const { isLandingPage } = pageContext.conf
|
|
285
|
+
const { navMaxWidth, name } = pageContext.globalContext.config.docpress
|
|
285
286
|
|
|
286
|
-
const TopNavigation = pageContext2.config.TopNavigation || PassThrough
|
|
287
287
|
const navSecondaryContent = (
|
|
288
288
|
<div
|
|
289
289
|
className={isNavLeft ? 'show-on-nav-hover add-transition' : 'hide-on-shrink desktop-grow'}
|
|
@@ -302,7 +302,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
302
302
|
}),
|
|
303
303
|
}}
|
|
304
304
|
>
|
|
305
|
-
|
|
305
|
+
{pageContext.globalContext.config.docpress.topNavigation}
|
|
306
306
|
{!isNavLeft && <div className="desktop-grow" />}
|
|
307
307
|
<ExternalLinks
|
|
308
308
|
style={{
|
|
@@ -342,7 +342,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
342
342
|
maxWidth: navMaxWidth,
|
|
343
343
|
margin: 'auto',
|
|
344
344
|
height: 'var(--nav-head-height)',
|
|
345
|
-
fontSize: `min(15.2px, ${isProjectNameShort(
|
|
345
|
+
fontSize: `min(15.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
|
|
346
346
|
color: '#666',
|
|
347
347
|
['--icon-text-padding']: 'min(8px, 1.8cqw)',
|
|
348
348
|
display: 'flex',
|
|
@@ -483,8 +483,8 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
483
483
|
|
|
484
484
|
function NavLogo({ className }: { className: string }) {
|
|
485
485
|
const pageContext = usePageContext()
|
|
486
|
-
const iconSize = pageContext.config.navLogoSize ?? 39
|
|
487
|
-
const {
|
|
486
|
+
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
487
|
+
const { name } = pageContext.globalContext.config.docpress
|
|
488
488
|
return (
|
|
489
489
|
<a
|
|
490
490
|
className={cls(['nav-logo', className])}
|
|
@@ -497,14 +497,14 @@ function NavLogo({ className }: { className: string }) {
|
|
|
497
497
|
href="/"
|
|
498
498
|
>
|
|
499
499
|
<img
|
|
500
|
-
src={pageContext.
|
|
500
|
+
src={pageContext.globalContext.config.docpress.logo}
|
|
501
501
|
style={{
|
|
502
502
|
height: iconSize,
|
|
503
503
|
width: iconSize,
|
|
504
|
-
...pageContext.config.navLogoStyle,
|
|
504
|
+
...pageContext.globalContext.config.docpress.navLogoStyle,
|
|
505
505
|
}}
|
|
506
506
|
onContextMenu={(ev) => {
|
|
507
|
-
if (!pageContext.config.pressKit) return // no /press page
|
|
507
|
+
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
508
508
|
if (window.location.pathname === '/press') return
|
|
509
509
|
ev.preventDefault()
|
|
510
510
|
navigate('/press#logo')
|
|
@@ -513,17 +513,17 @@ function NavLogo({ className }: { className: string }) {
|
|
|
513
513
|
<span
|
|
514
514
|
style={{
|
|
515
515
|
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
516
|
-
fontSize: isProjectNameShort(
|
|
517
|
-
...pageContext.config.navLogoTextStyle,
|
|
516
|
+
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
517
|
+
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
518
518
|
}}
|
|
519
519
|
>
|
|
520
|
-
{
|
|
520
|
+
{name}
|
|
521
521
|
</span>
|
|
522
522
|
</a>
|
|
523
523
|
)
|
|
524
524
|
}
|
|
525
|
-
function isProjectNameShort(
|
|
526
|
-
return
|
|
525
|
+
function isProjectNameShort(name: string) {
|
|
526
|
+
return name.length <= 4
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
|
package/MenuModal.tsx
CHANGED
package/NavItemComponent.tsx
CHANGED
|
@@ -56,7 +56,7 @@ function NavItemComponent({
|
|
|
56
56
|
[
|
|
57
57
|
`${jsxToTextContent(titleInNavJsx)} is missing a URL hash.`,
|
|
58
58
|
`Add a URL hash with: \`## ${sectionTitle}{#some-hash}\`.`,
|
|
59
|
-
/*
|
|
59
|
+
/* TO-DO/eventually: not implemented yet.
|
|
60
60
|
`Use \`<h2 id="url-hash">${sectionTitle}</h2>\` instead of \`## ${sectionTitle}\`.`,
|
|
61
61
|
*/
|
|
62
62
|
].join(' '),
|
package/components/Link.tsx
CHANGED
|
@@ -2,11 +2,11 @@ export { Link }
|
|
|
2
2
|
export type { LinkData }
|
|
3
3
|
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import type { PageContextResolved } from '../config/resolvePageContext'
|
|
6
5
|
import { usePageContext } from '../renderer/usePageContext'
|
|
7
6
|
import { assert, assertUsage, assertWarning, determineSectionTitle, determineSectionUrlHash } from '../utils/server'
|
|
8
7
|
import { parseMarkdownMini } from '../parseMarkdownMini'
|
|
9
8
|
import pc from '@brillout/picocolors'
|
|
9
|
+
import type { PageContext } from 'vike/types'
|
|
10
10
|
|
|
11
11
|
function Link({
|
|
12
12
|
href,
|
|
@@ -90,7 +90,7 @@ function getLinkTextData({
|
|
|
90
90
|
noWarning,
|
|
91
91
|
}: {
|
|
92
92
|
href: string
|
|
93
|
-
pageContext:
|
|
93
|
+
pageContext: PageContext
|
|
94
94
|
doNotInferSectionTitle?: boolean
|
|
95
95
|
noWarning?: boolean
|
|
96
96
|
}) {
|
|
@@ -138,10 +138,10 @@ type LinkData = {
|
|
|
138
138
|
}
|
|
139
139
|
function findLinkData(
|
|
140
140
|
href: string,
|
|
141
|
-
{ pageContext, noWarning }: { pageContext:
|
|
141
|
+
{ pageContext, noWarning }: { pageContext: PageContext; noWarning?: boolean },
|
|
142
142
|
): LinkData | null {
|
|
143
143
|
assert(href.startsWith('/') || href.startsWith('#'))
|
|
144
|
-
const { linksAll } = pageContext
|
|
144
|
+
const { linksAll } = pageContext.conf
|
|
145
145
|
const linkData = linksAll.find(({ url }) => href === url)
|
|
146
146
|
if (href.startsWith('#')) {
|
|
147
147
|
if (!noWarning) {
|
package/components/RepoLink.tsx
CHANGED
|
@@ -24,9 +24,8 @@ function getRepoHref(path: string, editMode = false) {
|
|
|
24
24
|
path = '/' + path
|
|
25
25
|
}
|
|
26
26
|
const viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob'
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
let href = `${githubRepository}/${viewMode}/main${path}`
|
|
27
|
+
const { github } = pageContext.globalContext.config.docpress
|
|
28
|
+
let href = `${github}/${viewMode}/main${path}`
|
|
30
29
|
if (editMode) href += '?plain=1'
|
|
31
30
|
return href
|
|
32
31
|
}
|
|
@@ -3,9 +3,8 @@ export { determineNavItemsColumnLayout }
|
|
|
3
3
|
// A CSS-only solution doesn't seem to exist.
|
|
4
4
|
// - https://github.com/brillout/docpress/blob/2e41d8b9df098ff8312b02f7e9d41a202548e2b9/src/renderer/getStyleColumnLayout.ts#L4-L26
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { assert, assertUsage
|
|
8
|
-
assert(!isBrowser())
|
|
6
|
+
import type { NavItem } from './NavItemComponent'
|
|
7
|
+
import { assert, assertUsage } from './utils/assert'
|
|
9
8
|
|
|
10
9
|
function determineNavItemsColumnLayout(navItems: NavItem[]): undefined {
|
|
11
10
|
const columnLayouts = getColumnEntries(navItems)
|
package/dist/+config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { config as default };
|
|
2
|
-
import type { ImportString } from 'vike/types';
|
|
3
|
-
import type { Exports } from './config/resolvePageContext';
|
|
4
2
|
import type { Config as DocpressConfig } from './types/Config';
|
|
3
|
+
import type { PageSection } from './parsePageSections';
|
|
4
|
+
import type { Conf } from './resolveConf.js';
|
|
5
5
|
declare const config: {
|
|
6
6
|
name: string;
|
|
7
7
|
require: {
|
|
@@ -13,27 +13,14 @@ declare const config: {
|
|
|
13
13
|
};
|
|
14
14
|
onRenderHtml: "import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml";
|
|
15
15
|
onRenderClient: "import:@brillout/docpress/renderer/onRenderClient:onRenderClient";
|
|
16
|
-
|
|
17
|
-
Layout: "import:@brillout/docpress/Layout:Layout";
|
|
16
|
+
onCreatePageContext: "import:@brillout/docpress/renderer/onCreatePageContext:onCreatePageContext";
|
|
18
17
|
clientRouting: true;
|
|
19
18
|
hydrationCanBeAborted: true;
|
|
20
|
-
passToClient: string[];
|
|
21
19
|
meta: {
|
|
22
|
-
Layout: {
|
|
23
|
-
env: {
|
|
24
|
-
client: true;
|
|
25
|
-
server: true;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
TopNavigation: {
|
|
29
|
-
env: {
|
|
30
|
-
client: true;
|
|
31
|
-
server: true;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
20
|
docpress: {
|
|
35
21
|
env: {
|
|
36
22
|
server: true;
|
|
23
|
+
client: true;
|
|
37
24
|
};
|
|
38
25
|
global: true;
|
|
39
26
|
};
|
|
@@ -48,12 +35,14 @@ declare global {
|
|
|
48
35
|
namespace Vike {
|
|
49
36
|
interface PageContext {
|
|
50
37
|
Page: ReactComponent;
|
|
51
|
-
|
|
38
|
+
conf: Conf;
|
|
52
39
|
}
|
|
53
40
|
interface Config {
|
|
54
|
-
Layout?: ReactComponent | null | ImportString;
|
|
55
|
-
TopNavigation?: ReactComponent;
|
|
56
41
|
docpress?: DocpressConfig;
|
|
57
42
|
}
|
|
43
|
+
interface ConfigResolved {
|
|
44
|
+
docpress: DocpressConfig;
|
|
45
|
+
pageSectionsExport: PageSection[] | undefined;
|
|
46
|
+
}
|
|
58
47
|
}
|
|
59
48
|
}
|
package/dist/+config.js
CHANGED
|
@@ -2,25 +2,17 @@ export { config as default };
|
|
|
2
2
|
import { viteConfig } from './vite.config.js';
|
|
3
3
|
var config = {
|
|
4
4
|
name: '@brillout/docpress',
|
|
5
|
-
require: { vike: '>=0.4.
|
|
5
|
+
require: { vike: '>=0.4.234' },
|
|
6
6
|
vite: viteConfig,
|
|
7
7
|
prerender: { noExtraDir: true },
|
|
8
8
|
onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
|
|
9
9
|
onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
|
|
10
|
-
|
|
11
|
-
Layout: 'import:@brillout/docpress/Layout:Layout',
|
|
10
|
+
onCreatePageContext: 'import:@brillout/docpress/renderer/onCreatePageContext:onCreatePageContext',
|
|
12
11
|
clientRouting: true,
|
|
13
12
|
hydrationCanBeAborted: true,
|
|
14
|
-
passToClient: ['pageContextResolved'],
|
|
15
13
|
meta: {
|
|
16
|
-
Layout: {
|
|
17
|
-
env: { client: true, server: true },
|
|
18
|
-
},
|
|
19
|
-
TopNavigation: {
|
|
20
|
-
env: { client: true, server: true },
|
|
21
|
-
},
|
|
22
14
|
docpress: {
|
|
23
|
-
env: { server: true },
|
|
15
|
+
env: { server: true, client: true },
|
|
24
16
|
global: true,
|
|
25
17
|
},
|
|
26
18
|
},
|
package/dist/NavItemComponent.js
CHANGED
|
@@ -33,7 +33,7 @@ function NavItemComponent(_a) {
|
|
|
33
33
|
assertWarning(navItem.url, [
|
|
34
34
|
"".concat(jsxToTextContent(titleInNavJsx), " is missing a URL hash."),
|
|
35
35
|
"Add a URL hash with: `## ".concat(sectionTitle, "{#some-hash}`."),
|
|
36
|
-
/*
|
|
36
|
+
/* TO-DO/eventually: not implemented yet.
|
|
37
37
|
`Use \`<h2 id="url-hash">${sectionTitle}</h2>\` instead of \`## ${sectionTitle}\`.`,
|
|
38
38
|
*/
|
|
39
39
|
].join(' '));
|
package/dist/components/Link.js
CHANGED
|
@@ -91,7 +91,7 @@ function getLinkTextData(_a) {
|
|
|
91
91
|
function findLinkData(href, _a) {
|
|
92
92
|
var pageContext = _a.pageContext, noWarning = _a.noWarning;
|
|
93
93
|
assert(href.startsWith('/') || href.startsWith('#'));
|
|
94
|
-
var linksAll = pageContext.linksAll;
|
|
94
|
+
var linksAll = pageContext.conf.linksAll;
|
|
95
95
|
var linkData = linksAll.find(function (_a) {
|
|
96
96
|
var url = _a.url;
|
|
97
97
|
return href === url;
|
|
@@ -22,9 +22,8 @@ function getRepoHref(path, editMode) {
|
|
|
22
22
|
path = '/' + path;
|
|
23
23
|
}
|
|
24
24
|
var viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
var href = "".concat(githubRepository, "/").concat(viewMode, "/main").concat(path);
|
|
25
|
+
var github = pageContext.globalContext.config.docpress.github;
|
|
26
|
+
var href = "".concat(github, "/").concat(viewMode, "/main").concat(path);
|
|
28
27
|
if (editMode)
|
|
29
28
|
href += '?plain=1';
|
|
30
29
|
return href;
|
|
@@ -19,8 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
21
|
export { determineNavItemsColumnLayout };
|
|
22
|
-
import { assert, assertUsage
|
|
23
|
-
assert(!isBrowser());
|
|
22
|
+
import { assert, assertUsage } from './utils/assert';
|
|
24
23
|
function determineNavItemsColumnLayout(navItems) {
|
|
25
24
|
var columnLayouts = getColumnEntries(navItems);
|
|
26
25
|
columnLayouts.forEach(function (columnEntries) {
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
export { usePageContext };
|
|
2
1
|
export { PageContextProvider };
|
|
2
|
+
export { usePageContext };
|
|
3
|
+
export { usePageContextLegacy };
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import type { PageContextResolved } from '../config/resolvePageContext';
|
|
5
5
|
import type { PageContext } from 'vike/types';
|
|
6
|
+
declare function usePageContextLegacy(): {
|
|
7
|
+
navItemsAll: import("../NavItemComponent").NavItem[];
|
|
8
|
+
navItemsDetached: import("../NavItemComponent").NavItem[] | undefined;
|
|
9
|
+
pageDesign: {
|
|
10
|
+
hideTitle?: true;
|
|
11
|
+
hideMenuLeft?: true;
|
|
12
|
+
contentMaxWidth?: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
linksAll: import("../components").LinkData[];
|
|
15
|
+
isLandingPage: boolean;
|
|
16
|
+
pageTitle: string | null;
|
|
17
|
+
documentTitle: string;
|
|
18
|
+
activeCategoryName: string;
|
|
19
|
+
};
|
|
20
|
+
declare function usePageContext(): PageContext;
|
|
6
21
|
declare function PageContextProvider({ pageContext, children, }: {
|
|
7
|
-
pageContext: PageContextResolved;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}): React.JSX.Element;
|
|
10
|
-
declare function usePageContext(): PageContextResolved;
|
|
11
|
-
export { PageContextProvider2 };
|
|
12
|
-
export { usePageContext2 };
|
|
13
|
-
declare function usePageContext2(): PageContext;
|
|
14
|
-
declare function PageContextProvider2({ pageContext, children, }: {
|
|
15
22
|
pageContext: PageContext;
|
|
16
23
|
children: React.ReactNode;
|
|
17
24
|
}): React.JSX.Element;
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
export { usePageContext };
|
|
2
1
|
export { PageContextProvider };
|
|
2
|
+
export { usePageContext };
|
|
3
|
+
export { usePageContextLegacy };
|
|
3
4
|
import React, { useContext } from 'react';
|
|
4
5
|
import { getGlobalObject } from '../utils/getGlobalObject';
|
|
5
6
|
var globalObject = getGlobalObject('usePageContext.ts', {
|
|
6
|
-
|
|
7
|
-
Context2: React.createContext(undefined),
|
|
7
|
+
Ctx: React.createContext(undefined),
|
|
8
8
|
});
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
return
|
|
9
|
+
function usePageContextLegacy() {
|
|
10
|
+
var Ctx = globalObject.Ctx;
|
|
11
|
+
var pageContext = useContext(Ctx);
|
|
12
|
+
return pageContext.conf;
|
|
13
13
|
}
|
|
14
14
|
function usePageContext() {
|
|
15
|
-
var
|
|
16
|
-
var pageContext = useContext(Context);
|
|
15
|
+
var pageContext = useContext(globalObject.Ctx);
|
|
17
16
|
return pageContext;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
// TODO/refactor: rename to usePageContext and remove old implementation
|
|
21
|
-
export { usePageContext2 };
|
|
22
|
-
function usePageContext2() {
|
|
23
|
-
var pageContext = useContext(globalObject.Context2);
|
|
24
|
-
return pageContext;
|
|
25
|
-
}
|
|
26
|
-
function PageContextProvider2(_a) {
|
|
18
|
+
function PageContextProvider(_a) {
|
|
27
19
|
var pageContext = _a.pageContext, children = _a.children;
|
|
28
|
-
var
|
|
29
|
-
return React.createElement(
|
|
20
|
+
var Ctx = globalObject.Ctx;
|
|
21
|
+
return React.createElement(Ctx.Provider, { value: pageContext }, children);
|
|
30
22
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { resolveConf };
|
|
2
|
+
export type Conf = ReturnType<typeof resolveConf>;
|
|
3
|
+
import type { NavItem } from './NavItemComponent';
|
|
4
|
+
import type { LinkData } from './components';
|
|
5
|
+
import type { PageContextServer } from 'vike/types';
|
|
6
|
+
declare function resolveConf(pageContext: PageContextServer): {
|
|
7
|
+
navItemsAll: NavItem[];
|
|
8
|
+
navItemsDetached: NavItem[] | undefined;
|
|
9
|
+
pageDesign: {
|
|
10
|
+
hideTitle?: true;
|
|
11
|
+
hideMenuLeft?: true;
|
|
12
|
+
contentMaxWidth?: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
linksAll: LinkData[];
|
|
15
|
+
isLandingPage: boolean;
|
|
16
|
+
pageTitle: string | null;
|
|
17
|
+
documentTitle: string;
|
|
18
|
+
activeCategoryName: string;
|
|
19
|
+
};
|