Skip to content

Commit 0de3c53

Browse files
NjuelleAschen
authored andcommitted
KZL-747 algolia on doc v2 (#113)
* [CSS] update rule to have focus style * [build]remove unused config version file * [build] update algolia creds * [tmp] Deploy to master with failing tests (#112) * [fix] Deploy to master with failing tests * Update .travis.yml Co-Authored-By: alexandrebouthinon <bouthinon.alexandre@gmail.com> * [front] update search and algolia behavior * [build] clean build process * [clean] remove console.log * [build] add algolia encrypted key * [build] add algolia encrypted key * [Clean] remove console log
1 parent 3244879 commit 0de3c53

File tree

10 files changed

+15
-36
lines changed

10 files changed

+15
-36
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
- secure: CEIMGeEcS+zpdiRXAripOJxwUg5rbmO8pe4u+zm5eteoLA6idQNUEi4o2F2pyWFNZy95B3BiM3ZSMStwdJwu3tZ4cjmX3XnU5GN26tw4wYsM2bW3iNH5xi1pxjtyFTwT9h6JL+mMxOBbPK8DmOPSWEWVMkAs+bw1GLOOMHQ3q29qXUwEDrb4+SS8mAXlWmQSFT+lQVGtRbvu38F6m24qSFQVL2mB/VKty3meByvkddaKShTrhsk867eR1pAvBBjtQHiyVCGaKHHspeOsWjfnnIr2I5CEWFlHSCOQgtY7obS5G0LmNcoApc/aAEYUWcSZ1TIoY0KtK+LyTkKNzB1oaqbVt0ZlrPJUt7fXSlBKyM/UbZ8NFCsIJ+Yi/dXUrD99cPONJK4sVBO9YLmZEpVWfGd1NJs6isULZJoqqbNb9XQ59uZpR9jo9ZyR7IUsHcshQAN8mH0EJLbRtiAN9m3bA89DkdEMWph9UmwBtKYC52JHne6ENClMAk7K/IgzB20iYd4B8M5a6k43DpDUaNf6gjkhL6RrR0ssiNJsI3QmdcYodf2mDlJuYnVmaHpb8dcUBC8ImcVjYKuDst32RXvkAYKvpCy67A2FDuZ1F2CE+hbA7fIaYsN5UkkcF6nYcNJMZ6PF76WQ+2j2UgLVGOvAl91lpoo1P07fzM4P5j9bnc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o2SiizmLLCCdwA7ocfN7UNjpvib4izjNvkYMpLLglA0VfTWXld66L9BlzQyV1/N24NGmiV5rzlyN/OE1lnxu+n+01HweRmUrz42tbutVe2VcecJES9fxW85Pol5CaOHNhAwSO2Wh0NzKIhuWWSdpoEPGCawPT+qJ62BsIqNKDp3sNXE9TtozVVQIkb7PNSqzux0JFDbB4A4AT1iZzGoYOn4SnpOGNv98aLvmNHfu7kWkpreYxGQxl87Oof2AnzXjc5sb4fhkYeVS56XjafkAuZOrZQ=
15+
# ALGOLIA PRIVATE KEY
16+
- secure: "GBlzbEAylEiZhWfyiSZalTd03PWhjuEGPISdyKTwzI5FDyLj4lOjscftICecOmkYm9v6Q8rFEeMXfd9LP35AGQCFYPkMyJlIPdywcSVPpG+WF0iS18fD0TQeuRKdhR9XQ0fAhIFmnXjusWjk04I61UVuXBIJefUcA75aqjeo6Op+uLYNTJ9OVWkdLcOgsyvnNn1qSnXCU76vC4GUFEYnlzM7E1SZbtrfzSMWnBTjOPsebZQXph365D8E3/wcyy0QxxW+VUAQBYqoh7Zvgl+cFKt7DS4dNZ+BKbr6+wl6A1z2KMHvssvu7pC+ruo/6LWwkhdCnOs+5VHgvc9Uq191OERAsaxIvPaMipP/kNyImPWnBypTVfFJJAkK72V4jVNn00RNsRnJHIJBl3RhfxLsebJwXvLfZ8qmKRjY+yIYiAp6W42DikQFtNA/ad80wAj9j5Pv5vZ/PO3YvgXrLVm2Ap+0DKFVkRh+VECSF6IsAGNsDgevPEsOhzv5Yu9Ewwnu4dwAmT/0Ibc8zAEKMUwrUV1LAKrepMmiBNngk4MjX8MUiH5fUQCTP1VyTlbheX12jfIg0MwsSyc0WYpHvVlN7uhyDqVpdzuU+dzA8eyNb6FTDiVDQCaaeZqIn3KBsTQw1SK3lG4r0z/Ft+nFck2X2rPbOAJoWTl1vZ5dZ+JADyE="
1517

1618
addons:
1719
apt:

config/metalsmith.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"path": "/"
1313
},
1414
"algolia": {
15-
"projectId": "4RFBRWISJR",
16-
"index": "",
17-
"publicKey": "6febf1ebe906bd82bce58d5a20ac6c1b",
15+
"projectId": "VF5HP4ZVDU",
16+
"index": "doc-v2",
17+
"publicKey": "de63216cd8d0116b2755916b9a38ae35",
1818
"privateKey": null,
1919
"fnFileParser": null
2020
},

config/versions.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

helpers/manageArgs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const manageArgs = (args, options) => {
2-
console.log(args);
32

43
if (args.dev) {
54
options.dev.enabled = true;

index.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const saveSrc = require('./plugins/save-src');
3333
const anchors = require('./plugins/anchors');
3434

3535
// configuration
36-
const versionsConfig = require('./config/versions');
3736
const msDefaultOpts = require('./config/metalsmith');
3837
const sdkVersions = JSON.stringify(ymlRead.sync(path.join(__dirname, './test/sdk-versions.yml'))).replace(/\s+/g, '');
3938

@@ -76,27 +75,15 @@ const redirectList = {
7675
//If you need others, add it here
7776
};
7877

79-
for (const version of versionsConfig) {
80-
if (version.version_path === options.build.path) {
81-
log(`Using version ${color.bold(version.version_label)}`);
82-
83-
options.github.repository = version.version_gh_repo;
84-
options.github.branch = version.version_gh_branch;
85-
options.algolia.index = version.algolia_index;
86-
}
87-
}
88-
8978
options.algolia.fnFileParser = (file, data) => {
9079
const objects = [];
9180
const $ = cheerio.load(data.contents.toString(), {
9281
normalizeWhitespace: true
9382
});
94-
const content = $('.main-content');
83+
const content = $('.md-content');
9584

9685
// remove useless content
97-
$('.hljs', content).remove();
98-
$('blockquote', content).remove();
99-
$('.language-tab-selector', content).remove();
86+
$('pre', content).remove();
10087
$('h1, h2, h3, h4, h5, h6', content).remove();
10188

10289
objects.push({
@@ -109,7 +96,7 @@ options.algolia.fnFileParser = (file, data) => {
10996
firstMember: (data.ancestry.firstMember ? data.ancestry.firstMember.title : ''),
11097
toc: data.toc
11198
});
112-
99+
113100
return objects;
114101
};
115102

@@ -126,7 +113,6 @@ const metalsmith = _metalsmith(__dirname)
126113
algolia_projectId: options.algolia.projectId,
127114
algolia_publicKey: options.algolia.publicKey,
128115
algolia_index: options.algolia.index,
129-
versions_config: versionsConfig,
130116
is_dev: options.dev.enabled,
131117
sdkVersions: sdkVersions,
132118
exclude: options.exclude

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Kuzzle Documentation",
55
"main": "index.js",
66
"scripts": {
7-
"build": "node index.js --gzip",
7+
"build": "node index.js --gzip --algolia-private-key $ALGOLIA_KEY",
88
"dev": "node index.js --dev --watch",
99
"lint": "eslint --max-warnings=0 *.js ./test/lib ./test/test ./helpers ./scaffolding/lib ./plugins",
1010
"snippets-testing": "bash run-all-snippet-tests.sh",

src/assets/js/algolia-search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var algoliaSearch = {
66
init: function() {
77
var self = this;
88
var client = algoliasearch(algolia_projectId, algolia_publicKey);
9-
var index = client.initIndex('kuzzle-documentation');
9+
var index = client.initIndex(algolia_index);
1010
var searchBar = $('.md-search__input');
1111
var searchTrigger = $('#search');
1212
var resultList = $('.md-search-result__list');
@@ -41,7 +41,7 @@ var algoliaSearch = {
4141
setResults: function(hits, container) {
4242
var content = '';
4343
for (var k in hits) {
44-
var teaser = hits[k]._snippetResult.content.value;
44+
var teaser = hits[k]._highlightResult.content.value;
4545
content +=
4646
'<li class="md-search-result__item">' +
4747
'<a href="' +

src/assets/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/stylesheets/layout/_search.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ $md-toggle__search--checked: '[data-md-toggle="search"]:checked ~ .md-header';
467467
overflow: hidden;
468468

469469
// Active or hovered link
470-
&[data-md-state='active'],
470+
&:focus,
471471
&:hover {
472472
background-color: transparentize($md-color-accent, 0.9);
473473

src/templates/partials/loadScript.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script type="text/javascript" data-packer="exclude">
2-
var site_url = 'https://docs.kuzzle.io/';
2+
var site_url = 'https://docs-v2.kuzzle.io/';
33
var site_base_path = '/';
44
var algolia_projectId = '{{ algolia_projectId }}';
5+
var algolia_index = '{{ algolia_index }}';
56
var algolia_publicKey = '{{ algolia_publicKey }}';
67
var sdkVersions = '{{ sdkVersions }}';
78

0 commit comments

Comments
 (0)