@brillout/docpress 0.13.1 → 0.14.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 +2 -1
- package/ExternalLinks.tsx +2 -2
- package/Layout.tsx +24 -21
- package/MenuModal.tsx +1 -1
- package/NavItemComponent.tsx +1 -1
- package/components/Link.tsx +4 -4
- package/components/RepoLink.tsx +4 -4
- 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.d.ts +2 -3
- package/dist/components/RepoLink.js +4 -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} +24 -29
- package/dist/types/Config.d.ts +2 -0
- 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 +53 -23
- package/renderer/usePageContext.tsx +12 -28
- package/{config/resolveHeadingsData.ts → resolveConf.ts} +30 -52
- package/tsconfig.config.json +1 -4
- package/tsconfig.json +1 -0
- package/types/Config.ts +2 -0
- 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,8 @@ 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
|
|
25
|
+
const docsDir = pageContext.globalContext.config.docpress.docsDir ?? 'docs'
|
|
26
|
+
const editLink = getRepoHref(`/${docsDir}/pages${fsPath}`, true)
|
|
26
27
|
return (
|
|
27
28
|
<a href={editLink} className={className} style={{ display: 'flex', alignItems: 'center', ...style }}>
|
|
28
29
|
{icon} Edit this page
|
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 { projectInfo, i18n } = pageContext.config
|
|
15
|
+
const { projectInfo, i18n } = pageContext.globalContext.config.docpress
|
|
16
16
|
const iconI18n = !i18n ? null : (
|
|
17
17
|
<LinkIcon
|
|
18
18
|
className="decolorize-4"
|
|
@@ -50,7 +50,7 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
50
50
|
|
|
51
51
|
function ChangelogButton() {
|
|
52
52
|
const pageContext = usePageContext()
|
|
53
|
-
const { projectInfo } = pageContext.config
|
|
53
|
+
const { projectInfo } = pageContext.globalContext.config.docpress
|
|
54
54
|
return (
|
|
55
55
|
<a
|
|
56
56
|
href={`${projectInfo.githubRepository}/blob/main/CHANGELOG.md`}
|
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,12 @@ const menuLinkStyle: React.CSSProperties = {
|
|
|
278
281
|
|
|
279
282
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
280
283
|
const pageContext = usePageContext()
|
|
281
|
-
const
|
|
282
|
-
const {
|
|
283
|
-
|
|
284
|
-
|
|
284
|
+
const { isLandingPage } = pageContext.conf
|
|
285
|
+
const {
|
|
286
|
+
navMaxWidth,
|
|
287
|
+
projectInfo: { projectName },
|
|
288
|
+
} = pageContext.globalContext.config.docpress
|
|
285
289
|
|
|
286
|
-
const TopNavigation = pageContext2.config.TopNavigation || PassThrough
|
|
287
290
|
const navSecondaryContent = (
|
|
288
291
|
<div
|
|
289
292
|
className={isNavLeft ? 'show-on-nav-hover add-transition' : 'hide-on-shrink desktop-grow'}
|
|
@@ -302,7 +305,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
302
305
|
}),
|
|
303
306
|
}}
|
|
304
307
|
>
|
|
305
|
-
|
|
308
|
+
{pageContext.globalContext.config.docpress.topNavigation}
|
|
306
309
|
{!isNavLeft && <div className="desktop-grow" />}
|
|
307
310
|
<ExternalLinks
|
|
308
311
|
style={{
|
|
@@ -483,8 +486,8 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
483
486
|
|
|
484
487
|
function NavLogo({ className }: { className: string }) {
|
|
485
488
|
const pageContext = usePageContext()
|
|
486
|
-
const iconSize = pageContext.config.navLogoSize ?? 39
|
|
487
|
-
const { projectName } = pageContext.
|
|
489
|
+
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
490
|
+
const { projectName } = pageContext.globalContext.config.docpress.projectInfo
|
|
488
491
|
return (
|
|
489
492
|
<a
|
|
490
493
|
className={cls(['nav-logo', className])}
|
|
@@ -497,14 +500,14 @@ function NavLogo({ className }: { className: string }) {
|
|
|
497
500
|
href="/"
|
|
498
501
|
>
|
|
499
502
|
<img
|
|
500
|
-
src={pageContext.
|
|
503
|
+
src={pageContext.globalContext.config.docpress.logoUrl}
|
|
501
504
|
style={{
|
|
502
505
|
height: iconSize,
|
|
503
506
|
width: iconSize,
|
|
504
|
-
...pageContext.config.navLogoStyle,
|
|
507
|
+
...pageContext.globalContext.config.docpress.navLogoStyle,
|
|
505
508
|
}}
|
|
506
509
|
onContextMenu={(ev) => {
|
|
507
|
-
if (!pageContext.config.pressKit) return // no /press page
|
|
510
|
+
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
508
511
|
if (window.location.pathname === '/press') return
|
|
509
512
|
ev.preventDefault()
|
|
510
513
|
navigate('/press#logo')
|
|
@@ -514,7 +517,7 @@ function NavLogo({ className }: { className: string }) {
|
|
|
514
517
|
style={{
|
|
515
518
|
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
516
519
|
fontSize: isProjectNameShort(projectName) ? '1.65em' : '1.3em',
|
|
517
|
-
...pageContext.config.navLogoTextStyle,
|
|
520
|
+
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
518
521
|
}}
|
|
519
522
|
>
|
|
520
523
|
{projectName}
|
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
|
@@ -11,20 +11,20 @@ function isRepoLink(href: string) {
|
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function RepoLink({ path, text
|
|
14
|
+
function RepoLink({ path, text }: { path: string; text?: string | React.ReactNode }) {
|
|
15
15
|
text = text || path
|
|
16
|
-
const href = getRepoHref(path
|
|
16
|
+
const href = getRepoHref(path)
|
|
17
17
|
return <a href={href}>{text}</a>
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function getRepoHref(path: string, editMode
|
|
20
|
+
function getRepoHref(path: string, editMode = false) {
|
|
21
21
|
const pageContext = usePageContext()
|
|
22
22
|
assert(isRepoLink(path), { path })
|
|
23
23
|
if (!path.startsWith('/')) {
|
|
24
24
|
path = '/' + path
|
|
25
25
|
}
|
|
26
26
|
const viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob'
|
|
27
|
-
const { githubRepository } = pageContext.config.projectInfo
|
|
27
|
+
const { githubRepository } = pageContext.globalContext.config.docpress.projectInfo
|
|
28
28
|
assert(githubRepository.startsWith('https://github.com/'))
|
|
29
29
|
let href = `${githubRepository}/${viewMode}/main${path}`
|
|
30
30
|
if (editMode) href += '?plain=1'
|
|
@@ -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;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { RepoLink };
|
|
2
2
|
export { getRepoHref };
|
|
3
3
|
import React from 'react';
|
|
4
|
-
declare function RepoLink({ path, text
|
|
4
|
+
declare function RepoLink({ path, text }: {
|
|
5
5
|
path: string;
|
|
6
6
|
text?: string | React.ReactNode;
|
|
7
|
-
editMode?: true;
|
|
8
7
|
}): React.JSX.Element;
|
|
9
|
-
declare function getRepoHref(path: string, editMode?:
|
|
8
|
+
declare function getRepoHref(path: string, editMode?: boolean): string;
|
|
@@ -9,19 +9,20 @@ function isRepoLink(href) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
function RepoLink(_a) {
|
|
12
|
-
var path = _a.path, text = _a.text
|
|
12
|
+
var path = _a.path, text = _a.text;
|
|
13
13
|
text = text || path;
|
|
14
|
-
var href = getRepoHref(path
|
|
14
|
+
var href = getRepoHref(path);
|
|
15
15
|
return React.createElement("a", { href: href }, text);
|
|
16
16
|
}
|
|
17
17
|
function getRepoHref(path, editMode) {
|
|
18
|
+
if (editMode === void 0) { editMode = false; }
|
|
18
19
|
var pageContext = usePageContext();
|
|
19
20
|
assert(isRepoLink(path), { path: path });
|
|
20
21
|
if (!path.startsWith('/')) {
|
|
21
22
|
path = '/' + path;
|
|
22
23
|
}
|
|
23
24
|
var viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
|
|
24
|
-
var githubRepository = pageContext.config.projectInfo.githubRepository;
|
|
25
|
+
var githubRepository = pageContext.globalContext.config.docpress.projectInfo.githubRepository;
|
|
25
26
|
assert(githubRepository.startsWith('https://github.com/'));
|
|
26
27
|
var href = "".concat(githubRepository, "/").concat(viewMode, "/main").concat(path);
|
|
27
28
|
if (editMode)
|
|
@@ -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
|
+
};
|