@brillout/docpress 0.5.34 → 0.5.35

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.
@@ -47,32 +47,31 @@ function RepoLink({ path, text, editMode }) {
47
47
  // src/parseTitle.ts
48
48
  import React3 from "react";
49
49
  function getHeadingsWithProcessedTitle(config) {
50
- const headingsWithoutParent = config.headings.map((heading) => {
51
- const titleProcessed = parseTitle(heading.title);
52
- const titleInNav = heading.titleInNav || heading.title;
53
- let titleInNavProcessed;
54
- if ("isListTitle" in heading) {
55
- assert(heading.isListTitle === true);
56
- let titleParsed = parseTitle(titleInNav);
57
- titleInNavProcessed = React3.createElement(React3.Fragment, {}, getListPrefix(), titleParsed);
58
- } else {
50
+ const headingsWithoutBreadcrumb = config.headings.map(
51
+ (heading) => {
52
+ const titleProcessed = parseTitle(heading.title);
53
+ const titleInNav = heading.titleInNav || heading.title;
54
+ let titleInNavProcessed;
59
55
  titleInNavProcessed = parseTitle(titleInNav);
56
+ if ("titleEmoji" in heading) {
57
+ assert(heading.titleEmoji);
58
+ titleInNavProcessed = withEmoji(heading.titleEmoji, titleInNavProcessed);
59
+ }
60
+ const headingProcessed = {
61
+ ...heading,
62
+ title: titleProcessed,
63
+ titleInNav: titleInNavProcessed
64
+ };
65
+ return headingProcessed;
60
66
  }
61
- if ("titleEmoji" in heading) {
62
- assert(heading.titleEmoji);
63
- titleInNavProcessed = withEmoji(heading.titleEmoji, titleInNavProcessed);
64
- }
65
- const headingProcessed = {
66
- ...heading,
67
- title: titleProcessed,
68
- titleInNav: titleInNavProcessed
69
- };
70
- return headingProcessed;
71
- });
67
+ );
72
68
  const headingsProcessed = [];
73
- headingsWithoutParent.forEach((heading) => {
74
- const parentHeadings = findParentHeadings(heading, headingsProcessed);
75
- headingsProcessed.push({ ...heading, parentHeadings });
69
+ headingsWithoutBreadcrumb.forEach((heading) => {
70
+ const headingsBreadcrumb = getHeadingsBreadcrumb(heading, headingsProcessed);
71
+ headingsProcessed.push({
72
+ ...heading,
73
+ headingsBreadcrumb
74
+ });
76
75
  });
77
76
  const headingsDetachedProcessed = config.headingsDetached.map((headingsDetached) => {
78
77
  const { url, title } = headingsDetached;
@@ -86,29 +85,23 @@ function getHeadingsWithProcessedTitle(config) {
86
85
  level: 2,
87
86
  title: titleProcessed,
88
87
  titleInNav: titleProcessed,
89
- parentHeadings: null
88
+ headingsBreadcrumb: null
90
89
  };
91
90
  });
92
91
  assertHeadingsUrl([...headingsProcessed, ...headingsDetachedProcessed]);
93
92
  return { headingsProcessed, headingsDetachedProcessed };
94
93
  }
95
- function findParentHeadings(heading, headings) {
96
- const parentHeadings = [];
94
+ function getHeadingsBreadcrumb(heading, headings) {
95
+ const headingsBreadcrumb = [];
97
96
  let levelCurrent = heading.level;
98
- let listTitleParentFound = false;
99
97
  headings.slice().reverse().forEach((parentCandidate) => {
100
- let isListTitleParent = false;
101
- if (!listTitleParentFound && levelCurrent === heading.level && parentCandidate.level === heading.level && !parentCandidate.isListTitle && heading.isListTitle) {
102
- isListTitleParent = true;
103
- listTitleParentFound = true;
104
- }
105
98
  const isParent = parentCandidate.level < levelCurrent;
106
- if (isParent || isListTitleParent) {
99
+ if (isParent) {
107
100
  levelCurrent = parentCandidate.level;
108
- parentHeadings.push(parentCandidate);
101
+ headingsBreadcrumb.push(parentCandidate);
109
102
  }
110
103
  });
111
- return parentHeadings;
104
+ return headingsBreadcrumb;
112
105
  }
113
106
  function assertHeadingsUrl(headings) {
114
107
  headings.forEach((heading) => {
@@ -118,11 +111,6 @@ function assertHeadingsUrl(headings) {
118
111
  }
119
112
  });
120
113
  }
121
- function getListPrefix() {
122
- const nonBreakingSpace = String.fromCodePoint(160);
123
- const bulletPoint = String.fromCodePoint(8226);
124
- return nonBreakingSpace + bulletPoint + nonBreakingSpace;
125
- }
126
114
  function parseTitle(title) {
127
115
  const parts = [];
128
116
  let current;
package/dist/index.d.ts CHANGED
@@ -36,7 +36,6 @@ type HeadingDefinition = HeadingBase & (({
36
36
  level: 4;
37
37
  } & HeadingAbstract) | {
38
38
  level: 2;
39
- isListTitle?: true;
40
39
  sectionTitles?: string[];
41
40
  url: null | string;
42
41
  } | {
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  isRepoLink,
4
4
  parseTitle,
5
5
  usePageContext
6
- } from "./chunk-GMA6WHHB.js";
6
+ } from "./chunk-MGOI4AFO.js";
7
7
  import {
8
8
  FeatureList
9
9
  } from "./chunk-NVJING6T.js";
@@ -47,10 +47,10 @@ function Link({
47
47
  const pageContext = usePageContext();
48
48
  return /* @__PURE__ */ React.createElement("a", {
49
49
  href
50
- }, children || text || getTitle({ href, noBreadcrumb, pageContext, doNotInferSectionTitle }));
50
+ }, children || text || getLinkText({ href, noBreadcrumb, pageContext, doNotInferSectionTitle }));
51
51
  }
52
52
  }
53
- function getTitle({
53
+ function getLinkText({
54
54
  href,
55
55
  noBreadcrumb,
56
56
  pageContext,
@@ -80,13 +80,13 @@ function getTitle({
80
80
  assert(isLinkOnSamePage === (heading.url === pageContext.urlPathname));
81
81
  assert(isLinkOnSamePage === (heading.url === pageContext.activeHeading.url));
82
82
  assert(isLinkOnSamePage === (heading === pageContext.activeHeading));
83
- const breadcrumbs = [];
84
- if (heading.parentHeadings) {
85
- breadcrumbs.push(
86
- ...(heading.parentHeadings ?? []).slice().reverse().map(({ title }) => title)
83
+ const breadcrumbParts = [];
84
+ if (heading.headingsBreadcrumb) {
85
+ breadcrumbParts.push(
86
+ ...(heading.headingsBreadcrumb ?? []).slice().reverse().map(({ title }) => title)
87
87
  );
88
88
  }
89
- breadcrumbs.push(heading.title);
89
+ breadcrumbParts.push(heading.title);
90
90
  if (urlHash) {
91
91
  let sectionTitle = void 0;
92
92
  assert(!urlHash.startsWith("#"));
@@ -107,14 +107,14 @@ function getTitle({
107
107
  );
108
108
  sectionTitle = determineSectionTitle(href);
109
109
  }
110
- breadcrumbs.push(sectionTitle);
110
+ breadcrumbParts.push(sectionTitle);
111
111
  }
112
112
  {
113
113
  if (noBreadcrumb || isLinkOnSamePage) {
114
- return breadcrumbs[breadcrumbs.length - 1];
114
+ return breadcrumbParts[breadcrumbParts.length - 1];
115
115
  }
116
116
  }
117
- return /* @__PURE__ */ React.createElement(React.Fragment, null, breadcrumbs.map((title, i) => {
117
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, breadcrumbParts.map((title, i) => {
118
118
  const seperator = i === 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null) : " > ";
119
119
  return /* @__PURE__ */ React.createElement(React.Fragment, {
120
120
  key: i
@@ -233,9 +233,6 @@ html.navigation-fullscreen .nav-item {
233
233
  border-bottom-left-radius: 5px;
234
234
  border-bottom-right-radius: var(--expend-border-radius);
235
235
  }
236
- .nav-item-h3.nav-item-parent-is-list-heading {
237
- --padding-left-additional: 21px;
238
- }
239
236
 
240
237
  /* src/navigation/Navigation-highlight.css */
241
238
 
@@ -1,5 +1,5 @@
1
1
  import * as vike_dist_esm_node_runtime_html_renderHtml from 'vike/dist/esm/node/runtime/html/renderHtml';
2
- import { PageContextBuiltIn } from 'vike/types';
2
+ import { PageContextBuiltInServer } from 'vike/types';
3
3
 
4
4
  type MarkdownHeading = {
5
5
  title: string;
@@ -12,7 +12,7 @@ type ReactComponent = () => JSX.Element;
12
12
  type Exports = {
13
13
  headings?: MarkdownHeading[];
14
14
  };
15
- type PageContextOriginal = PageContextBuiltIn & {
15
+ type PageContextOriginal = PageContextBuiltInServer & {
16
16
  Page: ReactComponent;
17
17
  exports: Exports;
18
18
  };
@@ -4,7 +4,7 @@ import {
4
4
  getHeadingsWithProcessedTitle,
5
5
  parseTitle,
6
6
  usePageContext
7
- } from "../chunk-GMA6WHHB.js";
7
+ } from "../chunk-MGOI4AFO.js";
8
8
  import {
9
9
  Emoji,
10
10
  jsxToTextContent,
@@ -245,7 +245,6 @@ function Heading({
245
245
  heading.computed.isActive && " is-active",
246
246
  heading.computed.isActiveFirst && " is-active-first",
247
247
  heading.computed.isActiveLast && " is-active-last",
248
- heading.computed.isChildOfListHeading && "nav-item-parent-is-list-heading",
249
248
  heading.computed.isFirstOfItsKind && "nav-item-first-of-its-kind",
250
249
  heading.computed.isLastOfItsKind && "nav-item-last-of-its-kind"
251
250
  ].filter(Boolean).join(" "),
@@ -266,7 +265,6 @@ function groupHeadings(headings) {
266
265
  }
267
266
  function getHeadingsWithComputedProps(headings, currentUrl) {
268
267
  return headings.map((heading, i) => {
269
- var _a2;
270
268
  assert([1, 2, 3, 4].includes(heading.level), heading);
271
269
  const headingPrevious = headings[i - 1];
272
270
  const headingNext = headings[i + 1];
@@ -289,7 +287,6 @@ function getHeadingsWithComputedProps(headings, currentUrl) {
289
287
  }
290
288
  const isFirstOfItsKind = heading.level !== (headingPrevious == null ? void 0 : headingPrevious.level);
291
289
  const isLastOfItsKind = heading.level !== (headingNext == null ? void 0 : headingNext.level);
292
- const isChildOfListHeading = !!heading.parentHeadings && !!((_a2 = heading.parentHeadings[0]) == null ? void 0 : _a2.isListTitle);
293
290
  return {
294
291
  ...heading,
295
292
  computed: {
@@ -297,8 +294,7 @@ function getHeadingsWithComputedProps(headings, currentUrl) {
297
294
  isActiveFirst,
298
295
  isActiveLast,
299
296
  isFirstOfItsKind,
300
- isLastOfItsKind,
301
- isChildOfListHeading
297
+ isLastOfItsKind
302
298
  }
303
299
  };
304
300
  });
@@ -444,11 +440,11 @@ function resolvePageContext(pageContext) {
444
440
  );
445
441
  let headingsOfDetachedPage = null;
446
442
  let headingsAll = [...headingsProcessed, ...headingsDetachedProcessed];
447
- headingsAll = getHeadingsWithSubHeadings(headingsAll, pageContext, activeHeading);
443
+ headingsAll = getHeadingsAll(headingsAll, pageContext, activeHeading);
448
444
  if (activeNavigationHeading) {
449
- headingsProcessed = getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeNavigationHeading);
445
+ headingsProcessed = getHeadingsAll(headingsProcessed, pageContext, activeNavigationHeading);
450
446
  } else {
451
- headingsOfDetachedPage = [activeHeading, ...getPageHeadings(pageContext, activeHeading)];
447
+ headingsOfDetachedPage = [activeHeading, ...getHeadingsOfTheCurrentPage(pageContext, activeHeading)];
452
448
  }
453
449
  const { title, isLandingPage, pageTitle } = getMetaData(
454
450
  headingsDetachedProcessed,
@@ -526,40 +522,40 @@ function findHeading(headingsProcessed, headingsDetachedProcessed, pageContext)
526
522
  }
527
523
  return { activeHeading, activeNavigationHeading };
528
524
  }
529
- function getHeadingsWithSubHeadings(headingsProcessed, pageContext, activeHeading) {
530
- const headingsProcessedWithSubHeadings = headingsProcessed.slice();
531
- const pageHeadings = getPageHeadings(pageContext, activeHeading);
532
- const activeHeadingIdx = headingsProcessedWithSubHeadings.indexOf(activeHeading);
525
+ function getHeadingsAll(headingsProcessed, pageContext, activeHeading) {
526
+ const headingsAll = headingsProcessed.slice();
527
+ const headingsOfTheCurrentPage = getHeadingsOfTheCurrentPage(pageContext, activeHeading);
528
+ const activeHeadingIdx = headingsAll.indexOf(activeHeading);
533
529
  assert(activeHeadingIdx >= 0);
534
- pageHeadings.forEach((pageHeading, i) => {
535
- headingsProcessedWithSubHeadings.splice(activeHeadingIdx + 1 + i, 0, pageHeading);
530
+ headingsOfTheCurrentPage.forEach((pageHeading, i) => {
531
+ headingsAll.splice(activeHeadingIdx + 1 + i, 0, pageHeading);
536
532
  });
537
- return headingsProcessedWithSubHeadings;
533
+ return headingsAll;
538
534
  }
539
- function getPageHeadings(pageContext, currentHeading) {
540
- const pageHeadings = [];
541
- const markdownHeadings = pageContext.exports.headings ?? [];
542
- markdownHeadings.forEach((markdownHeading) => {
535
+ function getHeadingsOfTheCurrentPage(pageContext, currentHeading) {
536
+ const headingsOfCurrentPage = [];
537
+ const headingsExport = pageContext.exports.headings ?? [];
538
+ headingsExport.forEach((markdownHeading) => {
543
539
  const title = parseTitle(markdownHeading.title);
544
540
  const url = markdownHeading.headingId && "#" + markdownHeading.headingId;
545
541
  if (markdownHeading.headingLevel === 2) {
546
542
  const heading = {
547
543
  url,
548
544
  title,
549
- parentHeadings: [currentHeading, ...currentHeading.parentHeadings ?? []],
545
+ headingsBreadcrumb: [currentHeading, ...currentHeading.headingsBreadcrumb ?? []],
550
546
  titleInNav: title,
551
547
  level: 3
552
548
  };
553
- pageHeadings.push(heading);
549
+ headingsOfCurrentPage.push(heading);
554
550
  }
555
551
  });
556
552
  if (currentHeading == null ? void 0 : currentHeading.sectionTitles) {
557
553
  currentHeading.sectionTitles.forEach((sectionTitle) => {
558
- const pageHeadingTitles = markdownHeadings.map((h) => h.title);
554
+ const pageHeadingTitles = headingsExport.map((h) => h.title);
559
555
  assert(pageHeadingTitles.includes(sectionTitle), { pageHeadingTitles, sectionTitle });
560
556
  });
561
557
  }
562
- return pageHeadings;
558
+ return headingsOfCurrentPage;
563
559
  }
564
560
 
565
561
  // src/algolia/DocSearch.ts
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
4
4
  "scripts": {
5
5
  "// Check types while developing": "",
6
6
  "types": "tsc --noEmit --watch",
7
7
  "// Develop Docpress using demo/": "",
8
+ "dev": "pnpm run dev:build && pnpm run dev:start",
8
9
  "dev:build": "tsup",
9
10
  "dev:start": "node dist/index.js dev",
10
- "dev": "pnpm run dev:build && pnpm run dev:start",
11
11
  "// Build Docpress": "",
12
12
  "build": "rimraf dist/ && framework-builder",
13
+ "// Preview build": "",
14
+ "preview": "pnpm run preview:build && pnpm run preview:start",
15
+ "preview:build": "pnpm run build && node dist/cli/index.js build",
16
+ "preview:start": "node dist/cli/index.js preview",
17
+ "// Test": "",
18
+ "test": "test-e2e",
13
19
  "// Release": "",
14
20
  "release": "release-me patch",
15
21
  "release:breaking-change": "release-me minor"
@@ -25,7 +31,7 @@
25
31
  "remark-gfm": "^3.0.1",
26
32
  "shiki": "^0.10.1",
27
33
  "twemoji": "^13.1.0",
28
- "vike": "^0.4.151",
34
+ "vike": "^0.4.158",
29
35
  "vike-contributors": "^0.0.6",
30
36
  "vite": "^4.3.9"
31
37
  },
@@ -65,6 +71,7 @@
65
71
  "@brillout/docpress": "link:.",
66
72
  "@brillout/framework-builder": "^0.1.1",
67
73
  "@brillout/release-me": "^0.1.13",
74
+ "@brillout/test-e2e": "^0.5.25",
68
75
  "@types/express": "^4.17.13",
69
76
  "@types/node": "^15.12.1",
70
77
  "@types/react": "^17.0.44",