@redpanda-data/docs-extensions-and-macros 3.0.4 → 3.0.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.
@@ -164,13 +164,13 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
164
164
  if (!(cname in algolia)) algolia[cname] = {}
165
165
  if (!(version in algolia[cname])) algolia[cname][version] = []
166
166
 
167
- // Handle the article text
167
+ /* Handle the article text
168
168
  var text = decode(article.text)
169
169
  text = text.replace(/\n/g, ' ')
170
170
  .replace(/\r/g, ' ')
171
171
  .replace(/\s+/g, ' ')
172
172
  .trim()
173
- if (text.length > 4000) text = text.substr(0, 4000)
173
+ if (text.length > 4000) text = text.substr(0, 4000)*/
174
174
 
175
175
  var tag = `${component.title}-${version}`
176
176
 
@@ -179,7 +179,7 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
179
179
  product: component.title,
180
180
  version: version,
181
181
  image: image? image: '',
182
- text: text,
182
+ //text: text,
183
183
  breadcrumbs: breadcrumbs,
184
184
  intro: intro,
185
185
  objectID: urlPath + page.pub.url,
@@ -44,7 +44,11 @@ function register ({
44
44
  Object.keys(algolia[c]).forEach((v) => {
45
45
  algoliaCount += algolia[c][v].length
46
46
  // Save all records to the index
47
- index.saveObjects(algolia[c][v]).wait();
47
+ index.saveObjects(algolia[c][v]).then(() => {
48
+ console.log(`${chalk.bold(algoliaCount)} Algolia index entries created`)
49
+ }).catch(error => {
50
+ console.error(`Error saving objects to Algolia: ${error}`);
51
+ });
48
52
  siteCatalog.addFile({
49
53
  mediaType: 'application/json',
50
54
  contents: Buffer.from(
@@ -62,7 +66,6 @@ function register ({
62
66
  'product'
63
67
  ]
64
68
  })
65
- console.log(`${chalk.bold(algoliaCount)} Algolia index entries created`)
66
69
  // Get and print the count of all records in the index
67
70
  let recordCount = 0;
68
71
  index
@@ -8,8 +8,9 @@ module.exports.register = function ({ config }) {
8
8
  for (const { versions } of contentCatalog.getComponents()) {
9
9
  for (const { name: component, version, asciidoc } of versions) {
10
10
  const attachments = contentCatalog.findBy({ component, version, family });
11
+ if (component == 'api') continue
11
12
  for (const attachment of attachments) {
12
- let contentString = String.fromCharCode(...attachment['_contents']);
13
+ let contentString = attachment['_contents'].toString('utf8');
13
14
  if (!asciidoc.attributes) continue
14
15
  if (!asciidoc.attributes.hasOwnProperty('replace-attributes-in-attachments')) continue;
15
16
  for (const key in asciidoc.attributes) {
@@ -15,49 +15,40 @@ module.exports.register = function ({ config }) {
15
15
  logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.');
16
16
  }
17
17
  this
18
- .on('playbookBuilt', async ({ playbook }) => {
18
+ .on('contentClassified', async ({ contentCatalog }) => {
19
19
  try {
20
+ const LatestRedpandaVersion = await GetLatestRedpandaVersion();
20
21
  const LatestConsoleVersion = await GetLatestConsoleVersion();
21
- if (!LatestConsoleVersion) {
22
- logger.warn(`Failed to get latest Console version from GitHub`)
23
- return
22
+ if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) {
23
+ logger.warn('Failed to get the latest Redpanda version - using defaults');
24
24
  }
25
- if (!playbook.asciidoc) {
26
- playbook.asciidoc = {};
27
- }
28
-
29
- if (!playbook.asciidoc.attributes) {
30
- playbook.asciidoc.attributes = {};
25
+ if (!LatestConsoleVersion) {
26
+ logger.warn(`Failed to get latest Console version from GitHub - using default`)
31
27
  }
32
- playbook.asciidoc.attributes['latest-console-version'] = LatestConsoleVersion
33
- console.log(`${chalk.green('Set Redpanda Console version to')} ${chalk.bold(LatestConsoleVersion)}`);
34
- } catch(error) {
35
- logger.warn(error)
36
- }
37
- })
38
- .on('contentClassified', async ({ contentCatalog }) => {
39
- try {
40
- const LatestRedpandaVersion = await GetLatestRedpandaVersion();
41
28
  const components = await contentCatalog.getComponents();
42
29
  for (let i = 0; i < components.length; i++) {
43
30
  let component = components[i];
44
- if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) {
45
- logger.warn('Failed to get the latest Redpanda versions - using defaults');
46
- return
31
+ if (component.name !== 'ROOT' && component.name !== 'preview') continue
32
+
33
+ if (!component.latest.asciidoc) {
34
+ component.latest.asciidoc = {};
47
35
  }
48
- if (component.name === 'ROOT') {
49
36
 
50
- if (!component.latest.asciidoc) {
51
- component.latest.asciidoc = {};
52
- }
37
+ if (!component.latest.asciidoc.attributes) {
38
+ component.latest.asciidoc.attributes = {};
39
+ }
53
40
 
54
- if (!component.latest.asciidoc.attributes) {
55
- component.latest.asciidoc.attributes = {};
56
- }
41
+ if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) continue;
57
42
 
58
- component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion[0]}`;
59
- component.latest.asciidoc.attributes['latest-release-commit'] = `${LatestRedpandaVersion[1]}`;
60
- console.log(`${chalk.green('Set Redpanda version to')} ${chalk.bold(LatestRedpandaVersion[0])} ${chalk.bold(LatestRedpandaVersion[1])}`)
43
+ component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion[0]}`;
44
+ 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)}`);
61
52
  }
62
53
  }
63
54
  } catch(error) {
@@ -75,7 +75,7 @@ module.exports.register = function (registry, config = {}) {
75
75
  }
76
76
  }
77
77
 
78
- //characters to replace by '_' in generated idprefix
78
+ //characters to replace by '-' in generated idprefix
79
79
  const IDRX = /[/ _.-]+/g
80
80
 
81
81
  function termId (term) {
@@ -123,9 +123,11 @@ module.exports.register = function (registry, config = {}) {
123
123
  var glossaryPage = document.getAttribute('glossary-page', '')
124
124
  if (glossaryPage.endsWith('.adoc')) {
125
125
  const page = config.contentCatalog.resolvePage(glossaryPage, config.file.src)
126
- const relativizedPath = path.relative(path.dirname(config.file.pub.url), page.pub.url)
127
- const prefix = attributes.prefix
128
- glossaryPage = prefix ? [prefix, relativizedPath].join('/') : relativizedPath
126
+ if (page && config.config.attributes['site-url']) {
127
+ glossaryPage = config.config.attributes['site-url'] + page.pub.url
128
+ } else if (page) {
129
+ glossaryPage = path.relative(path.dirname(config.file.pub.url), page.pub.url)
130
+ }
129
131
  }
130
132
  const glossaryTermRole = document.getAttribute('glossary-term-role', 'glossary-term')
131
133
  const attrs = glossaryTermRole ? { role: glossaryTermRole } : {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "scripts": {
16
16
  "build": "antora --to-dir docs --fetch local-antora-playbook.yml",
17
- "serve": "wds --node-resolve --open preview/test.html --watch --root-dir docs"
17
+ "serve": "wds --node-resolve --open preview/test --watch --root-dir docs"
18
18
  },
19
19
  "contributors": [
20
20
  {