@brillout/docpress 0.8.5 → 0.8.6

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.
@@ -154,16 +154,18 @@ function getActiveHeading(
154
154
  pageContext: { urlPathname: string; exports: Exports },
155
155
  ) {
156
156
  let activeHeading: HeadingResolved | HeadingDetachedResolved | null = null
157
- let activeCategory: string | undefined
157
+ let activeCategory = 'Miscellaneous'
158
+ let headingCategory: string | undefined
158
159
  const { urlPathname } = pageContext
159
160
  assert(urlPathname)
160
161
  for (const heading of headingsResolved) {
161
162
  if (heading.level === 1) {
162
- activeCategory = heading.title
163
+ headingCategory = heading.title
163
164
  }
164
165
  if (heading.url === urlPathname) {
165
166
  activeHeading = heading
166
- assert(activeCategory)
167
+ assert(headingCategory)
168
+ activeCategory = headingCategory
167
169
  assert(heading.level === 2, { pageUrl: urlPathname, heading })
168
170
  break
169
171
  }
@@ -185,6 +187,7 @@ function getActiveHeading(
185
187
  ].join('\n'),
186
188
  )
187
189
  }
190
+ if (activeHeading.category) activeCategory = activeHeading.category
188
191
  return { activeHeading, isDetachedPage, activeCategory }
189
192
  }
190
193
 
@@ -11,5 +11,5 @@ declare function resolveHeadingsData(pageContext: PageContextOriginal): {
11
11
  pageTitle: string | null;
12
12
  documentTitle: string;
13
13
  columnLayouts: number[][];
14
- activeCategory: string | undefined;
14
+ activeCategory: string;
15
15
  };
@@ -125,17 +125,19 @@ function getTitles(activeHeading, pageContext, config) {
125
125
  function getActiveHeading(headingsResolved, headingsDetachedResolved, pageContext) {
126
126
  var _a;
127
127
  var activeHeading = null;
128
- var activeCategory;
128
+ var activeCategory = 'Miscellaneous';
129
+ var headingCategory;
129
130
  var urlPathname = pageContext.urlPathname;
130
131
  assert(urlPathname);
131
132
  for (var _i = 0, headingsResolved_1 = headingsResolved; _i < headingsResolved_1.length; _i++) {
132
133
  var heading = headingsResolved_1[_i];
133
134
  if (heading.level === 1) {
134
- activeCategory = heading.title;
135
+ headingCategory = heading.title;
135
136
  }
136
137
  if (heading.url === urlPathname) {
137
138
  activeHeading = heading;
138
- assert(activeCategory);
139
+ assert(headingCategory);
140
+ activeCategory = headingCategory;
139
141
  assert(heading.level === 2, { pageUrl: urlPathname, heading: heading });
140
142
  break;
141
143
  }
@@ -157,6 +159,8 @@ function getActiveHeading(headingsResolved, headingsDetachedResolved, pageContex
157
159
  .join('\n'),
158
160
  ].join('\n'));
159
161
  }
162
+ if (activeHeading.category)
163
+ activeCategory = activeHeading.category;
160
164
  return { activeHeading: activeHeading, isDetachedPage: isDetachedPage, activeCategory: activeCategory };
161
165
  }
162
166
  function getPageSectionsResolved(pageContext, activeHeading) {
@@ -18,7 +18,7 @@ declare function resolvePageContext(pageContext: PageContextOriginal): {
18
18
  pageTitle: string | null;
19
19
  documentTitle: string;
20
20
  columnLayouts: number[][];
21
- activeCategory: string | undefined;
21
+ activeCategory: string;
22
22
  } & {
23
23
  urlPathname: string;
24
24
  meta: {
@@ -10,6 +10,7 @@ type HeadingResolved = {
10
10
  linkBreadcrumb: string[];
11
11
  sectionTitles?: string[];
12
12
  menuModalFullWidth?: true;
13
+ category?: string;
13
14
  } & Tmp;
14
15
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
15
16
  level: 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -34,7 +34,7 @@ Promise<Awaited<ReturnType<OnRenderHtmlAsync>>> => {
34
34
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
35
35
  ${getOpenGraphTags(pageContext.urlPathname, pageContextResolved.documentTitle, pageContextResolved.meta)}
36
36
  <style>${dangerouslySkipEscape(styleMenuModalLayout)}</style>
37
- <meta name="docsearch:category" content="${pageContextResolved.activeCategory ?? 'Miscellaneous'}" />
37
+ <meta name="docsearch:category" content="${pageContextResolved.activeCategory}" />
38
38
  </head>
39
39
  <body>
40
40
  <div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
package/types/Heading.ts CHANGED
@@ -11,6 +11,7 @@ type HeadingResolved = {
11
11
  linkBreadcrumb: string[]
12
12
  sectionTitles?: string[]
13
13
  menuModalFullWidth?: true
14
+ category?: string
14
15
  } & Tmp
15
16
 
16
17
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {