@brillout/docpress 0.6.21-commit-74553e7 → 0.6.21-commit-f22016e

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/+config.ts CHANGED
@@ -12,7 +12,7 @@ export default {
12
12
  passToClient: ['pageContextResolved'],
13
13
  meta: {
14
14
  NavHeader: {
15
- env: { client: true, server: true }
15
+ env: { client: true, server: true },
16
16
  },
17
17
  },
18
18
  } satisfies Config
package/dist/+config.js CHANGED
@@ -9,7 +9,7 @@ export default {
9
9
  passToClient: ['pageContextResolved'],
10
10
  meta: {
11
11
  NavHeader: {
12
- env: { client: true, server: true }
12
+ env: { client: true, server: true },
13
13
  },
14
14
  },
15
15
  };
@@ -22,11 +22,12 @@ function Navigation(_a) {
22
22
  return (React.createElement(React.Fragment, null,
23
23
  React.createElement("div", { id: "navigation-container" },
24
24
  React.createElement(NavigationHeader, null),
25
- isDetachedPage && (React.createElement(React.Fragment, null,
26
- navItems.length > 1 && (React.createElement(NavigationContent, { id: "navigation-content-detached", navItems: navItems, currentUrl: currentUrl })),
27
- React.createElement(DetachedPageNote, null))),
28
- React.createElement(NavigationContent, { id: "navigation-content-main", navItems: navItemsAll, currentUrl: currentUrl }),
29
- React.createElement(NavigationFullscreenClose, null))));
25
+ React.createElement("div", { id: "navigation-body" },
26
+ isDetachedPage && (React.createElement(React.Fragment, null,
27
+ navItems.length > 1 && (React.createElement(NavigationContent, { id: "navigation-content-detached", navItems: navItems, currentUrl: currentUrl })),
28
+ React.createElement(DetachedPageNote, null))),
29
+ React.createElement(NavigationContent, { id: "navigation-content-main", navItems: navItemsAll, currentUrl: currentUrl }),
30
+ React.createElement(NavigationFullscreenClose, null)))));
30
31
  }
31
32
  function NavigationMask() {
32
33
  return React.createElement("div", { id: "mobile-navigation-mask" });
@@ -5,7 +5,6 @@ import { parsePageSections } from './parsePageSections.js';
5
5
  import rehypePrettyCode from 'rehype-pretty-code';
6
6
  import remarkGfm from 'remark-gfm';
7
7
  import { transformerNotationDiff } from '@shikijs/transformers';
8
- import { cjsInterop } from 'vite-plugin-cjs-interop';
9
8
  var root = process.cwd();
10
9
  var prettyCode = [rehypePrettyCode, { theme: 'github-light', transformers: [transformerNotationDiff()] }];
11
10
  var rehypePlugins = [prettyCode];
@@ -23,15 +22,13 @@ var config = {
23
22
  },
24
23
  includeAssetsImportedByServer: true,
25
24
  }),
26
- cjsInterop({
27
- dependencies: ['@docsearch/react'],
28
- }),
29
25
  ],
30
26
  optimizeDeps: {
31
- include: ['react-dom/client', '@docsearch/react'],
27
+ include: ['react', 'react-dom', 'react-dom/client', '@docsearch/react', 'vike-contributors'],
28
+ exclude: ['@brillout/docpress'],
32
29
  },
33
30
  ssr: {
34
- noExternal: ['@brillout/docpress'],
31
+ noExternal: ['@brillout/docpress', '@docsearch/react'],
35
32
  },
36
33
  clearScreen: false,
37
34
  };
@@ -26,7 +26,7 @@ function installSectionUrlHashs() {
26
26
  }
27
27
 
28
28
  function assertNavLink(urlHash: string, heading: HTMLHeadingElement) {
29
- const navigationEl = getNavigationEl()
29
+ const navigationEl = document.querySelector('#navigation-body')!
30
30
  {
31
31
  const { pathname } = window.location
32
32
  const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${pathname}"]`))
@@ -53,10 +53,3 @@ function jumpToSection() {
53
53
  }
54
54
  target.scrollIntoView()
55
55
  }
56
-
57
- function getNavigationEl() {
58
- const elems: HTMLElement[] = Array.from(document.querySelectorAll('#navigation-container'))
59
- assert(elems.length === 1)
60
- const navigationEl = elems[0]!
61
- return navigationEl
62
- }
@@ -27,17 +27,19 @@ function Navigation({
27
27
  <>
28
28
  <div id="navigation-container">
29
29
  <NavigationHeader />
30
- {isDetachedPage && (
31
- <>
32
- {navItems.length > 1 && (
33
- <NavigationContent id="navigation-content-detached" navItems={navItems} currentUrl={currentUrl} />
34
- )}
35
- <DetachedPageNote />
36
- </>
37
- )}
38
- <NavigationContent id="navigation-content-main" navItems={navItemsAll} currentUrl={currentUrl} />
39
- {/* <ScrollOverlay /> */}
40
- <NavigationFullscreenClose />
30
+ <div id="navigation-body">
31
+ {isDetachedPage && (
32
+ <>
33
+ {navItems.length > 1 && (
34
+ <NavigationContent id="navigation-content-detached" navItems={navItems} currentUrl={currentUrl} />
35
+ )}
36
+ <DetachedPageNote />
37
+ </>
38
+ )}
39
+ <NavigationContent id="navigation-content-main" navItems={navItemsAll} currentUrl={currentUrl} />
40
+ {/* <ScrollOverlay /> */}
41
+ <NavigationFullscreenClose />
42
+ </div>
41
43
  </div>
42
44
  </>
43
45
  )
@@ -1,9 +1,10 @@
1
1
  export { initMobileNavigation }
2
2
 
3
+ hideNavigationOnLinkClick()
4
+
3
5
  function initMobileNavigation() {
4
6
  activateMobileShowNavigationToggle()
5
7
  activateMobileNavigationMask()
6
- autoHideNavigationOverlayOnLinkClick()
7
8
  }
8
9
 
9
10
  function activateMobileShowNavigationToggle() {
@@ -15,14 +16,23 @@ function activateMobileNavigationMask() {
15
16
  navigationMask.onclick = toggleNavigation
16
17
  }
17
18
 
18
- function autoHideNavigationOverlayOnLinkClick() {
19
- document.addEventListener('click', (ev: any) => {
20
- const el = ev.target
21
- if (!el || !('classList' in el)) return
22
- if (!el.classList.contains('nav-item')) return
19
+ function hideNavigationOnLinkClick() {
20
+ document.addEventListener('click', (ev) => {
21
+ const linkTag = findLinkTag(ev.target as HTMLElement)
22
+ if (!linkTag) return
23
23
  hideNavigation()
24
24
  })
25
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
+ }
26
36
 
27
37
  function toggleNavigation() {
28
38
  document.body.classList.toggle('mobile-show-navigation')
@@ -1,5 +1,7 @@
1
1
  export { initPressKit }
2
2
 
3
+ import { navigate } from 'vike/client/router'
4
+
3
5
  function initPressKit() {
4
6
  // Right click navigation header => show /press
5
7
  navigationHeaderRightClickInterceptor()
@@ -12,6 +14,6 @@ function navigationHeaderRightClickInterceptor() {
12
14
  const navHeaderImg = document.querySelector('#navigation-header-logo img') as HTMLElement
13
15
  navHeaderImg.oncontextmenu = (ev) => {
14
16
  ev.preventDefault()
15
- window.location.href = '/press'
17
+ navigate('/press')
16
18
  }
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.6.21-commit-74553e7",
3
+ "version": "0.6.21-commit-f22016e",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "// Build vite.config.ts and +config.ts": "",
@@ -27,8 +27,7 @@
27
27
  "rehype-pretty-code": "0.13.0",
28
28
  "remark-gfm": "4.0.0",
29
29
  "shiki": "1.2.0",
30
- "vike-contributors": "^0.0.9",
31
- "vite-plugin-cjs-interop": "^2.1.4"
30
+ "vike-contributors": "^0.0.9"
32
31
  },
33
32
  "peerDependencies": {
34
33
  "@types/node": "*",
package/vite.config.ts CHANGED
@@ -6,7 +6,6 @@ import { parsePageSections } from './parsePageSections.js'
6
6
  import rehypePrettyCode from 'rehype-pretty-code'
7
7
  import remarkGfm from 'remark-gfm'
8
8
  import { transformerNotationDiff } from '@shikijs/transformers'
9
- import { cjsInterop } from 'vite-plugin-cjs-interop'
10
9
 
11
10
  const root = process.cwd()
12
11
  const prettyCode = [rehypePrettyCode, { theme: 'github-light', transformers: [transformerNotationDiff()] }]
@@ -26,15 +25,13 @@ const config: UserConfig = {
26
25
  },
27
26
  includeAssetsImportedByServer: true,
28
27
  }),
29
- cjsInterop({
30
- dependencies: ['@docsearch/react'],
31
- }),
32
28
  ],
33
29
  optimizeDeps: {
34
- include: ['react-dom/client', '@docsearch/react'],
30
+ include: ['react', 'react-dom', 'react-dom/client', '@docsearch/react', 'vike-contributors'],
31
+ exclude: ['@brillout/docpress'],
35
32
  },
36
33
  ssr: {
37
- noExternal: ['@brillout/docpress'],
34
+ noExternal: ['@brillout/docpress', '@docsearch/react'],
38
35
  },
39
36
  clearScreen: false,
40
37
  }