@brillout/docpress 0.13.2 → 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 +1 -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 +1 -1
- 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 +1 -1
- 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 +1 -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 +1 -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,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 { 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
|
@@ -24,7 +24,7 @@ function getRepoHref(path: string, editMode = false) {
|
|
|
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;
|
|
@@ -22,7 +22,7 @@ function getRepoHref(path, editMode) {
|
|
|
22
22
|
path = '/' + path;
|
|
23
23
|
}
|
|
24
24
|
var viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
|
|
25
|
-
var githubRepository = pageContext.config.projectInfo.githubRepository;
|
|
25
|
+
var githubRepository = pageContext.globalContext.config.docpress.projectInfo.githubRepository;
|
|
26
26
|
assert(githubRepository.startsWith('https://github.com/'));
|
|
27
27
|
var href = "".concat(githubRepository, "/").concat(viewMode, "/main").concat(path);
|
|
28
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
|
+
};
|
|
@@ -18,15 +18,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
export {
|
|
22
|
-
import { assert
|
|
21
|
+
export { resolveConf };
|
|
22
|
+
import { assert } from './utils/assert';
|
|
23
|
+
import { jsxToTextContent } from './utils/jsxToTextContent';
|
|
23
24
|
import pc from '@brillout/picocolors';
|
|
24
|
-
import { parseMarkdownMini } from '
|
|
25
|
-
import { determineNavItemsColumnLayout } from '
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var
|
|
25
|
+
import { parseMarkdownMini } from './parseMarkdownMini';
|
|
26
|
+
import { determineNavItemsColumnLayout } from './determineNavItemsColumnLayout';
|
|
27
|
+
function resolveConf(pageContext) {
|
|
28
|
+
var _a;
|
|
29
|
+
var config = pageContext.globalContext.config.docpress;
|
|
30
|
+
var urlPathname = pageContext.urlPathname;
|
|
31
|
+
var pageSections = (_a = pageContext.config.pageSectionsExport) !== null && _a !== void 0 ? _a : [];
|
|
30
32
|
{
|
|
31
33
|
var headings = config.headings, headingsDetached = config.headingsDetached;
|
|
32
34
|
assertHeadingsDefinition(__spreadArray(__spreadArray([], headings, true), headingsDetached, true));
|
|
@@ -34,10 +36,12 @@ function resolveHeadingsData(pageContext) {
|
|
|
34
36
|
var resolved = getHeadingsResolved(config);
|
|
35
37
|
var headingsDetachedResolved = resolved.headingsDetachedResolved;
|
|
36
38
|
var headingsResolved = resolved.headingsResolved;
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var pageSectionsResolved = getPageSectionsResolved(
|
|
40
|
-
var
|
|
39
|
+
var _b = getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathname), activeHeading = _b.activeHeading, isDetachedPage = _b.isDetachedPage, activeCategoryName = _b.activeCategoryName;
|
|
40
|
+
var _c = getTitles(activeHeading, urlPathname, config), documentTitle = _c.documentTitle, isLandingPage = _c.isLandingPage, pageTitle = _c.pageTitle;
|
|
41
|
+
var pageSectionsResolved = getPageSectionsResolved(pageSections, activeHeading);
|
|
42
|
+
var linksGlobal = __spreadArray(__spreadArray([], headingsResolved.map(headingToLinkData), true), headingsDetachedResolved.map(headingToLinkData), true);
|
|
43
|
+
var linksPage = pageSectionsResolved.map(pageSectionToLinkData);
|
|
44
|
+
var linksAll = __spreadArray(__spreadArray([], linksPage, true), linksGlobal, true);
|
|
41
45
|
var navItemsAll;
|
|
42
46
|
var navItemsDetached;
|
|
43
47
|
{
|
|
@@ -50,18 +54,14 @@ function resolveHeadingsData(pageContext) {
|
|
|
50
54
|
navItemsDetached = __spreadArray([headingToNavItem(activeHeading)], navItemsPageSections, true);
|
|
51
55
|
}
|
|
52
56
|
else {
|
|
53
|
-
var activeHeadingIndex_1 = navItemsAll.findIndex(function (navItem) { return navItem.url ===
|
|
57
|
+
var activeHeadingIndex_1 = navItemsAll.findIndex(function (navItem) { return navItem.url === urlPathname; });
|
|
54
58
|
assert(activeHeadingIndex_1 >= 0);
|
|
55
59
|
navItemsPageSections.forEach(function (navItem, i) {
|
|
56
60
|
navItemsAll.splice(activeHeadingIndex_1 + 1 + i, 0, navItem);
|
|
57
61
|
});
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
|
-
var
|
|
61
|
-
name: activeCategoryName,
|
|
62
|
-
order: 99999999999,
|
|
63
|
-
};
|
|
64
|
-
var pageContextAddendum = {
|
|
64
|
+
var conf = {
|
|
65
65
|
navItemsAll: navItemsAll,
|
|
66
66
|
navItemsDetached: navItemsDetached,
|
|
67
67
|
pageDesign: activeHeading.pageDesign,
|
|
@@ -69,10 +69,9 @@ function resolveHeadingsData(pageContext) {
|
|
|
69
69
|
isLandingPage: isLandingPage,
|
|
70
70
|
pageTitle: pageTitle,
|
|
71
71
|
documentTitle: documentTitle,
|
|
72
|
-
|
|
73
|
-
activeCategory: activeCategory,
|
|
72
|
+
activeCategoryName: activeCategoryName,
|
|
74
73
|
};
|
|
75
|
-
return
|
|
74
|
+
return conf;
|
|
76
75
|
}
|
|
77
76
|
function headingToNavItem(heading) {
|
|
78
77
|
return {
|
|
@@ -109,9 +108,8 @@ function pageSectionToLinkData(pageSection) {
|
|
|
109
108
|
linkBreadcrumb: pageSection.linkBreadcrumb,
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
|
-
function getTitles(activeHeading,
|
|
113
|
-
var
|
|
114
|
-
var isLandingPage = url === '/';
|
|
111
|
+
function getTitles(activeHeading, urlPathname, config) {
|
|
112
|
+
var isLandingPage = urlPathname === '/';
|
|
115
113
|
var title = activeHeading.title;
|
|
116
114
|
var pageTitle = isLandingPage ? null : title;
|
|
117
115
|
var documentTitle = activeHeading.titleDocument || jsxToTextContent(parseMarkdownMini(title));
|
|
@@ -123,12 +121,11 @@ function getTitles(activeHeading, pageContext, config) {
|
|
|
123
121
|
}
|
|
124
122
|
return { documentTitle: documentTitle, isLandingPage: isLandingPage, pageTitle: pageTitle };
|
|
125
123
|
}
|
|
126
|
-
function getActiveHeading(headingsResolved, headingsDetachedResolved,
|
|
124
|
+
function getActiveHeading(headingsResolved, headingsDetachedResolved, urlPathname) {
|
|
127
125
|
var _a;
|
|
128
126
|
var activeHeading = null;
|
|
129
127
|
var activeCategoryName = 'Miscellaneous';
|
|
130
128
|
var headingCategory;
|
|
131
|
-
var urlPathname = pageContext.urlPathname;
|
|
132
129
|
assert(urlPathname);
|
|
133
130
|
for (var _i = 0, headingsResolved_1 = headingsResolved; _i < headingsResolved_1.length; _i++) {
|
|
134
131
|
var heading = headingsResolved_1[_i];
|
|
@@ -164,9 +161,7 @@ function getActiveHeading(headingsResolved, headingsDetachedResolved, pageContex
|
|
|
164
161
|
activeCategoryName = activeHeading.category;
|
|
165
162
|
return { activeHeading: activeHeading, isDetachedPage: isDetachedPage, activeCategoryName: activeCategoryName };
|
|
166
163
|
}
|
|
167
|
-
function getPageSectionsResolved(
|
|
168
|
-
var _a;
|
|
169
|
-
var pageSections = (_a = pageContext.exports.pageSectionsExport) !== null && _a !== void 0 ? _a : [];
|
|
164
|
+
function getPageSectionsResolved(pageSections, activeHeading) {
|
|
170
165
|
var pageSectionsResolved = pageSections.map(function (pageSection) {
|
|
171
166
|
var _a;
|
|
172
167
|
var pageSectionTitle = pageSection.pageSectionTitle;
|