Skip to content

Commit 5e240c1

Browse files
committedSep 17, 2021
partial
1 parent 602daaa commit 5e240c1

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed
 

‎.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
PLATFORM_API_TOKEN=look for me in chamber
22
PAPI_TOKEN=get one from a papi-enabled workspace
3+
ALGOLIA_APP_ID=
4+
ALGOLIA_SEARCH_KEY=

‎js/algolia/index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ import {createAlgoliaInsightsPlugin} from '@algolia/autocomplete-plugin-algolia-
55
import insightsClient from 'search-insights';
66

77

8-
const appId = 'UINQ2M4D9S';
9-
const apiKey = '3ecd0f228971adf2d5a4217789ae1765';
8+
const sampleAppId = 'latency';
9+
const sampleApiKey = '6be0576ff61c053d5f9a3225e2a90f76';
10+
const envAppId = process.env.ALGOLIA_APP_ID;
11+
const envApiKey = process.env.ALGOLIA_SEARCH_KEY;
12+
13+
14+
const appId = envAppId != null ? envAppId : sampleAppId;
15+
const apiKey = envApiKey != null ? envApiKey : sampleApiKey;
16+
const placeHolder = envApiKey != null ? 'Search the Segment documentation' : 'Search disabled locally'
17+
1018
const searchClient = algoliasearch(appId, apiKey);
1119

1220
//insights
@@ -19,7 +27,7 @@ const locations = ['#autocomplete','#autocomplete-mobile'];
1927
function initAutocomplete(item){
2028
const search = autocomplete({
2129
container: item,
22-
placeholder: 'Search the Segment documentation',
30+
placeholder: placeHolder,
2331
debug: false,
2432
openOnFocus: false,
2533
keyboardShortcuts: ['s', 191],

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"search-insights": "^1.7.1",
5959
"tap-spot": "^1.1.1",
6060
"tippy.js": "^5.2.0",
61-
"typewriter": "7.0.1"
61+
"typewriter": "7.0.1",
62+
"webpack-dotenv-plugin": "^2.1.0"
6263
}
6364
}

‎src/_layouts/default.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@
233233
// analytics.identify();
234234
}}();
235235
</script>
236-
236+
{%- if site.env.CONTEXT != "production" -%}
237+
<script src="{{ "./assets/docs.delay.js" | relative_url}}"></script>
238+
239+
{%- endif -%}
237240
</body>
238241
</html>

‎src/assets/docs.delay.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
setTimeout(function() {
2+
// document.getElementById("autocomplete-0-input").disabled = true;
3+
}, 1000);

‎webpack.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const path = require('path');
2+
const DotenvPlugin = require('webpack-dotenv-plugin');
3+
24

35
module.exports = {
46
entry: './js/index.js',
@@ -11,6 +13,13 @@ module.exports = {
1113
'analytics': path.resolve('analytics')
1214
}
1315
},
16+
plugins: [
17+
new DotenvPlugin({
18+
sample: './.env.example',
19+
path: './.env',
20+
allowEmptyValues: true,
21+
})
22+
],
1423
module: {
1524
rules: [
1625
{

‎yarn.lock

+19
Original file line numberDiff line numberDiff line change
@@ -3016,11 +3016,23 @@ dot-prop@^5.2.0:
30163016
dependencies:
30173017
is-obj "^2.0.0"
30183018

3019+
dotenv-safe@^5.0.1:
3020+
version "5.0.1"
3021+
resolved "https://registry.yarnpkg.com/dotenv-safe/-/dotenv-safe-5.0.1.tgz#8c4a79b8978fd4271b3d8ef17be2b2f04588af71"
3022+
integrity sha512-NiS92uLQHKThcQIB4pNEQHLaosz+O1VaJ1yuBaZNj0BASGpQliSzfPKgaoFs/WvE+p8pS9STXOMW30b5uxBZog==
3023+
dependencies:
3024+
dotenv "^5.0.0"
3025+
30193026
dotenv@8.2.0:
30203027
version "8.2.0"
30213028
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
30223029
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
30233030

3031+
dotenv@^5.0.0:
3032+
version "5.0.1"
3033+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef"
3034+
integrity sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==
3035+
30243036
duplexer3@^0.1.4:
30253037
version "0.1.4"
30263038
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
@@ -8780,6 +8792,13 @@ webpack-cli@3.3.9:
87808792
v8-compile-cache "2.0.3"
87818793
yargs "13.2.4"
87828794

8795+
webpack-dotenv-plugin@^2.1.0:
8796+
version "2.1.0"
8797+
resolved "https://registry.yarnpkg.com/webpack-dotenv-plugin/-/webpack-dotenv-plugin-2.1.0.tgz#366bb18712f414e8b86aa66408a9039d03dd7165"
8798+
integrity sha1-NmuxhxL0FOi4aqZkCKkDnQPdcWU=
8799+
dependencies:
8800+
dotenv-safe "^5.0.1"
8801+
87838802
webpack-sources@^1.4.0, webpack-sources@^1.4.1:
87848803
version "1.4.3"
87858804
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"

0 commit comments

Comments
 (0)
Please sign in to comment.