Skip to content

Commit de92227

Browse files
markzegarellirchinn1pwsegforstisabella
committed
Engage beta (#330)
* init * first batch of stubs + fix active nav * menu complete * add id res [netlify-build] * refactor nav [netlify-build] * Update nav * Added diff checker * merge diffs in Build Journeys article * home page nav * replace incorrect ' character which breaks Algolia * reconfig deploy * set the right index name * don't ignore * update metadata * Update csv-upload.md * working search :) * fix notes * add support contact page * Added placeholder for missing content * add beta blurb * Update template.md * Update SMS Template * Update editor.md * Update editor.md * Update template links * SMS link updates * update search pill color * Update index.md * fix links * small edits * Update use-cases.md * link update * use case images * Update use-cases.md * Update links * Add email template link * small edits * Update template.md * Update build-journey.md * pre launch updates * build-journey edits * [netlify-ignore] no debug on engage search * Onboarding Page Content * Content doc edits * Subscriptions Overview Content * Email Campaigns Content * SMS Campaigns Content * Update email-campaigns.md * edits * Update onboarding.md * Update onboarding.md * Update onboarding.md * Update onboarding.md * Update src/_data/sidenav/engage.yml Co-authored-by: forstisabella <[email protected]> * Update src/connections/destinations/catalog/customer-io/index.md Co-authored-by: forstisabella <[email protected]> * Update src/connections/destinations/catalog/optimizely-web/index.md Co-authored-by: forstisabella <[email protected]> * Update src/connections/storage/warehouses/redshift-useful-sql.md Co-authored-by: forstisabella <[email protected]> * Update src/connections/storage/warehouses/redshift-useful-sql.md Co-authored-by: forstisabella <[email protected]> Co-authored-by: rchinn-segment <[email protected]> Co-authored-by: pwseg <[email protected]> Co-authored-by: forstisabella <[email protected]>
1 parent 1fa1e33 commit de92227

File tree

251 files changed

+3757
-641
lines changed

Some content is hidden

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

251 files changed

+3757
-641
lines changed

.yarn/install-state.gz

-901 KB
Binary file not shown.

_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ plugins:
5656
- jekyll-last-modified-at
5757
- jekyll-dotenv
5858
algolia:
59+
max_record_size: 20000
5960
application_id: UINQ2M4D9S
6061
index_name: segment-docs
6162
files_to_exclude:
@@ -72,4 +73,5 @@ algolia:
7273
- searchable(hidden)
7374
- searchable(tags)
7475
- searchable(title)
76+
- searchable(engage)
7577
- type

js/algolia/index.js

+90-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ const apiKey = envApiKey != null ? envApiKey : sampleApiKey;
1616
const placeHolder = envApiKey != null ? 'Search the Segment documentation' : 'Search disabled locally'
1717

1818
const searchClient = algoliasearch(appId, apiKey);
19+
const loc = window.location.pathname
1920

2021
//insights
2122
insightsClient('init', { appId, apiKey, useCookie: true });
2223
const algoliaInsightsPlugin = createAlgoliaInsightsPlugin({ insightsClient });
2324

2425
// define locations to separate invocation for mobile and desktop
2526
const locations = ['#autocomplete','#autocomplete-mobile'];
27+
const engage_locations = ['#engage-autocomplete']
2628

2729
function initAutocomplete(item){
2830
const search = autocomplete({
@@ -54,7 +56,7 @@ function initAutocomplete(item){
5456
query,
5557
params: {
5658
hitsPerPage: 7,
57-
facetFilters: ['hidden:-true', 'engage:-true'],
59+
facetFilters: ['hidden:-true','engage:-true'],
5860
clickAnalytics: true,
5961
},
6062
},
@@ -104,4 +106,90 @@ function initAutocomplete(item){
104106

105107
}
106108

107-
locations.forEach(initAutocomplete);
109+
function initEngageAutocomplete(item){
110+
const search = autocomplete({
111+
container: item,
112+
placeholder: "Search the Twilio Engage documentation",
113+
debug: false,
114+
openOnFocus: false,
115+
keyboardShortcuts: ['s', 191],
116+
plugins: [algoliaInsightsPlugin,],
117+
detachedMediaQuery:'none',
118+
getSources( {query} ) {
119+
return [
120+
{
121+
sourceId: 'articles',
122+
getItemUrl({ item }){
123+
if (item.anchor != null) {
124+
var itemUrl = '/docs'+item.url+"#" + item.anchor;
125+
} else {
126+
var itemUrl = '/docs'+item.url;
127+
}
128+
return itemUrl;
129+
},
130+
getItems() {
131+
return getAlgoliaResults({
132+
searchClient,
133+
queries: [
134+
{
135+
indexName: 'segment-docs',
136+
query,
137+
params: {
138+
hitsPerPage: 7,
139+
facetFilters: ['hidden:-true'],
140+
clickAnalytics: true,
141+
},
142+
},
143+
],
144+
});
145+
},
146+
templates: {
147+
item({ item, createElement }){
148+
if (item.anchor != null) {
149+
var anchorLink = "#" + item.anchor;
150+
} else {
151+
var anchorLink = "";
152+
}
153+
154+
if (item.engage){
155+
var engage = "<span class='engage-pill'>Engage</span>"
156+
}
157+
return createElement('div',{
158+
dangerouslySetInnerHTML: {
159+
__html: `<a class="aa-link" href="/docs${item.url}${anchorLink}">
160+
<p class="aa-title" >${highlightHit({hit: item, attribute: 'title'})} ${engage}</h3>
161+
<p class="aa-content">${highlightHit({hit: item, attribute: 'content'})}</p></a>`
162+
}
163+
})
164+
},
165+
noResults() {
166+
return html `<p class="aa-content">No results for <strong>${query}</strong></p>`;
167+
}
168+
},
169+
170+
},
171+
];
172+
},
173+
navigator: {
174+
navigate({ itemUrl }) {
175+
window.location.assign(itemUrl);
176+
},
177+
navigateNewTab({ itemUrl }) {
178+
const windowReference = window.open(itemUrl, '_blank', 'noopener');
179+
180+
if (windowReference) {
181+
windowReference.focus();
182+
}
183+
},
184+
navigateNewWindow({ itemUrl }) {
185+
window.open(itemUrl, '_blank', 'noopener');
186+
},
187+
},
188+
});
189+
190+
}
191+
if (loc.startsWith("/docs/engage")) {
192+
engage_locations.forEach(initEngageAutocomplete)
193+
} else {
194+
locations.forEach(initAutocomplete);
195+
}

netlify.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
ignore = "./scripts/ignore.sh"
1313

1414
[context.branch-deploy]
15-
command = "yarn develop"
16-
ignore = "./scripts/ignore.sh"
15+
command = "jekyll algolia && yarn build"
16+
# ignore = "./scripts/ignore.sh"
1717

1818
[context.develop]
1919
command = "yarn develop"

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"browser-sync": "^2.27.7",
5050
"check-links": "^1.1.8",
5151
"clipboard": "^2.0.8",
52+
"diff": "^5.0.0",
5253
"dotenv": "^10.0.0",
5354
"enquirer": "^2.3.6",
5455
"fast-csv": "^4.3.6",

scripts/engage-compare.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const fm = require('front-matter');
4+
const yaml = require('js-yaml');
5+
const Diff = require('diff')
6+
const ora = require('ora')
7+
const {
8+
type
9+
} = require('os');
10+
const pages = yaml.load(fs.readFileSync(path.resolve(__dirname, `../src/_data/engage-compare.yml`)))
11+
12+
13+
const compare = async () => {
14+
let title = ""
15+
let engage_path = ""
16+
let personas_path = ""
17+
18+
19+
for (const key in pages) {
20+
title = pages[key].title
21+
engage_path = pages[key].engage
22+
personas_path = pages[key].personas
23+
const throbber = ora(`${title}`).start()
24+
25+
const engage_article = path.resolve(engage_path)
26+
const personas_article = path.resolve(personas_path)
27+
28+
try {
29+
const e = fm(fs.readFileSync(engage_article, 'utf8')).body;
30+
const p = fm(fs.readFileSync(personas_article, 'utf8')).body;
31+
const diff = Diff.diffChars(p, e)
32+
33+
if (diff.length > 1) {
34+
throbber.fail(`${title} has diffs!`)
35+
} else {
36+
throbber.succeed()
37+
}
38+
39+
40+
} catch (e) {
41+
console.log(e)
42+
return false
43+
}
44+
45+
}
46+
}
47+
48+
compare()

0 commit comments

Comments
 (0)