@brillout/docpress 0.6.21-commit-f22016e → 0.6.21-commit-d3557c8

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.
@@ -214,15 +214,6 @@ function getHeadingsResolved(config: {
214
214
  const headingsWithoutBreadcrumb: Omit<HeadingResolved, 'linkBreadcrumb'>[] = config.headings.map(
215
215
  (heading: HeadingDefinition) => {
216
216
  const titleInNav = heading.titleInNav || heading.title
217
- /* TODO: remove this and all realted code
218
- let titleInNavParsed: JSX.Element
219
- titleInNavParsed = parseTitle(titleInNav)
220
- if ('titleEmoji' in heading) {
221
- assert(heading.titleEmoji)
222
- titleInNavParsed = withEmoji(heading.titleEmoji, titleInNavParsed)
223
- }
224
- */
225
-
226
217
  const headingResolved: Omit<HeadingResolved, 'linkBreadcrumb'> = {
227
218
  ...heading,
228
219
  titleInNav,
@@ -175,14 +175,6 @@ function getPageSectionsResolved(pageContext, activeHeading) {
175
175
  function getHeadingsResolved(config) {
176
176
  var headingsWithoutBreadcrumb = config.headings.map(function (heading) {
177
177
  var titleInNav = heading.titleInNav || heading.title;
178
- /* TODO: remove this and all realted code
179
- let titleInNavParsed: JSX.Element
180
- titleInNavParsed = parseTitle(titleInNav)
181
- if ('titleEmoji' in heading) {
182
- assert(heading.titleEmoji)
183
- titleInNavParsed = withEmoji(heading.titleEmoji, titleInNavParsed)
184
- }
185
- */
186
178
  var headingResolved = __assign(__assign({}, heading), { titleInNav: titleInNav });
187
179
  return headingResolved;
188
180
  });
@@ -2,7 +2,6 @@ export { HeadingResolved };
2
2
  export { HeadingDetachedResolved };
3
3
  export { HeadingDetachedDefinition };
4
4
  export { HeadingDefinition };
5
- import type { EmojiName } from '../utils/server';
6
5
  type HeadingResolved = {
7
6
  url?: null | string;
8
7
  level: number;
@@ -32,7 +31,6 @@ type IsCategory = {
32
31
  };
33
32
  type HeadingDefinitionLevel = ({
34
33
  level: 1;
35
- titleEmoji: EmojiName;
36
34
  } & IsCategory) | ({
37
35
  level: 4;
38
36
  } & IsCategory) | {
@@ -1,6 +1,5 @@
1
1
  export { initMobileNavigation }
2
-
3
- hideNavigationOnLinkClick()
2
+ export { hideMobileNavigation }
4
3
 
5
4
  function initMobileNavigation() {
6
5
  activateMobileShowNavigationToggle()
@@ -16,27 +15,9 @@ function activateMobileNavigationMask() {
16
15
  navigationMask.onclick = toggleNavigation
17
16
  }
18
17
 
19
- function hideNavigationOnLinkClick() {
20
- document.addEventListener('click', (ev) => {
21
- const linkTag = findLinkTag(ev.target as HTMLElement)
22
- if (!linkTag) return
23
- hideNavigation()
24
- })
25
- }
26
- function findLinkTag(target: HTMLElement): null | HTMLElement {
27
- while (target.tagName !== 'A') {
28
- const { parentNode } = target
29
- if (!parentNode) {
30
- return null
31
- }
32
- target = parentNode as HTMLElement
33
- }
34
- return target
35
- }
36
-
37
18
  function toggleNavigation() {
38
19
  document.body.classList.toggle('mobile-show-navigation')
39
20
  }
40
- function hideNavigation() {
21
+ function hideMobileNavigation() {
41
22
  document.body.classList.remove('mobile-show-navigation')
42
23
  }
@@ -1,14 +1,12 @@
1
1
  export { initNavigationFullscreen }
2
+ export { hideNavigationFullScreen }
2
3
 
3
4
  import { assert } from '../../utils/client'
4
-
5
5
  let scrollPositionBeforeToggle: number = 0
6
+ initOnce()
6
7
 
7
- function initNavigationFullscreen() {
8
- updateColumnWidth()
8
+ function initOnce() {
9
9
  window.addEventListener('resize', updateColumnWidth, { passive: true })
10
- document.getElementById('navigation-fullscreen-button')!.onclick = toggleNavExpend
11
- document.getElementById('navigation-fullscreen-close')!.onclick = toggleNavExpend
12
10
  document.addEventListener(
13
11
  // We don't use keydown to not interfere with user pressing `<Esc>` for closing the browser's `<Ctrl-F>` search diablog, see https://stackoverflow.com/questions/66595035/how-to-detect-escape-key-if-search-bar-of-browser-is-open
14
12
  'keydown',
@@ -19,6 +17,11 @@ function initNavigationFullscreen() {
19
17
  false,
20
18
  )
21
19
  }
20
+ function initNavigationFullscreen() {
21
+ updateColumnWidth()
22
+ document.getElementById('navigation-fullscreen-button')!.onclick = toggleNavExpend
23
+ document.getElementById('navigation-fullscreen-close')!.onclick = toggleNavExpend
24
+ }
22
25
 
23
26
  function toggleNavExpend() {
24
27
  const navContainer = document.getElementById('navigation-container')!
@@ -29,6 +32,10 @@ function toggleNavExpend() {
29
32
  }
30
33
  scrollPositionBeforeToggle = scrollPos
31
34
  }
35
+ function hideNavigationFullScreen() {
36
+ if (!document.documentElement.classList.contains('navigation-fullscreen')) return
37
+ toggleNavExpend()
38
+ }
32
39
 
33
40
  function updateColumnWidth() {
34
41
  const navMinWidth = 299
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.6.21-commit-f22016e",
3
+ "version": "0.6.21-commit-d3557c8",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "// Build vite.config.ts and +config.ts": "",
@@ -5,14 +5,19 @@ import type { PageContextClient } from 'vike/types'
5
5
  import ReactDOM from 'react-dom/client'
6
6
  import { PageContextResolved } from '../config/resolvePageContext'
7
7
  import { getPageElement } from './getPageElement'
8
- import { initNavigationFullscreen } from '../navigation/navigation-fullscreen/initNavigationFullscreen'
9
- import { initMobileNavigation } from '../navigation/initMobileNavigation'
8
+ import {
9
+ hideNavigationFullScreen,
10
+ initNavigationFullscreen,
11
+ } from '../navigation/navigation-fullscreen/initNavigationFullscreen'
12
+ import { hideMobileNavigation, initMobileNavigation } from '../navigation/initMobileNavigation'
10
13
  import { initPressKit } from '../navigation/initPressKit'
11
14
  import '../css/index.css'
12
15
  import { autoScrollNav } from '../autoScrollNav'
13
16
  import { installSectionUrlHashs } from '../installSectionUrlHashs'
14
17
  import { addFeatureClickHandlers, addTwitterWidgets } from '../components/FeatureList/FeatureList.client'
15
18
 
19
+ initOnLinkClick()
20
+
16
21
  let root: ReactDOM.Root
17
22
  function onRenderClient(pageContext: PageContextClient) {
18
23
  const pageContextResolved: PageContextResolved = (pageContext as any).pageContextResolved
@@ -45,6 +50,26 @@ function OnRenderDoneHook({ children }: { children: React.ReactNode }) {
45
50
  return children
46
51
  }
47
52
 
53
+ function initOnLinkClick() {
54
+ document.addEventListener('click', (ev) => {
55
+ const linkTag = findLinkTag(ev.target as HTMLElement)
56
+ if (!linkTag) return
57
+ hideMobileNavigation()
58
+ hideNavigationFullScreen()
59
+ })
60
+ }
61
+
62
+ function findLinkTag(target: HTMLElement): null | HTMLElement {
63
+ while (target.tagName !== 'A') {
64
+ const { parentNode } = target
65
+ if (!parentNode) {
66
+ return null
67
+ }
68
+ target = parentNode as HTMLElement
69
+ }
70
+ return target
71
+ }
72
+
48
73
  function setHydrationIsFinished() {
49
74
  // Used by:
50
75
  // - https://github.com/vikejs/vike/blob/9d67f3dd4bdfb38c835186b8147251e0e3b06657/docs/.testRun.ts#L22
package/types/Heading.ts CHANGED
@@ -37,7 +37,7 @@ type IsCategory = {
37
37
  titleInNav?: undefined
38
38
  }
39
39
  type HeadingDefinitionLevel =
40
- | ({ level: 1; titleEmoji: EmojiName } & IsCategory)
40
+ | ({ level: 1 } & IsCategory)
41
41
  | ({ level: 4 } & IsCategory)
42
42
  | {
43
43
  level: 2