Skip to content

Commit be897a1

Browse files
Filter search to camel-core docs only (#1457)
1 parent 5d0857f commit be897a1

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

antora-ui-camel/src/js/vendor/algoliasearch.bundle.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33

44
const algoliasearch = require('algoliasearch/lite')
55

6+
// Sub-projects to exclude from main search - users can browse these directly
7+
const EXCLUDED_SUBPROJECTS = [
8+
'/camel-k/',
9+
'/camel-quarkus/',
10+
'/camel-spring-boot/',
11+
'/camel-kafka-connector/',
12+
'/camel-kamelets/',
13+
'/camel-karaf/',
14+
]
15+
16+
// Check if a URL belongs to a sub-project that should be filtered out
17+
function isSubProjectUrl (url) {
18+
if (!url) return false
19+
return EXCLUDED_SUBPROJECTS.some(function (subproject) {
20+
return url.indexOf(subproject) !== -1
21+
})
22+
}
23+
624
window.addEventListener('load', () => {
725
const client = algoliasearch('V62SL4FFIW', '1b7e52df4759e32dd49adedb286997f6')
826
const index = client.initIndex('apache_camel')
@@ -46,11 +64,14 @@
4664
cancel.style.display = 'block'
4765
index
4866
.search(search.value, {
49-
hitsPerPage: 5,
67+
hitsPerPage: 10,
5068
})
5169
.then((results) => {
52-
const hits = results.hits
53-
const data = hits.reduce((data, hit) => {
70+
// Filter out sub-project results to focus on camel-core documentation
71+
const filteredHits = results.hits.filter(function (hit) {
72+
return !isSubProjectUrl(hit.url)
73+
}).slice(0, 5)
74+
const data = filteredHits.reduce((data, hit) => {
5475
const section = hit.hierarchy.lvl0
5576
const sectionKey = `${section}-${hit.version || ''}`
5677

0 commit comments

Comments
 (0)