@redpanda-data/docs-extensions-and-macros 3.0.17 → 3.1.1
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.
|
@@ -59,11 +59,11 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
|
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
/* Skip pages marked as "noindex" for "robots"
|
|
63
63
|
const noindex = root.querySelector('meta[name=robots][content=noindex]')
|
|
64
64
|
if (noindex) {
|
|
65
65
|
continue
|
|
66
|
-
}
|
|
66
|
+
}*/
|
|
67
67
|
|
|
68
68
|
// Compute a flag identifying if the current page is in the
|
|
69
69
|
// "current" component version.
|
|
@@ -188,7 +188,8 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
|
|
|
188
188
|
objectID: urlPath + page.pub.url,
|
|
189
189
|
titles: titles,
|
|
190
190
|
keywords: keywords,
|
|
191
|
-
|
|
191
|
+
type: 'Doc',
|
|
192
|
+
_tags: [tag, 'docs']
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
algolia[cname][version].push(indexItem)
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
const generateIndex = require('./generate-index')
|
|
4
4
|
const chalk = require('chalk')
|
|
5
5
|
const algoliasearch = require('algoliasearch')
|
|
6
|
+
const http = require('http')
|
|
7
|
+
const https = require('https')
|
|
6
8
|
const fs = require('fs')
|
|
7
9
|
const path = require('path')
|
|
8
10
|
const _ = require('lodash')
|
|
11
|
+
process.env.UV_THREADPOOL_SIZE=16
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Algolia indexing for an Antora documentation site.
|
|
@@ -26,8 +29,14 @@ function register({
|
|
|
26
29
|
var client
|
|
27
30
|
var index
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const httpAgent = new http.Agent({ keepAlive: true, maxSockets: 100 });
|
|
33
|
+
const httpsAgent = new https.Agent({ keepAlive: true, maxSockets: 100 });
|
|
34
|
+
|
|
35
|
+
// Connect and authenticate with Algolia using the custom agent
|
|
36
|
+
client = algoliasearch(process.env.ALGOLIA_APP_ID, process.env.ALGOLIA_ADMIN_API_KEY, {
|
|
37
|
+
httpAgent: httpAgent,
|
|
38
|
+
httpsAgent: httpsAgent
|
|
39
|
+
})
|
|
31
40
|
index = client.initIndex(process.env.ALGOLIA_INDEX_NAME)
|
|
32
41
|
|
|
33
42
|
if (Object.keys(unknownOptions).length) {
|
|
@@ -78,34 +87,27 @@ function register({
|
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
logger.info(`Updated records for ${c} version ${v}`)
|
|
87
|
-
})
|
|
88
|
-
.catch(error => {
|
|
89
|
-
logger.error(`Error updating objects to Algolia: ${error.message}`)
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
if (objectsToAdd.length) {
|
|
93
|
-
index.saveObjects(objectsToAdd)
|
|
94
|
-
.then(() => {
|
|
95
|
-
logger.info(`Added records for ${c} version ${v}`)
|
|
96
|
-
})
|
|
97
|
-
.catch(error => {
|
|
98
|
-
logger.error(`Error adding objects to Algolia: ${error.message}`)
|
|
99
|
-
})
|
|
100
|
-
}
|
|
90
|
+
const addObjectActions = objectsToAdd.map(object => ({
|
|
91
|
+
action: 'addObject',
|
|
92
|
+
indexName: process.env.ALGOLIA_INDEX_NAME,
|
|
93
|
+
body: object
|
|
94
|
+
}));
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
const updateObjectActions = objectsToUpdate.map(object => ({
|
|
97
|
+
action: 'updateObject',
|
|
98
|
+
indexName: process.env.ALGOLIA_INDEX_NAME,
|
|
99
|
+
body: object
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
const batchActions = [...addObjectActions, ...updateObjectActions];
|
|
103
|
+
|
|
104
|
+
// Upload new records only if the objects have been updated or they are new.
|
|
105
|
+
// See https://www.algolia.com/doc/api-reference/api-methods/batch/?client=javascript
|
|
106
|
+
await client.multipleBatch(batchActions).then(() => {
|
|
107
|
+
console.log('Batch operations completed successfully');
|
|
108
|
+
}).catch(error => {
|
|
109
|
+
logger.error(`Error uploading records to Algolia: ${error.message}`);
|
|
110
|
+
});
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -117,21 +119,11 @@ function register({
|
|
|
117
119
|
console.log(chalk.green('New records:' + totalObjectsToAdd))
|
|
118
120
|
|
|
119
121
|
totalObjectsToAdd === 0 && totalObjectsToUpdate === 0 && console.log(chalk.green('No changes made'))
|
|
122
|
+
})
|
|
120
123
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
await index.browseObjects({
|
|
125
|
-
query: '',
|
|
126
|
-
batch: batch => {
|
|
127
|
-
recordCount += batch.length
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
console.log(chalk.green('Total records:', recordCount))
|
|
132
|
-
} catch (err) {
|
|
133
|
-
logger.error(JSON.stringify(err))
|
|
134
|
-
}
|
|
124
|
+
process.on('exit', () => {
|
|
125
|
+
httpAgent.destroy()
|
|
126
|
+
httpsAgent.destroy()
|
|
135
127
|
})
|
|
136
128
|
}
|
|
137
129
|
|