Skip to content

Commit 3bd92e2

Browse files
author
Donna-Marie Smith
committed
Merge branch 'main' of https://github.com/CortexIntelligentAutomation/docs into feature/hide-unsupported-version
2 parents 2768d19 + a103d9f commit 3bd92e2

File tree

1,465 files changed

+87642
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,465 files changed

+87642
-248
lines changed

.github/workflows/checklink.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ jobs:
3636
# For maximum backward compatibility with Hugo modules
3737
HUGO_ENVIRONMENT: production
3838
HUGO_ENV: production
39-
run: hugo --environment GitHubPages -d $GITHUB_WORKSPACE/dist
39+
run: hugo --environment GitHubPages -d $GITHUB_WORKSPACE/dist --buildFuture
40+
- name: Generate Search index
41+
run: |
42+
node ./assets/js/generate-lunr-index.js $GITHUB_WORKSPACE/dist
4043
- name: Test HTML
4144
uses: wjdp/htmltest-action@master
4245
with:

.github/workflows/hugo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
HUGO_ENV: production
6464
run: |
6565
hugo --environment GitHubPages
66+
- name: Generate Search index
67+
run: |
68+
node ./assets/js/generate-lunr-index.js
6669
- name: Upload artifact
6770
uses: actions/upload-pages-artifact@v3
6871
with:

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
docs/
2+
!docs/CNAME
23
public/
34
resources/
45
node_modules/
@@ -7,4 +8,5 @@ content/en/docs/latest/
78
content/static/latest/
89
content/static/**/*.dtmp
910
content/static/**/*.bkp
10-
content/static/**/*.crswap
11+
content/static/**/*.crswap
12+
content/static/lunr-index.json

.htmltest.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ IgnoreURLs:
2626
- "https://jsonformatter.org/.*"
2727
- "https://www.newtonsoft.com/.*"
2828
- "https://.*.gov.uk/.*"
29-
29+
- "https://www.elastic.co/.*"
30+
- "https://www.connectionstrings.com/.*"
3031
IgnoreDirs:
3132
- "docs/?.*/_print/"
3233
- "docs/?.*/_shared/"

assets/js/generate-lunr-index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const fs = require('fs');
2+
const lunr = require('lunr');
3+
4+
/**
5+
* This script is used to generate a lunr index from the offline-search-index.json file.
6+
* Hugo must be built before running this script, as jt requires the offline-search-index.json file to have been generated.
7+
*
8+
* The script will output a lunr-index.json file in the content/static directory and the docs directory.
9+
*/
10+
11+
const args = process.argv.slice(2);
12+
13+
// Arguments should only be provided from a pipeline build.
14+
const isFromPipeline = args[0] !== undefined;
15+
16+
const source = isFromPipeline
17+
? args[0]
18+
: "./docs";
19+
20+
const destination = isFromPipeline
21+
? `${args[0]}`
22+
: "./docs";
23+
24+
const data = JSON.parse(fs.readFileSync(`${source}/offline-search-index.json`));
25+
26+
const idx = lunr(function () {
27+
this.ref('ref');
28+
this.field('title', { boost: 5 });
29+
this.field('categories', { boost: 3 });
30+
this.field('tags', { boost: 3 });
31+
this.field('description', { boost: 2 });
32+
this.field('body');
33+
34+
data.forEach((doc) => {
35+
if (doc
36+
&& doc.ref !== undefined
37+
&& !doc.ref.includes('/_shared/')
38+
) {
39+
this.add(doc);
40+
}
41+
});
42+
});
43+
44+
if (!isFromPipeline) {
45+
fs.writeFileSync(`./content/static/lunr-index.json`, JSON.stringify(idx));
46+
}
47+
48+
fs.writeFileSync(`${destination}/lunr-index.json`, JSON.stringify(idx));
49+
50+
// check if file got created
51+
if (!fs.existsSync(`${destination}/lunr-index.json`)) {
52+
console.error('Failed to create lunr index, hugo must be build using `hugo` command before running this script.');
53+
process.exit(1);
54+
}

0 commit comments

Comments
 (0)