@brillout/docpress 0.7.10-commit-d154167 → 0.8.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.
@@ -12,7 +12,7 @@ type NavItem = {
12
12
  menuModalFullWidth?: true;
13
13
  };
14
14
  type NavItemAll = NavItem & {
15
- columnLayoutEntry?: true;
15
+ columnLayoutElement?: true;
16
16
  };
17
17
  declare function NavigationContent(props: {
18
18
  navItems: NavItem[];
@@ -28,7 +28,7 @@ function NavigationContent(props) {
28
28
  }
29
29
  else {
30
30
  assert(!props.showOnlyRelevant);
31
- var navItemsColumnLayout = groupByColumns(navItemsWithComputed);
31
+ var navItemsColumnLayout = groupByColumnLayout(navItemsWithComputed);
32
32
  var paddingBottom_1 = 40;
33
33
  navContent = (React.createElement(React.Fragment, null, navItemsColumnLayout.map(function (_a, i) {
34
34
  var navItemsColumnEntries = _a.navItemsColumnEntries, isFullWidth = _a.isFullWidth;
@@ -40,7 +40,7 @@ function NavigationContent(props) {
40
40
  flexGrow: 1,
41
41
  columnGap: 20,
42
42
  paddingBottom: isFullWidth ? paddingBottom_1 : undefined,
43
- } }, navItemsColumnEntries.map(function (navItemColumnEntry, k) { return (React.createElement("div", { key: k, className: "column-layout-entry", style: {
43
+ } }, navItemsColumnEntries.map(function (navItemColumnEntry, j) { return (React.createElement("div", { key: j, className: "column-layout-entry", style: {
44
44
  breakInside: 'avoid',
45
45
  paddingBottom: !isFullWidth ? paddingBottom_1 : undefined,
46
46
  width: '100%',
@@ -80,7 +80,7 @@ function NavItemComponent(_a) {
80
80
  .filter(Boolean)
81
81
  .join(' '), href: (_b = navItem.url) !== null && _b !== void 0 ? _b : undefined }, titleInNavJsx));
82
82
  }
83
- function groupByColumns(navItems) {
83
+ function groupByColumnLayout(navItems) {
84
84
  var navItemsColumnLayout = [];
85
85
  var navItemsColumnEntries = [];
86
86
  var isFullWidth;
@@ -94,7 +94,7 @@ function groupByColumns(navItems) {
94
94
  }
95
95
  }
96
96
  assert(isFullWidth !== undefined);
97
- if (navItem.columnLayoutEntry) {
97
+ if (navItem.columnLayoutElement) {
98
98
  assert(navItem.level === 1 || navItem.level === 4);
99
99
  var navItemColumnEntry = __assign(__assign({}, navItem), { navItemChilds: [] });
100
100
  navItemsColumnEntries.push(navItemColumnEntry);
@@ -36,6 +36,7 @@ function determineColumnLayoutEntries(navItems) {
36
36
  navItemsWithLength.forEach(function (navItem) {
37
37
  if (navItem.level === 1) {
38
38
  navItemLevel1 = navItem;
39
+ navItemLevel4 = undefined;
39
40
  return;
40
41
  }
41
42
  if (navItem.level === 4) {
@@ -43,7 +44,7 @@ function determineColumnLayoutEntries(navItems) {
43
44
  return;
44
45
  }
45
46
  var bumpNavItemLength = function (navItem) {
46
- assert(navItem.numberOfHeadings !== null && navItem.numberOfHeadings >= 0);
47
+ assert(navItem.numberOfHeadings !== null);
47
48
  navItem.numberOfHeadings++;
48
49
  };
49
50
  assert(navItemLevel1);
@@ -67,12 +68,18 @@ function determineColumnLayoutEntries(navItems) {
67
68
  columns = [];
68
69
  }
69
70
  }
70
- if ((!isFullWidth && navItem.level === 1) ||
71
- (isFullWidth && navItem.level === 4 && navItemsWithLength[i - 1].level !== 1) ||
72
- isFullWidthBegin) {
71
+ if (!isFullWidth
72
+ ? navItem.level === 1
73
+ : (navItem.level === 4 && navItemsWithLength[i - 1].level !== 1) || isFullWidthBegin) {
74
+ if (isFullWidth) {
75
+ assert(navItem.level === 4 || (navItem.level === 1 && isFullWidthBegin));
76
+ }
77
+ else {
78
+ assert(navItem.level === 1);
79
+ }
73
80
  assert(navItem.numberOfHeadings !== null);
74
81
  columns.push(navItem.numberOfHeadings);
75
- navItems[i].columnLayoutEntry = true;
82
+ navItems[i].columnLayoutElement = true;
76
83
  }
77
84
  });
78
85
  columnLayouts.push(columns);
@@ -1,7 +1,7 @@
1
1
  export { SearchLink }
2
2
 
3
3
  import React from 'react'
4
- import { openDocsearchModal } from './closeDocsearchModal'
4
+ import { openDocsearchModal } from './toggleDocsearchModal'
5
5
 
6
6
  type PropsDiv = React.HTMLProps<HTMLDivElement>
7
7
  function SearchLink(props: PropsDiv) {
@@ -1,6 +1,6 @@
1
1
  export { initKeyBindings }
2
2
 
3
- import { closeDocsearchModal } from './docsearch/closeDocsearchModal'
3
+ import { closeDocsearchModal } from './docsearch/toggleDocsearchModal'
4
4
  import { closeMenuModal, toggleMenuModal } from './MenuModal'
5
5
 
6
6
  function initKeyBindings() {
@@ -19,7 +19,7 @@ type NavItem = {
19
19
  menuModalFullWidth?: true
20
20
  }
21
21
  type NavItemAll = NavItem & {
22
- columnLayoutEntry?: true
22
+ columnLayoutElement?: true
23
23
  }
24
24
  function NavigationContent(props: {
25
25
  navItems: NavItem[]
@@ -36,7 +36,7 @@ function NavigationContent(props: {
36
36
  .map((navItem, i) => <NavItemComponent navItem={navItem} key={i} />)
37
37
  } else {
38
38
  assert(!props.showOnlyRelevant)
39
- const navItemsColumnLayout = groupByColumns(navItemsWithComputed)
39
+ const navItemsColumnLayout = groupByColumnLayout(navItemsWithComputed)
40
40
  const paddingBottom = 40
41
41
  navContent = (
42
42
  <>
@@ -56,9 +56,9 @@ function NavigationContent(props: {
56
56
  paddingBottom: isFullWidth ? paddingBottom : undefined,
57
57
  }}
58
58
  >
59
- {navItemsColumnEntries.map((navItemColumnEntry, k) => (
59
+ {navItemsColumnEntries.map((navItemColumnEntry, j) => (
60
60
  <div
61
- key={k}
61
+ key={j}
62
62
  className="column-layout-entry"
63
63
  style={{
64
64
  breakInside: 'avoid',
@@ -129,7 +129,7 @@ function NavItemComponent({
129
129
  }
130
130
 
131
131
  type NavItemsColumnEntry = NavItemComputed & { navItemChilds: NavItemComputed[] }
132
- function groupByColumns(navItems: NavItemComputed[]) {
132
+ function groupByColumnLayout(navItems: NavItemComputed[]) {
133
133
  const navItemsColumnLayout: { navItemsColumnEntries: NavItemsColumnEntry[]; isFullWidth: boolean }[] = []
134
134
  let navItemsColumnEntries: NavItemsColumnEntry[] = []
135
135
  let isFullWidth: boolean | undefined
@@ -143,7 +143,7 @@ function groupByColumns(navItems: NavItemComputed[]) {
143
143
  }
144
144
  }
145
145
  assert(isFullWidth !== undefined)
146
- if (navItem.columnLayoutEntry) {
146
+ if (navItem.columnLayoutElement) {
147
147
  assert(navItem.level === 1 || navItem.level === 4)
148
148
  const navItemColumnEntry = { ...navItem, navItemChilds: [] }
149
149
  navItemsColumnEntries.push(navItemColumnEntry)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.7.10-commit-d154167",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -18,7 +18,7 @@ const columnWidthMin = 300
18
18
  const columnWidthMax = 350
19
19
 
20
20
  type NavItemWithLength = NavItemAll & { numberOfHeadings: number | null }
21
- function determineColumnLayoutEntries(navItems: NavItemAll[]) {
21
+ function determineColumnLayoutEntries(navItems: NavItemAll[]): { columnLayouts: number[][] } {
22
22
  const navItemsWithLength: NavItemWithLength[] = navItems.map((navItem) => ({
23
23
  ...navItem,
24
24
  numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null,
@@ -28,6 +28,7 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]) {
28
28
  navItemsWithLength.forEach((navItem) => {
29
29
  if (navItem.level === 1) {
30
30
  navItemLevel1 = navItem
31
+ navItemLevel4 = undefined
31
32
  return
32
33
  }
33
34
  if (navItem.level === 4) {
@@ -35,7 +36,7 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]) {
35
36
  return
36
37
  }
37
38
  const bumpNavItemLength = (navItem: NavItemWithLength) => {
38
- assert(navItem.numberOfHeadings !== null && navItem.numberOfHeadings >= 0)
39
+ assert(navItem.numberOfHeadings !== null)
39
40
  navItem.numberOfHeadings++
40
41
  }
41
42
  assert(navItemLevel1)
@@ -60,13 +61,18 @@ function determineColumnLayoutEntries(navItems: NavItemAll[]) {
60
61
  }
61
62
  }
62
63
  if (
63
- (!isFullWidth && navItem.level === 1) ||
64
- (isFullWidth && navItem.level === 4 && navItemsWithLength[i - 1]!.level !== 1) ||
65
- isFullWidthBegin
64
+ !isFullWidth
65
+ ? navItem.level === 1
66
+ : (navItem.level === 4 && navItemsWithLength[i - 1]!.level !== 1) || isFullWidthBegin
66
67
  ) {
68
+ if (isFullWidth) {
69
+ assert(navItem.level === 4 || (navItem.level === 1 && isFullWidthBegin))
70
+ } else {
71
+ assert(navItem.level === 1)
72
+ }
67
73
  assert(navItem.numberOfHeadings !== null)
68
74
  columns.push(navItem.numberOfHeadings)
69
- navItems[i].columnLayoutEntry = true
75
+ navItems[i].columnLayoutElement = true
70
76
  }
71
77
  })
72
78
  columnLayouts.push(columns)
@@ -10,7 +10,6 @@ import '../css/index.css'
10
10
  import { autoScrollNav } from '../autoScrollNav'
11
11
  import { installSectionUrlHashs } from '../installSectionUrlHashs'
12
12
  import { getGlobalObject } from '../utils/client'
13
- import { setpageContextCurrent } from './getPageContextCurrent'
14
13
  import { initKeyBindings } from '../initKeyBindings'
15
14
 
16
15
  const globalObject = getGlobalObject<{
@@ -22,8 +21,6 @@ addEcosystemStamp()
22
21
  initKeyBindings()
23
22
 
24
23
  async function onRenderClient(pageContext: PageContextClient) {
25
- setpageContextCurrent(pageContext)
26
-
27
24
  onRenderStart()
28
25
 
29
26
  // TODO: stop using any
@@ -1,16 +0,0 @@
1
- export { getpageContextCurrent }
2
- export { setpageContextCurrent }
3
-
4
- import { PageContextClient } from 'vike/types'
5
- import { getGlobalObject } from '../utils/getGlobalObject'
6
-
7
- const globalObject = getGlobalObject<{
8
- pageContextCurrent?: PageContextClient
9
- }>('onRenderClient.ts', {})
10
-
11
- function getpageContextCurrent(): undefined | PageContextClient {
12
- return globalObject.pageContextCurrent
13
- }
14
- function setpageContextCurrent(pageContext: PageContextClient): void {
15
- globalObject.pageContextCurrent = pageContext
16
- }