Skip to content

Commit 4cb3b95

Browse files
author
Donna-Marie Smith
committed
Merge branch 'main' of https://github.com/CortexIntelligentAutomation/docs into feature/new-documentation-structure-for-guides
2 parents 2dd7608 + de3a9f4 commit 4cb3b95

File tree

43 files changed

+756
-655
lines changed

Some content is hidden

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

43 files changed

+756
-655
lines changed

.github/workflows/checklink.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
uses: actions/checkout@v3
1919
with:
2020
submodules: recursive
21+
- name: Update Latest URL content
22+
shell: pwsh
23+
run: |
24+
.\createLatest.ps1
2125
- name: npm install
2226
working-directory: ./
2327
run: |
@@ -32,17 +36,20 @@ jobs:
3236
# For maximum backward compatibility with Hugo modules
3337
HUGO_ENVIRONMENT: production
3438
HUGO_ENV: production
35-
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
3643
- name: Test HTML
3744
uses: wjdp/htmltest-action@master
3845
with:
3946
# For consistency, use the same config file as for local builds
4047
config: .htmltest.yml
4148
- name: Archive htmltest results
4249
if: always()
43-
uses: actions/upload-artifact@v3
50+
uses: actions/upload-artifact@v4
4451
# Note: Set ACTIONS_RUNTIME_TOKEN env variable to test with nektos/act
4552
with:
4653
name: htmltest-report
4754
path: tmp/.htmltest/htmltest.log
48-
retention-days: 7 # Default is 90 days
55+
retention-days: 7 # Default is 90 days

.github/workflows/hugo.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ jobs:
4343
uses: actions/checkout@v3
4444
with:
4545
submodules: recursive
46+
- name: Update Latest URL content
47+
shell: pwsh
48+
run: |
49+
.\createLatest.ps1
4650
- name: npm install
4751
working-directory: ./
4852
run: |
@@ -59,8 +63,11 @@ jobs:
5963
HUGO_ENV: production
6064
run: |
6165
hugo --environment GitHubPages
66+
- name: Generate Search index
67+
run: |
68+
node ./assets/js/generate-lunr-index.js
6269
- name: Upload artifact
63-
uses: actions/upload-pages-artifact@v1
70+
uses: actions/upload-pages-artifact@v3
6471
with:
6572
path: ./docs
6673

@@ -74,4 +81,4 @@ jobs:
7481
steps:
7582
- name: Deploy to GitHub Pages
7683
id: deployment
77-
uses: actions/deploy-pages@v1
84+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
1+
docs/
2+
!docs/CNAME
23
public/
34
resources/
45
node_modules/
56
tech-doc-hugo
7+
content/en/docs/latest/
8+
content/static/latest/
69
content/static/**/*.dtmp
710
content/static/**/*.bkp
8-
content/static/**/*.crswap
11+
content/static/**/*.crswap
12+
content/static/lunr-index.json

.htmltest.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ IgnoreURLs:
2525
- "https://blogs.oracle.com/.*"
2626
- "https://jsonformatter.org/.*"
2727
- "https://www.newtonsoft.com/.*"
28-
- "https://.*/gov.uk/.*"
28+
- "https://.*.gov.uk/.*"
29+
- "https://www.elastic.co/.*"
30+
- "https://www.connectionstrings.com/.*"
2931
IgnoreDirs:
3032
- "docs/?.*/_print/"
3133
- "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)