@redpanda-data/docs-extensions-and-macros 3.0.14 → 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.
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
module.exports.register = function ({ config }) {
|
|
8
8
|
const yaml = require('js-yaml');
|
|
9
|
-
const _ = require('lodash');
|
|
10
9
|
const logger = this.getLogger('global-attributes-extension');
|
|
11
10
|
const chalk = require('chalk')
|
|
12
11
|
|
|
@@ -29,18 +28,4 @@ module.exports.register = function ({ config }) {
|
|
|
29
28
|
logger.error(`Error loading attributes: ${error.message}`);
|
|
30
29
|
}
|
|
31
30
|
})
|
|
32
|
-
|
|
33
|
-
.on('contentClassified', ({ siteCatalog, contentCatalog }) => {
|
|
34
|
-
const components = contentCatalog.getComponents()
|
|
35
|
-
try {
|
|
36
|
-
components.forEach(({versions}) => {
|
|
37
|
-
versions.forEach(({asciidoc}) => {
|
|
38
|
-
asciidoc.attributes = _.merge(asciidoc.attributes, siteCatalog.attributeFile);
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
console.log(chalk.green('Merged global attributes into each component version.'));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
logger.error(`Error merging attributes: ${error.message}`);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
31
|
}
|
|
@@ -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,
|
|
@@ -7,6 +7,7 @@ antora:
|
|
|
7
7
|
const GetLatestRedpandaVersion = require('./getLatestRedpandaVersion');
|
|
8
8
|
const GetLatestConsoleVersion = require('./getLatestConsoleVersion');
|
|
9
9
|
const chalk = require('chalk')
|
|
10
|
+
const _ = require('lodash');
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
module.exports.register = function ({ config }) {
|
|
@@ -15,7 +16,7 @@ module.exports.register = function ({ config }) {
|
|
|
15
16
|
logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.');
|
|
16
17
|
}
|
|
17
18
|
this
|
|
18
|
-
.on('contentClassified', async ({ contentCatalog }) => {
|
|
19
|
+
.on('contentClassified', async ({ siteCatalog,contentCatalog }) => {
|
|
19
20
|
try {
|
|
20
21
|
const LatestRedpandaVersion = await GetLatestRedpandaVersion();
|
|
21
22
|
const LatestConsoleVersion = await GetLatestConsoleVersion();
|
|
@@ -30,6 +31,16 @@ module.exports.register = function ({ config }) {
|
|
|
30
31
|
let component = components[i];
|
|
31
32
|
if (component.name !== 'ROOT' && component.name !== 'preview') continue
|
|
32
33
|
|
|
34
|
+
component.versions.forEach(({name, version, asciidoc}) => {
|
|
35
|
+
if (siteCatalog.attributeFile) {
|
|
36
|
+
asciidoc.attributes = _.merge(asciidoc.attributes, siteCatalog.attributeFile);
|
|
37
|
+
}
|
|
38
|
+
if (LatestConsoleVersion) {
|
|
39
|
+
asciidoc.attributes['latest-console-version'] = `${LatestConsoleVersion}`;
|
|
40
|
+
console.log(`${chalk.green('Set Redpanda Console version to')} ${chalk.bold(LatestConsoleVersion)} in ${name} ${version}`);
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
33
44
|
if (!component.latest.asciidoc) {
|
|
34
45
|
component.latest.asciidoc = {};
|
|
35
46
|
}
|
|
@@ -42,14 +53,7 @@ module.exports.register = function ({ config }) {
|
|
|
42
53
|
|
|
43
54
|
component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion[0]}`;
|
|
44
55
|
component.latest.asciidoc.attributes['latest-release-commit'] = `${LatestRedpandaVersion[1]}`;
|
|
45
|
-
console.log(`${chalk.green('Set Redpanda version to')} ${chalk.bold(LatestRedpandaVersion[0])} ${chalk.bold(LatestRedpandaVersion[1])}`)
|
|
46
|
-
|
|
47
|
-
if (LatestConsoleVersion) {
|
|
48
|
-
for (const { asciidoc } of component.versions) {
|
|
49
|
-
asciidoc.attributes['latest-console-version'] = `${LatestConsoleVersion}`;
|
|
50
|
-
}
|
|
51
|
-
console.log(`${chalk.green('Set Redpanda Console version to')} ${chalk.bold(LatestConsoleVersion)}`);
|
|
52
|
-
}
|
|
56
|
+
console.log(`${chalk.green('Set the latest Redpanda version to')} ${chalk.bold(LatestRedpandaVersion[0])} ${chalk.bold(LatestRedpandaVersion[1])}`)
|
|
53
57
|
}
|
|
54
58
|
} catch(error) {
|
|
55
59
|
logger.warn(error)
|