@brillout/docpress 0.16.47-commit-cd5aa01 → 0.16.47-commit-e262d2a
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/Layout.tsx +8 -5
- package/components/index.ts +0 -3
- package/css/heading.css +2 -2
- package/dist/components/index.d.ts +0 -3
- package/dist/components/index.js +0 -3
- package/dist/renderer/usePageContext.d.ts +0 -16
- package/dist/renderer/usePageContext.js +0 -6
- package/dist/resolvePageContext.d.ts +1 -0
- package/dist/types/Heading.d.ts +6 -0
- package/dist/utils/server.d.ts +0 -2
- package/dist/utils/server.js +0 -2
- package/package.json +1 -1
- package/renderer/usePageContext.tsx +0 -7
- package/types/Heading.ts +6 -0
- package/utils/server.ts +0 -2
- package/components/Comment.tsx +0 -7
- package/components/HorizontalLine.tsx +0 -22
- package/components/P.css +0 -8
- package/components/P.tsx +0 -8
- package/dist/components/Comment.d.ts +0 -3
- package/dist/components/Comment.js +0 -5
- package/dist/components/HorizontalLine.d.ts +0 -5
- package/dist/components/HorizontalLine.js +0 -15
- package/dist/components/P.d.ts +0 -4
- package/dist/components/P.js +0 -6
- package/dist/utils/cls.d.ts +0 -3
- package/dist/utils/cls.js +0 -5
- package/dist/utils/filter.d.ts +0 -2
- package/dist/utils/filter.js +0 -11
- package/dist/utils/objectAssign.d.ts +0 -2
- package/dist/utils/objectAssign.js +0 -5
- package/utils/PassTrough.tsx +0 -7
- package/utils/filesystemPathHandling.ts +0 -42
- package/utils/filter.ts +0 -12
- package/utils/objectAssign.ts +0 -9
package/Layout.tsx
CHANGED
|
@@ -69,7 +69,8 @@ const whitespaceBuster2: React.CSSProperties = {
|
|
|
69
69
|
|
|
70
70
|
function Layout({ children }: { children: React.ReactNode }) {
|
|
71
71
|
const pageContext = usePageContext()
|
|
72
|
-
const { isLandingPage } = pageContext.resolved
|
|
72
|
+
const { isLandingPage, pageDesign } = pageContext.resolved
|
|
73
|
+
const isTopNavSticky = !isLandingPage && (pageDesign?.topNavSticky ?? true)
|
|
73
74
|
|
|
74
75
|
let content: React.JSX.Element
|
|
75
76
|
if (isLandingPage) {
|
|
@@ -86,6 +87,8 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
86
87
|
['--block-margin']: `${blockMargin}px`,
|
|
87
88
|
// ['--nav-head-height']: `${isLandingPage ? 70 : 63}px`,
|
|
88
89
|
['--nav-head-height']: `63px`,
|
|
90
|
+
// The offset that sticky elements (top nav, <NavLeft>) sit below. Zero when the top nav scrolls away.
|
|
91
|
+
['--nav-head-sticky-offset']: isTopNavSticky ? 'var(--nav-head-height)' : '0px',
|
|
89
92
|
['--main-view-padding']: `${mainViewPadding}px`,
|
|
90
93
|
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
91
94
|
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
@@ -95,7 +98,7 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
95
98
|
}}
|
|
96
99
|
>
|
|
97
100
|
<div className={isLandingPage ? 'landing-page' : 'doc-page'} style={whitespaceBuster1}>
|
|
98
|
-
<div style={{ position:
|
|
101
|
+
<div style={{ position: isTopNavSticky ? 'sticky' : 'relative', top: 0, zIndex: 100 }}>
|
|
99
102
|
<NavHead />
|
|
100
103
|
{/* <MenuModal> is inside here because `container-type` on the page wrapper traps `position: fixed` — https://github.com/brillout/docpress/pull/177 */}
|
|
101
104
|
<MenuModal isNavLeftAlwaysHidden_={isNavLeftAlwaysHidden_} />
|
|
@@ -223,8 +226,8 @@ function NavLeft() {
|
|
|
223
226
|
<div
|
|
224
227
|
style={{
|
|
225
228
|
position: 'sticky',
|
|
226
|
-
// Sit below the sticky top nav
|
|
227
|
-
top: 'var(--nav-head-
|
|
229
|
+
// Sit below the sticky top nav (or at the very top when the top nav scrolls away)
|
|
230
|
+
top: 'var(--nav-head-sticky-offset)',
|
|
228
231
|
}}
|
|
229
232
|
>
|
|
230
233
|
<div
|
|
@@ -236,7 +239,7 @@ function NavLeft() {
|
|
|
236
239
|
id="navigation-container"
|
|
237
240
|
style={{
|
|
238
241
|
top: 0,
|
|
239
|
-
height: `calc(100vh - var(--nav-head-
|
|
242
|
+
height: `calc(100vh - var(--nav-head-sticky-offset) - var(--block-margin))`,
|
|
240
243
|
overflowY: 'auto',
|
|
241
244
|
overscrollBehavior: 'contain',
|
|
242
245
|
paddingBottom: 40,
|
package/components/index.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export * from '../utils/Emoji/index.js'
|
|
2
2
|
export * from './Link.js'
|
|
3
3
|
export * from './RepoLink.js'
|
|
4
|
-
export * from './P.js'
|
|
5
4
|
export * from './Note.js'
|
|
6
5
|
export * from './ImportMeta.js'
|
|
7
|
-
export * from './HorizontalLine.js'
|
|
8
6
|
export * from './CodeBlockTransformer.js'
|
|
9
|
-
export * from './Comment.js'
|
|
10
7
|
export * from './FileRemoved.js'
|
|
11
8
|
export * from '../code-blocks/components/Tabs.js'
|
package/css/heading.css
CHANGED
|
@@ -13,9 +13,9 @@ h3 {
|
|
|
13
13
|
margin-bottom: 20px;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/* Offset headings below the sticky top nav. */
|
|
16
|
+
/* Offset headings below the sticky top nav (no offset when the top nav scrolls away). */
|
|
17
17
|
.doc-page :is(h1, h2, h3, h4, h5, h6) {
|
|
18
|
-
scroll-margin-top: calc(var(--nav-head-
|
|
18
|
+
scroll-margin-top: calc(var(--nav-head-sticky-offset) + 16px);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.doc-page h2,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export * from '../utils/Emoji/index.js';
|
|
2
2
|
export * from './Link.js';
|
|
3
3
|
export * from './RepoLink.js';
|
|
4
|
-
export * from './P.js';
|
|
5
4
|
export * from './Note.js';
|
|
6
5
|
export * from './ImportMeta.js';
|
|
7
|
-
export * from './HorizontalLine.js';
|
|
8
6
|
export * from './CodeBlockTransformer.js';
|
|
9
|
-
export * from './Comment.js';
|
|
10
7
|
export * from './FileRemoved.js';
|
|
11
8
|
export * from '../code-blocks/components/Tabs.js';
|
package/dist/components/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export * from '../utils/Emoji/index.js';
|
|
2
2
|
export * from './Link.js';
|
|
3
3
|
export * from './RepoLink.js';
|
|
4
|
-
export * from './P.js';
|
|
5
4
|
export * from './Note.js';
|
|
6
5
|
export * from './ImportMeta.js';
|
|
7
|
-
export * from './HorizontalLine.js';
|
|
8
6
|
export * from './CodeBlockTransformer.js';
|
|
9
|
-
export * from './Comment.js';
|
|
10
7
|
export * from './FileRemoved.js';
|
|
11
8
|
export * from '../code-blocks/components/Tabs.js';
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
export { PageContextProvider };
|
|
2
2
|
export { usePageContext };
|
|
3
|
-
export { usePageContextLegacy };
|
|
4
3
|
import React from 'react';
|
|
5
4
|
import type { PageContext } from 'vike/types';
|
|
6
|
-
declare function usePageContextLegacy(): {
|
|
7
|
-
navItemsAll: import("../NavItemComponent.js").NavItem[];
|
|
8
|
-
navItemsDetached: import("../NavItemComponent.js").NavItem[] | undefined;
|
|
9
|
-
pageDesign: {
|
|
10
|
-
hideTitle?: true;
|
|
11
|
-
hideMenuLeft?: true;
|
|
12
|
-
contentMaxWidth?: number;
|
|
13
|
-
} | undefined;
|
|
14
|
-
linksAll: import("../components/Link.js").LinkData[];
|
|
15
|
-
isLandingPage: boolean;
|
|
16
|
-
pageTitle: string | null;
|
|
17
|
-
documentTitle: string;
|
|
18
|
-
activeCategoryName: string;
|
|
19
|
-
choices: import("../code-blocks/utils/resolveChoices.js").ResolvedChoices | undefined;
|
|
20
|
-
};
|
|
21
5
|
declare function usePageContext(): PageContext;
|
|
22
6
|
declare function PageContextProvider({ pageContext, children, }: {
|
|
23
7
|
pageContext: PageContext;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
export { PageContextProvider };
|
|
2
2
|
export { usePageContext };
|
|
3
|
-
export { usePageContextLegacy };
|
|
4
3
|
import React, { useContext } from 'react';
|
|
5
4
|
import { getGlobalObject } from '../utils/getGlobalObject.js';
|
|
6
5
|
const globalObject = getGlobalObject('usePageContext.ts', {
|
|
7
6
|
Ctx: React.createContext(undefined),
|
|
8
7
|
});
|
|
9
|
-
function usePageContextLegacy() {
|
|
10
|
-
const { Ctx } = globalObject;
|
|
11
|
-
const pageContext = useContext(Ctx);
|
|
12
|
-
return pageContext.resolved;
|
|
13
|
-
}
|
|
14
8
|
function usePageContext() {
|
|
15
9
|
const pageContext = useContext(globalObject.Ctx);
|
|
16
10
|
return pageContext;
|
package/dist/types/Heading.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ type PageDesign = {
|
|
|
24
24
|
hideTitle?: true;
|
|
25
25
|
hideMenuLeft?: true;
|
|
26
26
|
contentMaxWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the top navigation sticks to the top of the viewport while scrolling.
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
topNavSticky?: boolean;
|
|
27
33
|
};
|
|
28
34
|
type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
|
|
29
35
|
level: 2;
|
package/dist/utils/server.d.ts
CHANGED
package/dist/utils/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { PageContextProvider }
|
|
2
2
|
export { usePageContext }
|
|
3
|
-
export { usePageContextLegacy }
|
|
4
3
|
|
|
5
4
|
import React, { useContext } from 'react'
|
|
6
5
|
import type { PageContext } from 'vike/types'
|
|
@@ -10,12 +9,6 @@ const globalObject = getGlobalObject('usePageContext.ts', {
|
|
|
10
9
|
Ctx: React.createContext<PageContext>(undefined as any),
|
|
11
10
|
})
|
|
12
11
|
|
|
13
|
-
function usePageContextLegacy() {
|
|
14
|
-
const { Ctx } = globalObject
|
|
15
|
-
const pageContext = useContext(Ctx)
|
|
16
|
-
return pageContext.resolved
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
function usePageContext(): PageContext {
|
|
20
13
|
const pageContext = useContext(globalObject.Ctx)
|
|
21
14
|
return pageContext
|
package/types/Heading.ts
CHANGED
|
@@ -28,6 +28,12 @@ type PageDesign = {
|
|
|
28
28
|
hideTitle?: true
|
|
29
29
|
hideMenuLeft?: true
|
|
30
30
|
contentMaxWidth?: number
|
|
31
|
+
/**
|
|
32
|
+
* Whether the top navigation sticks to the top of the viewport while scrolling.
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
topNavSticky?: boolean
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
|
package/utils/server.ts
CHANGED
package/components/Comment.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { HorizontalLine }
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { cls } from '../utils/cls.js'
|
|
5
|
-
|
|
6
|
-
function HorizontalLine({ primary }: { primary?: true }) {
|
|
7
|
-
return (
|
|
8
|
-
<div className={cls(primary && 'primary')} style={{ textAlign: 'center' }}>
|
|
9
|
-
<hr
|
|
10
|
-
style={{
|
|
11
|
-
display: 'inline-block',
|
|
12
|
-
margin: 0,
|
|
13
|
-
border: 0,
|
|
14
|
-
// Same as `.doc-page h2::after`
|
|
15
|
-
borderTop: '1px solid var(--color-border, rgba(0, 0, 0, 0.1))',
|
|
16
|
-
maxWidth: 500,
|
|
17
|
-
width: '80%',
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
20
|
-
</div>
|
|
21
|
-
)
|
|
22
|
-
}
|
package/components/P.css
DELETED
package/components/P.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { HorizontalLine };
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { cls } from '../utils/cls.js';
|
|
4
|
-
function HorizontalLine({ primary }) {
|
|
5
|
-
return (React.createElement("div", { className: cls(primary && 'primary'), style: { textAlign: 'center' } },
|
|
6
|
-
React.createElement("hr", { style: {
|
|
7
|
-
display: 'inline-block',
|
|
8
|
-
margin: 0,
|
|
9
|
-
border: 0,
|
|
10
|
-
// Same as `.doc-page h2::after`
|
|
11
|
-
borderTop: '1px solid var(--color-border, rgba(0, 0, 0, 0.1))',
|
|
12
|
-
maxWidth: 500,
|
|
13
|
-
width: '80%',
|
|
14
|
-
} })));
|
|
15
|
-
}
|
package/dist/components/P.d.ts
DELETED
package/dist/components/P.js
DELETED
package/dist/utils/cls.d.ts
DELETED
package/dist/utils/cls.js
DELETED
package/dist/utils/filter.d.ts
DELETED
package/dist/utils/filter.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { filter };
|
|
2
|
-
// https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
|
|
3
|
-
function filter(obj, predicate) {
|
|
4
|
-
const result = {};
|
|
5
|
-
Object.keys(obj).forEach((name) => {
|
|
6
|
-
if (predicate(obj[name], name)) {
|
|
7
|
-
result[name] = obj[name];
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
return result;
|
|
11
|
-
}
|
package/utils/PassTrough.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export { toPosixPath }
|
|
2
|
-
export { assertPosixPath }
|
|
3
|
-
export { toSystemPath }
|
|
4
|
-
|
|
5
|
-
import assert from 'assert'
|
|
6
|
-
|
|
7
|
-
const sepPosix = '/'
|
|
8
|
-
const sepWin32 = '\\'
|
|
9
|
-
|
|
10
|
-
function toPosixPath(path: string) {
|
|
11
|
-
if (isPosix()) {
|
|
12
|
-
assertPosixPath(path)
|
|
13
|
-
return path
|
|
14
|
-
}
|
|
15
|
-
if (isWin32()) {
|
|
16
|
-
const pathPosix = path.split(sepWin32).join(sepPosix)
|
|
17
|
-
assertPosixPath(pathPosix)
|
|
18
|
-
return pathPosix
|
|
19
|
-
}
|
|
20
|
-
assert(false)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function assertPosixPath(path: string) {
|
|
24
|
-
assert(path && !path.includes(sepWin32), `Wrongly formatted path: ${path}`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function toSystemPath(path: string) {
|
|
28
|
-
if (isPosix()) {
|
|
29
|
-
return toPosixPath(path)
|
|
30
|
-
}
|
|
31
|
-
if (isWin32()) {
|
|
32
|
-
return path.split(sepPosix).join(sepWin32)
|
|
33
|
-
}
|
|
34
|
-
assert(false)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function isWin32() {
|
|
38
|
-
return process.platform === 'win32'
|
|
39
|
-
}
|
|
40
|
-
function isPosix() {
|
|
41
|
-
return !isWin32()
|
|
42
|
-
}
|
package/utils/filter.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { filter }
|
|
2
|
-
|
|
3
|
-
// https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
|
|
4
|
-
function filter<T extends object>(obj: T, predicate: <K extends keyof T>(value: T[K], key: K) => boolean): T {
|
|
5
|
-
const result: { [K in keyof T]?: T[K] } = {}
|
|
6
|
-
;(Object.keys(obj) as Array<keyof T>).forEach((name) => {
|
|
7
|
-
if (predicate(obj[name], name)) {
|
|
8
|
-
result[name] = obj[name]
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
return result as T
|
|
12
|
-
}
|
package/utils/objectAssign.ts
DELETED