mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-29 14:38:50 +00:00
+1
-1
@@ -56,7 +56,7 @@ pipeline:
|
|||||||
tag: latest
|
tag: latest
|
||||||
secrets: [docker_username, docker_password, algolia_app_id, algolia_admin_key]
|
secrets: [docker_username, docker_password, algolia_app_id, algolia_admin_key]
|
||||||
environment:
|
environment:
|
||||||
- ALGOLIA_INDEX_NAME="dev_docs"
|
- ALGOLIA_INDEX_NAME="prod_docs"
|
||||||
- ALGOLIA_INDEX_FILE="public/algolia.json"
|
- ALGOLIA_INDEX_FILE="public/algolia.json"
|
||||||
build_args_from_env:
|
build_args_from_env:
|
||||||
- ALGOLIA_APP_ID
|
- ALGOLIA_APP_ID
|
||||||
|
|||||||
+1
-10
@@ -168,16 +168,7 @@ gulp.task('pub-delete', () => {
|
|||||||
|
|
||||||
|
|
||||||
gulp.task('build:search-index', (cb) => {
|
gulp.task('build:search-index', (cb) => {
|
||||||
const env = process.env;
|
const opts = {stdio: 'inherit'};
|
||||||
|
|
||||||
env.ALGOLIA_APP_ID = '30NEY6C9UY';
|
|
||||||
env.ALGOLIA_INDEX_NAME = isProduction ? 'prod_docs' : 'dev_docs';
|
|
||||||
env.ALGOLIA_INDEX_FILE = 'public/algolia.json';
|
|
||||||
|
|
||||||
const opts = {
|
|
||||||
stdio: 'inherit',
|
|
||||||
env: env
|
|
||||||
};
|
|
||||||
return spawn(process.cwd()+'/scripts/build-algolia.js', opts).on('close', (/* code */) => {
|
return spawn(process.cwd()+'/scripts/build-algolia.js', opts).on('close', (/* code */) => {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ const {
|
|||||||
const md5 = require('md5');
|
const md5 = require('md5');
|
||||||
const atomicalgolia = require("atomic-algolia");
|
const atomicalgolia = require("atomic-algolia");
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
|
||||||
const indexName = isProduction ? "prod_docs" : "dev_docs";
|
|
||||||
const nue = [];
|
const nue = [];
|
||||||
const rawdata = fs.readFileSync('public/algolia.json');
|
const rawdata = fs.readFileSync('public/algolia.json');
|
||||||
const nodes = JSON.parse(rawdata);
|
const nodes = JSON.parse(rawdata);
|
||||||
@@ -22,7 +20,7 @@ nodes.forEach(node => {
|
|||||||
title: '',
|
title: '',
|
||||||
content: '',
|
content: '',
|
||||||
postref: node.objectID,
|
postref: node.objectID,
|
||||||
objectID: md5(node.permalink),
|
objectID: null,
|
||||||
permalink: node.permalink
|
permalink: node.permalink
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,14 +58,17 @@ nodes.forEach(node => {
|
|||||||
paragraphOut.content = content.textContent;
|
paragraphOut.content = content.textContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// limit the content to 10k so we dont blow up just incase someone decides to make a 40k blog post in one paragraph ¯\_(ツ)_/¯
|
if (paragraphOut.content) {
|
||||||
paragraphOut.content = paragraphOut.content.substr(0, 8000);
|
// limit the content to 10k so we dont blow up just incase someone decides to make a 40k blog post in one paragraph ¯\_(ツ)_/¯
|
||||||
|
paragraphOut.content = paragraphOut.content.substr(0, 18000);
|
||||||
|
|
||||||
// objectID is not quite unique yet so hash the entire object
|
// objectID is not quite unique yet so hash the entire object
|
||||||
paragraphOut.objectID = md5(JSON.stringify(paragraphOut));
|
paragraphOut.objectID = md5(JSON.stringify(paragraphOut));
|
||||||
|
|
||||||
|
|
||||||
nue.push(paragraphOut);
|
nue.push(paragraphOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// remove potentially large content (see size limits) and replace with teh summary so that we don't get results with zero highlightable results
|
// remove potentially large content (see size limits) and replace with teh summary so that we don't get results with zero highlightable results
|
||||||
node.content = node.summary;
|
node.content = node.summary;
|
||||||
@@ -81,7 +82,7 @@ const merged = [...nodes, ...nue];
|
|||||||
|
|
||||||
// fs.writeFileSync('public/combined.algolia.json', JSON.stringify(merged));
|
// fs.writeFileSync('public/combined.algolia.json', JSON.stringify(merged));
|
||||||
// process.exit(0);
|
// process.exit(0);
|
||||||
atomicalgolia(indexName, merged, (err, result) => {
|
atomicalgolia(process.env.ALGOLIA_INDEX_NAME, merged, (err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log(result);
|
console.log(result);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ const bootstrapDocsSearch = function() {
|
|||||||
apiKey: 'b7f43c16886fec97b87981e9e62ef1a5',
|
apiKey: 'b7f43c16886fec97b87981e9e62ef1a5',
|
||||||
indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs',
|
indexName: window.location.host === 'rancher.com' ? 'prod_docs' : 'dev_docs',
|
||||||
routing: true,
|
routing: true,
|
||||||
|
searchFunction: function(helper) {
|
||||||
|
if (helper.state.query === "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
helper.search();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
search.addWidget(
|
search.addWidget(
|
||||||
|
|||||||
Reference in New Issue
Block a user