@redpanda-data/docs-extensions-and-macros 3.0.15 → 3.0.16
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.
|
@@ -143,13 +143,37 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
|
|
|
143
143
|
if (!(cname in algolia)) algolia[cname] = {}
|
|
144
144
|
if (!(version in algolia[cname])) algolia[cname][version] = []
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
// Handle the article text
|
|
147
|
+
const contentElements = article.querySelectorAll('p, table, li');
|
|
148
|
+
let contentText = '';
|
|
149
|
+
let currentSize = 0;
|
|
150
|
+
// Maximum size in bytes
|
|
151
|
+
const MAX_SIZE = 50000;
|
|
152
|
+
const encoder = new TextEncoder();
|
|
153
|
+
contentElements.forEach(element => {
|
|
154
|
+
let elementText = '';
|
|
155
|
+
if (element.tagName === 'TABLE') {
|
|
156
|
+
element.querySelectorAll('tr').forEach(tr => {
|
|
157
|
+
tr.querySelectorAll('td, th').forEach(cell => {
|
|
158
|
+
elementText += cell.text + ' ';
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
elementText = decode(element.rawText);
|
|
163
|
+
}
|
|
164
|
+
const elementSize = encoder.encode(elementText).length;
|
|
165
|
+
if (currentSize + elementSize > MAX_SIZE) {
|
|
166
|
+
return;
|
|
167
|
+
} else {
|
|
168
|
+
contentText += elementText;
|
|
169
|
+
currentSize += elementSize;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
var text = contentText.replace(/\n/g, ' ')
|
|
149
174
|
.replace(/\r/g, ' ')
|
|
150
175
|
.replace(/\s+/g, ' ')
|
|
151
|
-
.trim()
|
|
152
|
-
if (text.length > 4000) text = text.substr(0, 4000)*/
|
|
176
|
+
.trim();
|
|
153
177
|
|
|
154
178
|
var tag = `${component.title}-${version}`
|
|
155
179
|
|
|
@@ -158,7 +182,7 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
|
|
|
158
182
|
product: component.title,
|
|
159
183
|
version: version,
|
|
160
184
|
//image: image? image: '',
|
|
161
|
-
|
|
185
|
+
text: text,
|
|
162
186
|
breadcrumbs: breadcrumbs,
|
|
163
187
|
intro: intro,
|
|
164
188
|
objectID: urlPath + page.pub.url,
|