@brillout/docpress 0.15.0 → 0.15.2
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 +41 -28
- package/dist/types/Config.d.ts +3 -2
- package/package.json +1 -1
- package/types/Config.ts +5 -2
package/Layout.tsx
CHANGED
|
@@ -18,7 +18,6 @@ import { autoScrollNav_SSR } from './autoScrollNav'
|
|
|
18
18
|
import { SearchLink } from './docsearch/SearchLink'
|
|
19
19
|
import { navigate } from 'vike/client/router'
|
|
20
20
|
import { css } from './utils/css'
|
|
21
|
-
import { PassThrough } from './utils/PassTrough'
|
|
22
21
|
import { Style } from './utils/Style'
|
|
23
22
|
import { cls } from './utils/cls'
|
|
24
23
|
import { iconBooks } from './icons'
|
|
@@ -282,7 +281,7 @@ const menuLinkStyle: React.CSSProperties = {
|
|
|
282
281
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
283
282
|
const pageContext = usePageContext()
|
|
284
283
|
const { isLandingPage } = pageContext.conf
|
|
285
|
-
const { navMaxWidth, name } = pageContext.globalContext.config.docpress
|
|
284
|
+
const { navMaxWidth, name, algolia } = pageContext.globalContext.config.docpress
|
|
286
285
|
|
|
287
286
|
const navSecondaryContent = (
|
|
288
287
|
<div
|
|
@@ -351,7 +350,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
351
350
|
>
|
|
352
351
|
<NavLogo className="grow-half" />
|
|
353
352
|
{!isNavLeft && <div className="desktop-grow" />}
|
|
354
|
-
<SearchLink className="grow-half" style={menuLinkStyle} />
|
|
353
|
+
{algolia && <SearchLink className="grow-half" style={menuLinkStyle} />}
|
|
355
354
|
<MenuToggleMain className="grow-full" style={menuLinkStyle} />
|
|
356
355
|
{navSecondaryContent}
|
|
357
356
|
</div>
|
|
@@ -483,8 +482,36 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
483
482
|
|
|
484
483
|
function NavLogo({ className }: { className: string }) {
|
|
485
484
|
const pageContext = usePageContext()
|
|
486
|
-
|
|
487
|
-
const {
|
|
485
|
+
|
|
486
|
+
const { navLogo } = pageContext.globalContext.config.docpress
|
|
487
|
+
let navLogoResolved = navLogo
|
|
488
|
+
if (!navLogoResolved) {
|
|
489
|
+
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
490
|
+
const { name, logo, navLogoStyle, navLogoTextStyle } = pageContext.globalContext.config.docpress
|
|
491
|
+
navLogoResolved = (
|
|
492
|
+
<>
|
|
493
|
+
<img
|
|
494
|
+
src={logo}
|
|
495
|
+
style={{
|
|
496
|
+
height: iconSize,
|
|
497
|
+
width: iconSize,
|
|
498
|
+
...navLogoStyle,
|
|
499
|
+
}}
|
|
500
|
+
onContextMenu={onContextMenu}
|
|
501
|
+
/>
|
|
502
|
+
<span
|
|
503
|
+
style={{
|
|
504
|
+
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
505
|
+
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
506
|
+
...navLogoTextStyle,
|
|
507
|
+
}}
|
|
508
|
+
>
|
|
509
|
+
{name}
|
|
510
|
+
</span>
|
|
511
|
+
</>
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
|
|
488
515
|
return (
|
|
489
516
|
<a
|
|
490
517
|
className={cls(['nav-logo', className])}
|
|
@@ -495,32 +522,18 @@ function NavLogo({ className }: { className: string }) {
|
|
|
495
522
|
color: 'inherit',
|
|
496
523
|
}}
|
|
497
524
|
href="/"
|
|
525
|
+
onContextMenu={!navLogo ? undefined : onContextMenu}
|
|
498
526
|
>
|
|
499
|
-
|
|
500
|
-
src={pageContext.globalContext.config.docpress.logo}
|
|
501
|
-
style={{
|
|
502
|
-
height: iconSize,
|
|
503
|
-
width: iconSize,
|
|
504
|
-
...pageContext.globalContext.config.docpress.navLogoStyle,
|
|
505
|
-
}}
|
|
506
|
-
onContextMenu={(ev) => {
|
|
507
|
-
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
508
|
-
if (window.location.pathname === '/press') return
|
|
509
|
-
ev.preventDefault()
|
|
510
|
-
navigate('/press#logo')
|
|
511
|
-
}}
|
|
512
|
-
/>
|
|
513
|
-
<span
|
|
514
|
-
style={{
|
|
515
|
-
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
516
|
-
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
517
|
-
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
518
|
-
}}
|
|
519
|
-
>
|
|
520
|
-
{name}
|
|
521
|
-
</span>
|
|
527
|
+
{navLogoResolved}
|
|
522
528
|
</a>
|
|
523
529
|
)
|
|
530
|
+
|
|
531
|
+
function onContextMenu(ev: React.MouseEvent<unknown, MouseEvent>) {
|
|
532
|
+
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
533
|
+
if (window.location.pathname === '/press') return
|
|
534
|
+
ev.preventDefault()
|
|
535
|
+
navigate('/press#logo')
|
|
536
|
+
}
|
|
524
537
|
}
|
|
525
538
|
function isProjectNameShort(name: string) {
|
|
526
539
|
return name.length <= 4
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -24,12 +24,13 @@ type Config = {
|
|
|
24
24
|
i18n?: true;
|
|
25
25
|
pressKit?: true;
|
|
26
26
|
docsDir?: string;
|
|
27
|
-
globalNote?: React.ReactNode;
|
|
28
|
-
topNavigation?: React.ReactNode;
|
|
29
27
|
navMaxWidth?: number;
|
|
28
|
+
topNavigation?: React.ReactNode;
|
|
29
|
+
navLogo?: React.ReactNode;
|
|
30
30
|
navLogoSize?: number;
|
|
31
31
|
navLogoStyle?: React.CSSProperties;
|
|
32
32
|
navLogoTextStyle?: React.CSSProperties;
|
|
33
|
+
globalNote?: React.ReactNode;
|
|
33
34
|
};
|
|
34
35
|
/** Order in Algolia search results */
|
|
35
36
|
type Category = string | {
|
package/package.json
CHANGED
package/types/Config.ts
CHANGED
|
@@ -30,13 +30,16 @@ type Config = {
|
|
|
30
30
|
i18n?: true
|
|
31
31
|
pressKit?: true
|
|
32
32
|
docsDir?: string
|
|
33
|
+
navMaxWidth?: number
|
|
33
34
|
|
|
34
|
-
globalNote?: React.ReactNode
|
|
35
35
|
topNavigation?: React.ReactNode
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
navLogo?: React.ReactNode
|
|
37
38
|
navLogoSize?: number
|
|
38
39
|
navLogoStyle?: React.CSSProperties
|
|
39
40
|
navLogoTextStyle?: React.CSSProperties
|
|
41
|
+
|
|
42
|
+
globalNote?: React.ReactNode
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/** Order in Algolia search results */
|