@brillout/docpress 0.16.46 → 0.16.47-commit-cd5aa01

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/ExternalLinks.tsx CHANGED
@@ -46,10 +46,11 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
46
46
 
47
47
  function ChangelogButton() {
48
48
  const pageContext = usePageContext()
49
- const { version, github } = pageContext.globalContext.config.docpress
49
+ const { version, github, changelog } = pageContext.globalContext.config.docpress
50
+ const changeLogUrl = typeof changelog === 'string' ? changelog : `${github}/blob/main/CHANGELOG.md`
50
51
  return (
51
52
  <a
52
- href={`${github}/blob/main/CHANGELOG.md`}
53
+ href={changeLogUrl}
53
54
  className="colorize-on-hover"
54
55
  style={{
55
56
  display: 'flex',
@@ -62,7 +63,7 @@ function ChangelogButton() {
62
63
  className="button"
63
64
  style={{
64
65
  background: '#ffffff4f',
65
- fontFamily: 'monospace',
66
+ fontFamily: 'var(--font-mono, monospace)',
66
67
  letterSpacing: -1,
67
68
  display: 'flex',
68
69
  alignItems: 'center',
package/Layout.tsx CHANGED
@@ -94,9 +94,12 @@ function Layout({ children }: { children: React.ReactNode }) {
94
94
  margin: 'auto',
95
95
  }}
96
96
  >
97
- <MenuModal isTopNav={isLandingPage} isNavLeftAlwaysHidden_={isNavLeftAlwaysHidden_} />
98
- <div className={isLandingPage ? '' : 'doc-page'} style={whitespaceBuster1}>
99
- <NavHead />
97
+ <div className={isLandingPage ? 'landing-page' : 'doc-page'} style={whitespaceBuster1}>
98
+ <div style={{ position: isLandingPage ? 'relative' : 'sticky', top: 0, zIndex: 100 }}>
99
+ <NavHead />
100
+ {/* <MenuModal> is inside here because `container-type` on the page wrapper traps `position: fixed` — https://github.com/brillout/docpress/pull/177 */}
101
+ <MenuModal isNavLeftAlwaysHidden_={isNavLeftAlwaysHidden_} />
102
+ </div>
100
103
  {content}
101
104
  </div>
102
105
  {/* Early toggling, to avoid layout jumps */}
@@ -220,10 +223,10 @@ function NavLeft() {
220
223
  <div
221
224
  style={{
222
225
  position: 'sticky',
223
- top: 0,
226
+ // Sit below the sticky top nav
227
+ top: 'var(--nav-head-height)',
224
228
  }}
225
229
  >
226
- <NavHead isNavLeft={true} />
227
230
  <div
228
231
  style={{
229
232
  backgroundColor: 'var(--color-bg-gray)',
@@ -296,29 +299,18 @@ const menuLinkStyle: React.CSSProperties = {
296
299
  justifyContent: 'center',
297
300
  }
298
301
 
299
- // Two <NavHead> instances are rendered:
300
- // - The left-side <NavHead> shown on documentation pages on desktop
301
- // - The top <NavHead> shown otherwise
302
- function NavHead({ isNavLeft }: { isNavLeft?: true }) {
302
+ function NavHead() {
303
303
  const pageContext = usePageContext()
304
304
  const { navMaxWidth, name, algolia } = pageContext.globalContext.config.docpress
305
305
  const hideNavHeadLogo = pageContext.resolved.isLandingPage && !navMaxWidth
306
306
 
307
307
  const navHeadSecondary = (
308
308
  <div
309
- className={cls(['nav-head-secondary', isNavLeft && 'show-on-nav-hover add-transition'])}
309
+ className="nav-head-secondary"
310
310
  style={{
311
311
  padding: 0,
312
312
  display: 'flex',
313
313
  height: '100%',
314
- ...(isNavLeft
315
- ? {
316
- position: 'absolute',
317
- left: '100%',
318
- top: 0,
319
- width: mainViewWidthMax, // guaranteed real estate
320
- }
321
- : {}),
322
314
  }}
323
315
  >
324
316
  {pageContext.globalContext.config.docpress.topNavigation}
@@ -336,26 +328,29 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
336
328
 
337
329
  return (
338
330
  <div
339
- className={cls(['nav-head link-hover-animation', isNavLeft && 'is-nav-left', !!navMaxWidth && 'has-max-width'])}
331
+ className={cls(['nav-head link-hover-animation', !!navMaxWidth && 'has-max-width'])}
340
332
  style={{
341
333
  backgroundColor: 'var(--color-bg-gray)',
342
- borderBottom: 'var(--block-margin) solid var(--color-bg-white)',
343
334
  position: 'relative',
335
+ boxShadow: `0 ${blockMargin}px 0 var(--color-bg-white)`,
344
336
  }}
345
337
  >
346
- {isNavLeft && <NavHeadLeftFullWidthBackground />}
347
338
  <div
348
339
  style={{
349
340
  // DON'T REMOVE this container: it's needed for the `cqw` values
350
341
  container: 'container-nav-head / inline-size',
351
342
  width: '100%',
343
+ // Cap the cqw context so nav-item spacing matches between landing and doc pages.
344
+ maxWidth: bodyMaxWidth,
345
+ margin: '0 auto',
352
346
  }}
353
347
  >
354
348
  <div
355
349
  className="nav-head-content"
356
350
  style={{
357
351
  width: '100%',
358
- maxWidth: navMaxWidth,
352
+ // Top nav spans the doc-page width so its logo lines up with the sidebar (same width on landing).
353
+ maxWidth: bodyMaxWidth,
359
354
  margin: 'auto',
360
355
  height: 'var(--nav-head-height)',
361
356
  fontSize: `min(14.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
@@ -364,7 +359,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
364
359
  justifyContent: 'center',
365
360
  }}
366
361
  >
367
- {!hideNavHeadLogo && <NavHeadLogo isNavLeft={isNavLeft} />}
362
+ {!hideNavHeadLogo && <NavHeadLogo />}
368
363
  <div className="desktop-grow" style={{ display: 'none' }} />
369
364
  {algolia && <SearchLink className="always-shown" style={menuLinkStyle} />}
370
365
  <MenuToggleMain className="always-shown nav-head-menu-toggle" style={menuLinkStyle} />
@@ -380,7 +375,7 @@ function getStyleLayout() {
380
375
  // Mobile
381
376
  style += css`
382
377
  @media(max-width: ${viewMobile}px) {
383
- .nav-head:not(.is-nav-left) {
378
+ .nav-head {
384
379
  .nav-head-menu-toggle {
385
380
  justify-content: flex-end !important;
386
381
  padding-right: var(--main-view-padding) !important;
@@ -397,7 +392,7 @@ function getStyleLayout() {
397
392
  // Mobile + tablet
398
393
  style += css`
399
394
  @media(max-width: ${viewTablet}px) {
400
- .nav-head:not(.is-nav-left) {
395
+ .nav-head {
401
396
  .nav-head-secondary {
402
397
  display: none !important;
403
398
  }
@@ -407,7 +402,7 @@ function getStyleLayout() {
407
402
  // Tablet
408
403
  style += css`
409
404
  @media(max-width: ${viewTablet}px) and (min-width: ${viewMobile + 1}px) {
410
- .nav-head:not(.is-nav-left) {
405
+ .nav-head {
411
406
  .nav-head-content {
412
407
  --icon-text-padding: 8px;
413
408
  --padding-side: 20px;
@@ -418,7 +413,7 @@ function getStyleLayout() {
418
413
  // Desktop small + desktop
419
414
  style += css`
420
415
  @media(min-width: ${viewTablet + 1}px) {
421
- .nav-head:not(.is-nav-left) {
416
+ .nav-head {
422
417
  .nav-head-content {
423
418
  --icon-text-padding: min(8px, 0.5cqw);
424
419
  --padding-side: min(20px, 1.2cqw);
@@ -442,39 +437,6 @@ function getStyleLayout() {
442
437
  // Desktop
443
438
  if (!isNavLeftAlwaysHidden()) {
444
439
  style += css`
445
- @container container-viewport (min-width: ${viewDesktop}px) {
446
- .nav-head:not(.is-nav-left) {
447
- display: none !important;
448
- }
449
- .nav-head.is-nav-left {
450
- .nav-head-content {
451
- --icon-text-padding: min(8px, 7 * (1cqw - 2.5px));
452
- & > :not(.always-shown) {
453
- --padding-side: min(24px, 27 * (1cqw - 2.5px));
454
- }
455
- & > * {
456
- flex-grow: 0.5;
457
- }
458
- & > .nav-head-menu-toggle {
459
- flex-grow: 1;
460
- }
461
- }
462
- }
463
- .show-on-nav-hover {
464
- opacity: 0;
465
- transition-property: opacity;
466
- pointer-events: none;
467
- }
468
- html:not(.unexpand-nav) {
469
- & .nav-head.is-nav-left:hover .show-on-nav-hover,
470
- &:has(.nav-head:hover) #menu-modal-wrapper.show-on-nav-hover,
471
- &.menu-modal-show .nav-head.is-nav-left .show-on-nav-hover,
472
- &.menu-modal-show #menu-modal-wrapper.show-on-nav-hover {
473
- opacity: 1;
474
- pointer-events: all;
475
- }
476
- }
477
- }
478
440
  @container container-viewport (max-width: ${viewDesktop - 1}px) {
479
441
  #nav-left, #nav-left-margin {
480
442
  display: none;
@@ -514,37 +476,7 @@ function unexpandNav() {
514
476
  }, 1000)
515
477
  }
516
478
 
517
- function NavHeadLeftFullWidthBackground() {
518
- return (
519
- <>
520
- <div
521
- className="nav-head-bg show-on-nav-hover add-transition"
522
- style={{
523
- height: '100%',
524
- zIndex: -1,
525
- background: 'var(--color-bg-gray)',
526
- position: 'absolute',
527
- left: 0,
528
- top: 0,
529
- boxSizing: 'content-box',
530
- borderBottom: 'var(--block-margin) solid var(--color-bg-white)',
531
- }}
532
- />
533
- <Style>{
534
- // (min-width: 0px) => trick to always apply => @container seems to always require a condition
535
- css`
536
- @container container-viewport (min-width: 0px) {
537
- .nav-head-bg {
538
- width: 100cqw;
539
- }
540
- }
541
- `
542
- }</Style>
543
- </>
544
- )
545
- }
546
-
547
- function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
479
+ function NavHeadLogo() {
548
480
  const pageContext = usePageContext()
549
481
 
550
482
  const { navLogo } = pageContext.globalContext.config.docpress
@@ -584,14 +516,8 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
584
516
  alignItems: 'center',
585
517
  height: '100%',
586
518
  color: 'inherit',
587
- ...(!isNavLeft
588
- ? {
589
- paddingLeft: 'var(--main-view-padding)',
590
- paddingRight: 'var(--padding-side)',
591
- }
592
- : {
593
- paddingLeft: 15,
594
- }),
519
+ paddingLeft: 'var(--main-view-padding)',
520
+ paddingRight: 'var(--padding-side)',
595
521
  }}
596
522
  href="/"
597
523
  onContextMenu={!navLogo ? undefined : onContextMenu}
package/MenuModal.tsx CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  } from './MenuModal/toggleMenuModal.js'
15
15
  import { EditLink } from './EditLink.js'
16
16
 
17
- function MenuModal({ isTopNav, isNavLeftAlwaysHidden_ }: { isTopNav: boolean; isNavLeftAlwaysHidden_: boolean }) {
17
+ function MenuModal({ isNavLeftAlwaysHidden_ }: { isNavLeftAlwaysHidden_: boolean }) {
18
18
  return (
19
19
  <>
20
20
  <Style>{getStyle()}</Style>
@@ -22,7 +22,8 @@ function MenuModal({ isTopNav, isNavLeftAlwaysHidden_ }: { isTopNav: boolean; is
22
22
  id="menu-modal-wrapper"
23
23
  className="link-hover-animation add-transition show-on-nav-hover"
24
24
  style={{
25
- position: isTopNav ? 'absolute' : 'fixed',
25
+ // Absolute inside the sticky header so the dropdown tracks the nav on scroll
26
+ position: 'absolute',
26
27
  width: '100%',
27
28
  top: 'var(--nav-head-height)',
28
29
  zIndex: 199, // maximum value, because docsearch's modal has `z-index: 200`
@@ -5,6 +5,7 @@ pre > code {
5
5
  */
6
6
  background: rgba(0, 0, 0, 0.043137255);
7
7
  font-size: 1em;
8
+ font-family: var(--font-mono, monospace);
8
9
  }
9
10
 
10
11
  /* Copy button */
package/css/code.css CHANGED
@@ -10,4 +10,5 @@ code {
10
10
  border-radius: 4px;
11
11
  background: rgba(0, 0, 0, 0.063137255);
12
12
  font-size: 1.1em;
13
+ font-family: var(--font-mono, monospace);
13
14
  }
package/css/font.css CHANGED
@@ -1,7 +1,7 @@
1
1
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
2
2
 
3
3
  body {
4
- font-family: 'Inter', sans-serif;
4
+ font-family: var(--font-sans, 'Inter', sans-serif);
5
5
  }
6
6
  button {
7
7
  font-family: inherit;
package/css/heading.css CHANGED
@@ -13,6 +13,11 @@ h3 {
13
13
  margin-bottom: 20px;
14
14
  }
15
15
 
16
+ /* Offset headings below the sticky top nav. */
17
+ .doc-page :is(h1, h2, h3, h4, h5, h6) {
18
+ scroll-margin-top: calc(var(--nav-head-height) + 16px);
19
+ }
20
+
16
21
  .doc-page h2,
17
22
  .doc-page h3 {
18
23
  margin-bottom: 16px;
package/css/tooltip.css CHANGED
@@ -13,7 +13,7 @@
13
13
  opacity: 0;
14
14
  transition: opacity 0.3s ease-in-out;
15
15
  pointer-events: none;
16
- font-family: monospace;
16
+ font-family: var(--font-mono, monospace);
17
17
  font-size: 12px;
18
18
  content: attr(aria-label);
19
19
  position: absolute;
@@ -29,7 +29,7 @@ type Config = {
29
29
  twitter?: string;
30
30
  bluesky?: string;
31
31
  linkedin?: string;
32
- changelog?: boolean;
32
+ changelog?: boolean | string;
33
33
  headings: HeadingDefinition[];
34
34
  headingsDetached: HeadingDetachedDefinition[];
35
35
  categories?: Category[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.16.46",
3
+ "version": "0.16.47-commit-cd5aa01",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -66,10 +66,7 @@
66
66
  "vike": "^0.4.255",
67
67
  "vite": "^8.0.8"
68
68
  },
69
- "repository": {
70
- "type": "git",
71
- "url": "https://github.com/brillout/docpress"
72
- },
69
+ "repository": "https://github.com/brillout/docpress",
73
70
  "license": "MIT",
74
71
  "publishConfig": {
75
72
  "access": "public"
package/types/Config.ts CHANGED
@@ -35,7 +35,7 @@ type Config = {
35
35
  twitter?: string
36
36
  bluesky?: string
37
37
  linkedin?: string
38
- changelog?: boolean
38
+ changelog?: boolean | string
39
39
 
40
40
  headings: HeadingDefinition[]
41
41
  headingsDetached: HeadingDetachedDefinition[]