Skip to content

Commit 6f8b92c

Browse files
committed
fix: upgrade DocSearch to v4 and add version boosting
Signed-off-by: Neeraj Deshmukh <neerajd002@gmail.com>
1 parent 19aa25f commit 6f8b92c

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

_includes/head.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="description" content="{% if page.summary %}{{ page.summary | strip_html | strip_newlines | truncate: 160 }}{% endif %}">
99
<meta name="keywords" content="{{page.tags}}{% if page.tags %}, {% endif %} {{page.keywords}}">
10+
{% if page.url contains '/lb4/' %}
11+
<meta name="docsearch:version" content="lb4" />
12+
{% elsif page.url contains '/lb3/' %}
13+
<meta name="docsearch:version" content="lb3" />
14+
{% elsif page.url contains '/lb2/' %}
15+
<meta name="docsearch:version" content="lb2" />
16+
{% endif %}
1017
<title>{{ page.title }} | {{ site.site_title }}</title>
1118
<link rel="stylesheet" href="{{base}}/css/syntax.css">
1219

_layouts/default.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
});
2222
</script>
2323
{% endif %}
24-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/>
24+
<link rel="preconnect" href="https://JHHAZ68MS2.algolia.net" crossorigin />
25+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@4"/>
2526

2627

27-
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
28+
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@4"></script>
2829
</head>
2930
<body>
3031
{% include topnav.html %}
@@ -45,13 +46,22 @@
4546
<!-- /.container -->
4647
</div>
4748
<script type="text/javascript">
49+
const path = window.location.pathname;
50+
let currentVersion = 'lb4';
51+
52+
if (path.includes('/lb3/')) {
53+
currentVersion = 'lb3';
54+
} else if (path.includes('/lb2/')) {
55+
currentVersion = 'lb2';
56+
}
4857
docsearch({
4958
appId: 'JHHAZ68MS2',
5059
apiKey: 'd5ea594dd98a77b9e4b27fb69776fa9f',
5160
indexName: 'loopback',
5261
container: '#algolia-docsearch',
5362
searchParameters: {
54-
facetFilters: ['lang:en']
63+
facetFilters: ['language:en'],
64+
optionalFilters: [`version:${currentVersion}`]
5565
}
5666
});
5767

0 commit comments

Comments
 (0)