@brillout/docpress 0.6.8 → 0.6.10

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.
@@ -34,14 +34,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- export { markdownHeadingsVitePlugin };
37
+ export { parsePageSections };
38
38
  import { assert } from './utils/assert.js';
39
39
  import { determineSectionUrlHash } from './utils/determineSectionUrlHash.js';
40
40
  import os from 'os';
41
- function markdownHeadingsVitePlugin() {
41
+ function parsePageSections() {
42
42
  var _this = this;
43
43
  return {
44
- name: 'mdx-headings',
44
+ name: '@brillout/docpress:parsePageSections',
45
45
  enforce: 'pre',
46
46
  transform: function (code, id) { return __awaiter(_this, void 0, void 0, function () {
47
47
  var codeNew;
@@ -52,11 +52,11 @@ function markdownHeadingsVitePlugin() {
52
52
  codeNew = transform(code);
53
53
  return [2 /*return*/, codeNew];
54
54
  });
55
- }); }
55
+ }); },
56
56
  };
57
57
  }
58
58
  function transform(code) {
59
- var headings = [];
59
+ var pageSections = [];
60
60
  var isCodeBlock = false;
61
61
  var codeNew = code
62
62
  .split('\n')
@@ -74,47 +74,44 @@ function transform(code) {
74
74
  return line;
75
75
  }
76
76
  if (line.startsWith('#')) {
77
- var _a = parseMarkdownHeading(line), headingId = _a.headingId, headingLevel = _a.headingLevel, title = _a.title, headingHtml = _a.headingHtml;
78
- headings.push({ headingId: headingId, headingLevel: headingLevel, title: title });
77
+ var _a = parsePageSection(line), pageSectionId = _a.pageSectionId, pageSectionLevel = _a.pageSectionLevel, pageSectionTitle = _a.pageSectionTitle, headingHtml = _a.headingHtml;
78
+ pageSections.push({ pageSectionId: pageSectionId, pageSectionLevel: pageSectionLevel, pageSectionTitle: pageSectionTitle });
79
79
  return headingHtml;
80
80
  }
81
81
  return line;
82
82
  })
83
83
  .join('\n');
84
- var headingsExportCode = "export const headings = [".concat(headings
85
- .map(function (heading) { return JSON.stringify(heading); })
84
+ var exportCode = "export const pageSectionsExport = [".concat(pageSections
85
+ .map(function (pageSection) { return JSON.stringify(pageSection); })
86
86
  .join(', '), "];");
87
- codeNew += "\n\n".concat(headingsExportCode, "\n");
87
+ codeNew += "\n\n".concat(exportCode, "\n");
88
88
  return codeNew;
89
89
  }
90
- function parseMarkdownHeading(line) {
90
+ function parsePageSection(line) {
91
91
  var _a;
92
92
  var _b = line.split(' '), lineBegin = _b[0], lineWords = _b.slice(1);
93
93
  assert(lineBegin.split('#').join('') === '', { line: line, lineWords: lineWords });
94
- var headingLevel = lineBegin.length;
94
+ var pageSectionLevel = lineBegin.length;
95
95
  var titleMdx = lineWords.join(' ');
96
96
  assert(!titleMdx.startsWith(' '), { line: line, lineWords: lineWords });
97
97
  assert(titleMdx, { line: line, lineWords: lineWords });
98
- var headingMdx = {
99
- title: titleMdx,
100
- anchor: titleMdx
101
- };
98
+ var pageSectionTitle = titleMdx;
99
+ var anchor = titleMdx;
102
100
  {
103
- // Support custom anchor like: `## title{#custom-anchor}`
101
+ // Support custom anchor: `## Some Title{#custom-anchor}`
104
102
  var customAnchor = (_a = /(?<={#).*(?=})/g.exec(titleMdx)) === null || _a === void 0 ? void 0 : _a[0];
105
103
  if (customAnchor) {
106
- headingMdx.anchor = customAnchor;
107
- headingMdx.title = titleMdx.replace(/{#.*}/g, '');
104
+ anchor = customAnchor;
105
+ pageSectionTitle = titleMdx.replace(/{#.*}/g, '');
108
106
  }
109
107
  }
110
- var headingId = determineSectionUrlHash(headingMdx.anchor);
111
- var title = headingMdx.title;
112
- var titleParsed = parseTitle(title);
113
- assert(headingId === null || headingId.length > 0);
114
- var headingAttrId = headingId === null ? '' : " id=\"".concat(headingId, "\"");
115
- var headingHtml = "<h".concat(headingLevel).concat(headingAttrId, ">").concat(titleParsed, "</h").concat(headingLevel, ">");
116
- var heading = { headingLevel: headingLevel, title: title, headingId: headingId, headingHtml: headingHtml };
117
- return heading;
108
+ var pageSectionId = determineSectionUrlHash(anchor);
109
+ var titleParsed = parseTitle(pageSectionTitle);
110
+ assert(pageSectionId === null || pageSectionId.length > 0);
111
+ var headingId = pageSectionId === null ? '' : " id=\"".concat(pageSectionId, "\"");
112
+ var headingHtml = "<h".concat(pageSectionLevel).concat(headingId, ">").concat(titleParsed, "</h").concat(pageSectionLevel, ">");
113
+ var pageSection = { pageSectionLevel: pageSectionLevel, pageSectionTitle: pageSectionTitle, pageSectionId: pageSectionId, headingHtml: headingHtml };
114
+ return pageSection;
118
115
  }
119
116
  function parseTitle(titleMarkdown) {
120
117
  var parts = [];
@@ -1,7 +1,7 @@
1
1
  import mdx from '@mdx-js/rollup';
2
2
  import react from '@vitejs/plugin-react-swc';
3
3
  import vike from 'vike/plugin';
4
- import { markdownHeadingsVitePlugin } from './markdownHeadingsVitePlugin.js';
4
+ 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';
@@ -12,22 +12,22 @@ var remarkPlugins = [remarkGfm];
12
12
  var config = {
13
13
  root: root,
14
14
  plugins: [
15
- markdownHeadingsVitePlugin(),
15
+ parsePageSections(),
16
16
  mdx({ rehypePlugins: rehypePlugins, remarkPlugins: remarkPlugins }),
17
17
  // @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
18
18
  react(),
19
19
  vike({
20
20
  prerender: {
21
- noExtraDir: true
21
+ noExtraDir: true,
22
22
  },
23
- includeAssetsImportedByServer: true
23
+ includeAssetsImportedByServer: true,
24
24
  }),
25
25
  ],
26
26
  optimizeDeps: { include: ['@mdx-js/react', 'react-dom'] },
27
27
  // @ts-ignore
28
28
  ssr: {
29
- noExternal: ['@brillout/docpress']
29
+ noExternal: ['@brillout/docpress'],
30
30
  },
31
- clearScreen: false
31
+ clearScreen: false,
32
32
  };
33
33
  export default config;
@@ -27,7 +27,8 @@ function installSectionUrlHashs() {
27
27
  function assertNavLink(urlHash: string, heading: HTMLHeadingElement) {
28
28
  const navigationEl = getNavigationEl()
29
29
  {
30
- const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${window.location.pathname}"]`))
30
+ const { pathname } = window.location
31
+ const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${pathname}"]`))
31
32
  assert(parentNavLinkMatch.length === 1)
32
33
  }
33
34
  {
@@ -8,10 +8,10 @@
8
8
  .nav-item code {
9
9
  font-size: 0.9em;
10
10
  }
11
- .nav-item-h1 + .nav-item-h4 {
11
+ .nav-item-level-1 + .nav-item-level-4 {
12
12
  margin-top: -2px;
13
13
  }
14
- .nav-item-h4 {
14
+ .nav-item-level-4 {
15
15
  margin-top: 14px;
16
16
  margin-bottom: -1px;
17
17
  color: #999;
@@ -22,10 +22,10 @@
22
22
  padding-right: 4px;
23
23
  text-decoration: none;
24
24
  }
25
- .nav-column:first-of-type > .nav-h1-group:first-of-type > .nav-item-h1:first-of-type {
25
+ .nav-column:first-of-type > .nav-items-level-1-group:first-of-type > .nav-item-level-1:first-of-type {
26
26
  margin-top: 20px;
27
27
  }
28
- .nav-item-h1 {
28
+ .nav-item-level-1 {
29
29
  margin-top: 30px;
30
30
  font-size: 15.4px;
31
31
  text-transform: uppercase;
@@ -37,7 +37,7 @@
37
37
  padding-right: 4px;
38
38
  text-decoration: none;
39
39
  }
40
- .nav-item-h2 {
40
+ .nav-item-level-2 {
41
41
  text-decoration: none;
42
42
  font-size: 14.4px;
43
43
  font-weight: 400;
@@ -49,7 +49,7 @@
49
49
  padding-top: var(--padding);
50
50
  padding-bottom: var(--padding);
51
51
  }
52
- .nav-item-h3 {
52
+ .nav-item-level-3 {
53
53
  font-size: 12px;
54
54
  font-weight: 400;
55
55
  letter-spacing: 0.15ch;
@@ -61,28 +61,28 @@
61
61
  padding: var(--padding) 0;
62
62
  padding-left: calc(var(--padding-left-global) + var(--padding-left-additional));
63
63
  }
64
- html.navigation-fullscreen .nav-item-h3 {
64
+ html.navigation-fullscreen .nav-item-level-3 {
65
65
  border-right: 4px solid #eee;
66
66
  }
67
- .nav-item-h3.nav-item-first-of-its-kind {
67
+ .nav-item-level-3.nav-item-first-of-its-kind {
68
68
  padding-top: calc(var(--padding) * 1.6);
69
69
  }
70
- .nav-item-h3.nav-item-last-of-its-kind {
70
+ .nav-item-level-3.nav-item-last-of-its-kind {
71
71
  padding-bottom: calc(var(--padding) * 2);
72
72
  }
73
- .nav-item-h2,
74
- .nav-item-h3 {
73
+ .nav-item-level-2,
74
+ .nav-item-level-3 {
75
75
  position: relative;
76
76
  }
77
77
  /*
78
- .nav-item-h2.is-active .nav-item-text{
78
+ .nav-item-level-2.is-active .nav-item-text{
79
79
  background-color: var(--background-color);
80
80
  }
81
81
  */
82
- .nav-item-h2.is-active {
82
+ .nav-item-level-2.is-active {
83
83
  background-color: var(--background-color);
84
84
  }
85
- .nav-item-h3.is-active:before {
85
+ .nav-item-level-3.is-active:before {
86
86
  display: block;
87
87
  content: '';
88
88
  position: absolute;
@@ -93,7 +93,7 @@ html.navigation-fullscreen .nav-item-h3 {
93
93
  background-color: var(--background-color);
94
94
  z-index: 10;
95
95
  }
96
- .nav-item-h3.is-active-last:after {
96
+ .nav-item-level-3.is-active-last:after {
97
97
  display: block;
98
98
  content: '';
99
99
  position: absolute;
@@ -29,7 +29,7 @@
29
29
  margin-top: 25px;
30
30
  }
31
31
 
32
- #navigation-mask {
32
+ #mobile-navigation-mask {
33
33
  position: fixed;
34
34
  width: 100%;
35
35
  height: 100vh;
@@ -47,7 +47,7 @@
47
47
  height: 100vh;
48
48
  top: 0;
49
49
  }
50
- #navigation-mask {
50
+ #mobile-navigation-mask {
51
51
  display: none;
52
52
  }
53
53
  }
@@ -83,10 +83,10 @@
83
83
  /* `position: sticky` doesn't seem to work on mobile */
84
84
  position: fixed;
85
85
  }
86
- body:not(.show-menu) #navigation-container {
86
+ body:not(.mobile-show-navigation) #navigation-container {
87
87
  transform: translateX(calc(-1 * var(--width)));
88
88
  }
89
- body:not(.show-menu) #navigation-mask {
89
+ body:not(.mobile-show-navigation) #mobile-navigation-mask {
90
90
  display: none;
91
91
  }
92
92
  #mobile-header {
@@ -118,7 +118,7 @@ html.navigation-fullscreen .navigation-content > .nav-column {
118
118
  flex-grow: 1;
119
119
  max-width: 350px;
120
120
  }
121
- html.navigation-fullscreen .nav-column > .nav-h1-group:first-child > .nav-item-h1:first-child {
121
+ html.navigation-fullscreen .nav-column > .nav-items-level-1-group:first-child > .nav-item-level-1:first-child {
122
122
  margin-top: 0px;
123
123
  }
124
124
  html.navigation-fullscreen {
@@ -1,43 +1,7 @@
1
1
  import { initNavigationFullscreen } from './navigation-fullscreen/initNavigationFullscreen'
2
+ import { initMobileNavigation } from './initMobileNavigation'
3
+ import { initPressKit } from './initPressKit'
2
4
 
3
- activateNavigationMask()
4
- activateMenuToggle()
5
5
  initNavigationFullscreen()
6
- autoHideNavigationOverlayOnLinkClick()
7
- navHeaderRightClickInterceptor()
8
-
9
- function activateMenuToggle() {
10
- const menuToggle = document.getElementById('menu-toggle')!
11
- menuToggle.onclick = navigationOverlayToggle
12
- }
13
-
14
- function activateNavigationMask() {
15
- const navigationMask = document.getElementById('navigation-mask')!
16
- navigationMask.onclick = navigationOverlayToggle
17
- }
18
-
19
- function autoHideNavigationOverlayOnLinkClick() {
20
- document.addEventListener('click', (ev: any) => {
21
- const el = ev.target
22
- if (!el || !('classList' in el)) return
23
- if (!el.classList.contains('nav-item')) return
24
- navigationOverlayHide()
25
- })
26
- }
27
-
28
- function navigationOverlayToggle() {
29
- document.body.classList.toggle('show-menu')
30
- }
31
- function navigationOverlayHide() {
32
- document.body.classList.remove('show-menu')
33
- }
34
-
35
- function navHeaderRightClickInterceptor() {
36
- const navHeader = document.getElementById('navigation-header')!
37
- if (!navHeader.classList.contains('press-kit')) return
38
- if (window.location.pathname === '/press') return
39
- navHeader.oncontextmenu = (ev) => {
40
- ev.preventDefault()
41
- window.location.href = '/press'
42
- }
43
- }
6
+ initMobileNavigation()
7
+ initPressKit()
@@ -1,44 +1,40 @@
1
1
  export { Navigation }
2
2
  export { NavigationMask }
3
+ export type { NavigationData }
4
+ export type { NavItem }
3
5
 
4
6
  import React from 'react'
5
7
  import { NavigationHeader } from './NavigationHeader'
6
- import { Heading, HeadingDetached } from '../types/Heading'
7
8
  import { assert, Emoji, assertWarning, jsxToTextContent } from '../utils/server'
8
9
  import './Navigation.css'
9
10
  import { NavigationFullscreenClose } from './navigation-fullscreen/NavigationFullscreenButton'
10
11
 
12
+ type NavigationData = Parameters<typeof Navigation>[0]
13
+
11
14
  function Navigation({
12
- pageContext,
15
+ navItems,
16
+ navItemsAll,
17
+ currentUrl,
18
+ isDetachedPage,
13
19
  }: {
14
- pageContext: {
15
- headingsProcessed: Heading[]
16
- headingsOfDetachedPage: null | (Heading | HeadingDetached)[]
17
- urlPathname: string
18
- }
20
+ navItems: NavItem[]
21
+ navItemsAll: NavItem[]
22
+ currentUrl: string
23
+ isDetachedPage: boolean
19
24
  }) {
20
- const currentUrl = pageContext.urlPathname
21
25
  return (
22
26
  <>
23
27
  <div id="navigation-container">
24
28
  <NavigationHeader />
25
- {pageContext.headingsOfDetachedPage && (
29
+ {isDetachedPage && (
26
30
  <>
27
- {pageContext.headingsOfDetachedPage.length > 1 && (
28
- <NavigationContent
29
- id="navigation-content-detached"
30
- headingsProcessed={pageContext.headingsOfDetachedPage}
31
- currentUrl={currentUrl}
32
- />
31
+ {navItems.length > 1 && (
32
+ <NavigationContent id="navigation-content-detached" navItems={navItems} currentUrl={currentUrl} />
33
33
  )}
34
34
  <DetachedPageNote />
35
35
  </>
36
36
  )}
37
- <NavigationContent
38
- id="navigation-content-main"
39
- headingsProcessed={pageContext.headingsProcessed}
40
- currentUrl={currentUrl}
41
- />
37
+ <NavigationContent id="navigation-content-main" navItems={navItemsAll} currentUrl={currentUrl} />
42
38
  {/* <ScrollOverlay /> */}
43
39
  <NavigationFullscreenClose />
44
40
  </div>
@@ -47,26 +43,39 @@ function Navigation({
47
43
  }
48
44
 
49
45
  function NavigationMask() {
50
- return <div id="navigation-mask" />
46
+ return <div id="mobile-navigation-mask" />
47
+ }
48
+
49
+ type NavItem = {
50
+ level: number
51
+ url?: string | null
52
+ title: string | JSX.Element
53
+ titleInNav: string | JSX.Element
54
+ }
55
+ type NavItemComputed = NavItem & {
56
+ isActive: boolean
57
+ isActiveFirst: boolean
58
+ isActiveLast: boolean
59
+ isFirstOfItsKind: boolean
60
+ isLastOfItsKind: boolean
51
61
  }
52
62
 
53
63
  function NavigationContent(props: {
54
64
  id: 'navigation-content-main' | 'navigation-content-detached'
55
- headingsProcessed: (Heading | HeadingDetached)[]
65
+ navItems: NavItem[]
56
66
  currentUrl: string
57
67
  }) {
58
- const headings = getHeadingsWithComputedProps(props.headingsProcessed, props.currentUrl)
59
-
60
- const headingsGrouped = groupHeadings(headings)
68
+ const navItemsWithComputed = addComputedProps(props.navItems, props.currentUrl)
69
+ const navItemsGrouped = groupByLevel1(navItemsWithComputed)
61
70
 
62
71
  return (
63
72
  <div id={props.id} className="navigation-content">
64
73
  <div className="nav-column" style={{ position: 'relative' }}>
65
- {headingsGrouped.map((headingsH1, i) => (
66
- <div className="nav-h1-group" key={i}>
67
- <Heading heading={headingsH1} />
68
- {headingsH1.headings.map((heading, j) => (
69
- <Heading heading={heading} key={j} />
74
+ {navItemsGrouped.map((navItemLevel1, i) => (
75
+ <div className="nav-items-level-1-group" key={i}>
76
+ <NavItemComponent navItem={navItemLevel1} />
77
+ {navItemLevel1.navItemChilds.map((navItem, j) => (
78
+ <NavItemComponent navItem={navItem} key={j} />
70
79
  ))}
71
80
  </div>
72
81
  ))}
@@ -75,32 +84,20 @@ function NavigationContent(props: {
75
84
  )
76
85
  }
77
86
 
78
- function Heading({
79
- heading,
87
+ function NavItemComponent({
88
+ navItem,
80
89
  }: {
81
- heading: {
82
- level: number
83
- url?: string | null
84
- title: string | JSX.Element
85
- titleInNav: string | JSX.Element
86
- computed: {
87
- isActive: boolean
88
- isActiveFirst: boolean
89
- isActiveLast: boolean
90
- isFirstOfItsKind: boolean
91
- isLastOfItsKind: boolean
92
- }
93
- }
90
+ navItem: NavItemComputed
94
91
  }) {
95
- assert([1, 2, 3, 4].includes(heading.level), heading)
96
- if (heading.level === 1 || heading.level === 4) {
97
- assert(heading.url === undefined)
92
+ assert([1, 2, 3, 4].includes(navItem.level), navItem)
93
+ if (navItem.level === 1 || navItem.level === 4) {
94
+ assert(navItem.url === undefined)
98
95
  } else {
99
- const sectionTitle = jsxToTextContent(heading.title)
96
+ const sectionTitle = jsxToTextContent(navItem.title)
100
97
  assertWarning(
101
- heading.url,
98
+ navItem.url,
102
99
  `${jsxToTextContent(
103
- heading.titleInNav,
100
+ navItem.titleInNav,
104
101
  )} is missing a URL hash. Use \`<h2 id="url-hash">${sectionTitle}</h2>\` instead of \`## ${sectionTitle}\`.`,
105
102
  )
106
103
  }
@@ -108,73 +105,71 @@ function Heading({
108
105
  <a
109
106
  className={[
110
107
  'nav-item',
111
- 'nav-item-h' + heading.level,
112
- heading.computed.isActive && ' is-active',
113
- heading.computed.isActiveFirst && ' is-active-first',
114
- heading.computed.isActiveLast && ' is-active-last',
115
- heading.computed.isFirstOfItsKind && 'nav-item-first-of-its-kind',
116
- heading.computed.isLastOfItsKind && 'nav-item-last-of-its-kind',
108
+ 'nav-item-level-' + navItem.level,
109
+ navItem.isActive && ' is-active',
110
+ navItem.isActiveFirst && ' is-active-first',
111
+ navItem.isActiveLast && ' is-active-last',
112
+ navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
113
+ navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
117
114
  ]
118
115
  .filter(Boolean)
119
116
  .join(' ')}
120
- href={heading.url ?? undefined}
117
+ href={navItem.url ?? undefined}
121
118
  >
122
- {/* <span className="nav-item-text">{heading.titleInNav}</span> */}
123
- {heading.titleInNav}
119
+ {/* <span className="nav-item-text">{navItem.titleInNav}</span> */}
120
+ {navItem.titleInNav}
124
121
  </a>
125
122
  )
126
123
  }
127
124
 
128
- function groupHeadings<T extends { level: number }>(headings: T[]) {
129
- const headingsGrouped: (T & { headings: T[] })[] = []
130
- const headingLevelMin: number = Math.min(...headings.map((h) => h.level))
131
- headings.forEach((heading) => {
132
- if (heading.level === headingLevelMin) {
133
- headingsGrouped.push({ ...heading, headings: [] })
125
+ function groupByLevel1<T extends { level: number }>(navItems: T[]) {
126
+ const navItemsGrouped: (T & { navItemChilds: T[] })[] = []
127
+ const levelMin: number = Math.min(...navItems.map((h) => h.level))
128
+ navItems.forEach((navItem) => {
129
+ if (navItem.level === levelMin) {
130
+ navItemsGrouped.push({ ...navItem, navItemChilds: [] })
134
131
  } else {
135
- headingsGrouped[headingsGrouped.length - 1].headings.push(heading)
132
+ navItemsGrouped[navItemsGrouped.length - 1].navItemChilds.push(navItem)
136
133
  }
137
134
  })
138
- return headingsGrouped
135
+ return navItemsGrouped
139
136
  }
140
137
 
141
- function getHeadingsWithComputedProps(headings: (Heading | HeadingDetached)[], currentUrl: string) {
142
- return headings.map((heading, i) => {
143
- assert([1, 2, 3, 4].includes(heading.level), heading)
138
+ function addComputedProps(navItems: NavItem[], currentUrl: string): NavItemComputed[] {
139
+ return navItems.map((navItem, i) => {
140
+ assert([1, 2, 3, 4].includes(navItem.level), navItem)
144
141
 
145
- const headingPrevious = headings[i - 1]
146
- const headingNext = headings[i + 1]
142
+ const navItemPrevious = navItems[i - 1]
143
+ const navItemNext = navItems[i + 1]
147
144
 
148
145
  let isActiveFirst = false
149
146
  let isActiveLast = false
150
147
  let isActive = false
151
- if (heading.url === currentUrl) {
152
- assert(heading.level === 2, { currentUrl })
148
+ if (navItem.url === currentUrl) {
149
+ assert(navItem.level === 2, { currentUrl })
153
150
  isActive = true
154
151
  isActiveFirst = true
155
- if (headingNext?.level !== 3) {
152
+ if (navItemNext?.level !== 3) {
156
153
  isActiveLast = true
157
154
  }
158
155
  }
159
- if (heading.level === 3) {
156
+ if (navItem.level === 3) {
160
157
  isActive = true
161
- if (headingNext?.level !== 3) {
158
+ if (navItemNext?.level !== 3) {
162
159
  isActiveLast = true
163
160
  }
164
161
  }
165
162
 
166
- const isFirstOfItsKind = heading.level !== headingPrevious?.level
167
- const isLastOfItsKind = heading.level !== headingNext?.level
163
+ const isFirstOfItsKind = navItem.level !== navItemPrevious?.level
164
+ const isLastOfItsKind = navItem.level !== navItemNext?.level
168
165
 
169
166
  return {
170
- ...heading,
171
- computed: {
172
- isActive,
173
- isActiveFirst,
174
- isActiveLast,
175
- isFirstOfItsKind,
176
- isLastOfItsKind,
177
- },
167
+ ...navItem,
168
+ isActive,
169
+ isActiveFirst,
170
+ isActiveLast,
171
+ isFirstOfItsKind,
172
+ isLastOfItsKind,
178
173
  }
179
174
  })
180
175
  }
@@ -0,0 +1,32 @@
1
+ export { initMobileNavigation }
2
+
3
+ function initMobileNavigation() {
4
+ activateMobileShowNavigationToggle()
5
+ activateMobileNavigationMask()
6
+ autoHideNavigationOverlayOnLinkClick()
7
+ }
8
+
9
+ function activateMobileShowNavigationToggle() {
10
+ const toggle = document.getElementById('mobile-show-navigation-toggle')!
11
+ toggle.onclick = toggleNavigation
12
+ }
13
+ function activateMobileNavigationMask() {
14
+ const navigationMask = document.getElementById('mobile-navigation-mask')!
15
+ navigationMask.onclick = toggleNavigation
16
+ }
17
+
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
23
+ hideNavigation()
24
+ })
25
+ }
26
+
27
+ function toggleNavigation() {
28
+ document.body.classList.toggle('mobile-show-navigation')
29
+ }
30
+ function hideNavigation() {
31
+ document.body.classList.remove('mobile-show-navigation')
32
+ }
@@ -0,0 +1,16 @@
1
+ export { initPressKit }
2
+
3
+ function initPressKit() {
4
+ // Right click navigation header => show /press
5
+ navigationHeaderRightClickInterceptor()
6
+ }
7
+
8
+ function navigationHeaderRightClickInterceptor() {
9
+ const navHeader = document.getElementById('navigation-header')!
10
+ if (!navHeader.classList.contains('press-kit')) return
11
+ if (window.location.pathname === '/press') return
12
+ navHeader.oncontextmenu = (ev) => {
13
+ ev.preventDefault()
14
+ window.location.href = '/press'
15
+ }
16
+ }
@@ -27,6 +27,6 @@ html:not(.navigation-fullscreen) #navigation-fullscreen-close {
27
27
  }
28
28
 
29
29
  html.navigation-fullscreen #page-content {
30
- /* Make `Ctrl-F` browser search only crawl the navigation menu */
30
+ /* Make `Ctrl-F` browser search only crawl the navigation */
31
31
  visibility: hidden;
32
32
  }
@@ -32,7 +32,7 @@ function toggleNavExpend() {
32
32
 
33
33
  function updateColumnWidth() {
34
34
  const navMinWidth = 299
35
- const navH1Groups = Array.from(document.querySelectorAll('#navigation-content-main .nav-h1-group'))
35
+ const navH1Groups = Array.from(document.querySelectorAll('#navigation-content-main .nav-items-level-1-group'))
36
36
  const numberOfColumnsMax = navH1Groups.length
37
37
 
38
38
  const widthAvailable = getViewportWidth()