Skip to content

Commit

Permalink
Test Inkeep AI
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel committed Nov 20, 2024
1 parent 87883bd commit 08e91e7
Show file tree
Hide file tree
Showing 15 changed files with 62,012 additions and 201 deletions.
69 changes: 0 additions & 69 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,72 +67,3 @@ if(main && scrollBtn) {
});
observer.observe(main);
}

function handleSearch(inputSelector) {
const searchConfig = {
inputSelector: inputSelector,
typesenseCollectionName: 'docsearch',
typesenseServerConfig: {
nodes: [{
host: 'cgnvrk0xwyj9576lp-1.a1.typesense.net',
port: '443',
protocol: 'https'
}],
apiKey: 'GHQK6od8KfpvTEh4YpA113gUc2dU5fGR'
},
typesenseSearchParams: {
query_by: 'hierarchy.lvl0,hierarchy.lvl1,url_without_anchor',
query_by_weight: '100,50,1',
sort_by: "_text_match:desc,item_priority:desc",
prioritize_token_position: true,
group_by: "url_without_anchor",
group_limit: 1
},
autocompleteOptions: {
autoselect: false,
debug: false,
hint: false
}
};

const search = docsearch(searchConfig);

let opened = false;
search.autocomplete.on('autocomplete:shown', (e, a, b, c) => {
opened = true;
});
search.autocomplete.on('autocomplete:closed', () => {
opened = false;
});
let cursorUsed = false;
// we can't detect the cursor changing to an empty auto complete entry,
// so the only case where getting to search results via Enter will work is
// text typed followed by Enter.
search.autocomplete.on('autocomplete:cursorchanged', (event, suggestion) => {
cursorUsed = true;
});
// search.autocomplete.on('keydown', (e) => {
// if (opened && !cursorUsed && e.key === 'Enter' && search.input[0].value !== '') {
// const query = encodeURIComponent(search.input[0].value);
// window.location = `${window.location.origin}/search?query=${query}`;
// }
// });
}

handleSearch('.navbar-nav .td-search-input');
handleSearch('.td-sidebar__search .td-search-input');

// Userflow START
!function(){var e="undefined"==typeof window?{}:window,r=e.userflow;if(!r){var t="https://js.userflow.com/",n=null;r=e.userflow={_stubbed:!0,load:function(){return n||(n=new Promise((function(r,o){var s=document.createElement("script");s.async=!0;var a=e.USERFLOWJS_ENV_VARS||{};"es2020"===(a.USERFLOWJS_BROWSER_TARGET||function(e){for(var r=[[/Edg\//,/Edg\/(\d+)/,80],[/OPR\//,/OPR\/(\d+)/,67],[/Chrome\//,/Chrome\/(\d+)/,80],[/Safari\//,/Version\/(\d+)/,14],[/Firefox\//,/Firefox\/(\d+)/,74]],t=0;t<r.length;t++){var n=r[t],o=n[0],s=n[1],a=n[2];if(e.match(o)){var u=e.match(new RegExp(s));if(u&&parseInt(u[1],10)>=a)return"es2020";break}}return"legacy"}(navigator.userAgent))?(s.type="module",s.src=a.USERFLOWJS_ES2020_URL||t+"es2020/userflow.js"):s.src=a.USERFLOWJS_LEGACY_URL||t+"legacy/userflow.js",s.onload=function(){r()},s.onerror=function(){document.head.removeChild(s),n=null;var e=new Error("Could not load Userflow.js");console.error(e.message),o(e)},document.head.appendChild(s)}))),n}};var o=e.USERFLOWJS_QUEUE=e.USERFLOWJS_QUEUE||[],s=function(e){r[e]=function(){var t=Array.prototype.slice.call(arguments);r.load(),o.push([e,null,t])}},a=function(e){r[e]=function(){var t,n=Array.prototype.slice.call(arguments);r.load();var s=new Promise((function(e,r){t={resolve:e,reject:r}}));return o.push([e,t,n]),s}},u=function(e,t){r[e]=function(){return t}};s("_setTargetEnv"),s("closeResourceCenter"),s("init"),s("off"),s("on"),s("prepareAudio"),s("registerCustomInput"),s("remount"),s("reset"),s("setBaseZIndex"),s("setCustomInputSelector"),s("setCustomNavigate"),s("setCustomScrollIntoView"),s("setInferenceAttributeFilter"),s("setInferenceAttributeNames"),s("setInferenceClassNameFilter"),s("setResourceCenterLauncherHidden"),s("setScrollPadding"),s("setShadowDomEnabled"),s("setPageTrackingDisabled"),s("setUrlFilter"),s("openResourceCenter"),s("toggleResourceCenter"),a("endAll"),a("endAllFlows"),a("endChecklist"),a("group"),a("identify"),a("identifyAnonymous"),a("start"),a("startFlow"),a("startWalk"),a("track"),a("updateGroup"),a("updateUser"),u("getResourceCenterState",null),u("isIdentified",!1)}}();

userflow.init("ct_dybdwc2fkna4lmih2zyqb6eune");
userflow.setResourceCenterLauncherHidden(true);

async function initAndClick() {
// unclear why it needs to be called twice but otherwise you need to click the button twice.
await userflow.identifyAnonymous({});
await userflow.identifyAnonymous({});
userflow.openResourceCenter()
}

// Userflow END
72 changes: 0 additions & 72 deletions assets/js/search-results.js

This file was deleted.

26 changes: 0 additions & 26 deletions assets/js/search.js

This file was deleted.

33 changes: 19 additions & 14 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1847,12 +1847,29 @@ a.ais-Pagination-link:hover {
min-height: 90%;
}

// Helper to allow search to link to tabs

.search-helper {
// Search START

#sideSearchBar {
display: none;
max-width: 100%;
width: 100%;
}

@media (max-width: 992px) {

#navSearchBar {
display: none;
}

#sideSearchBar {
display: unset;
}

}

// Search END

// styling for model list from registry

.searchhitsbox {
Expand Down Expand Up @@ -2156,18 +2173,6 @@ h3.body-header[style] {
margin-right: 1rem;
}

.algolia-autocomplete .typesense-docsearch-suggestion--subcategory-column {
display: none !important;
float:left;
width:0 !important;
padding-left:0;
padding:0px;
}

.algolia-autocomplete .typesense-docsearch-suggestion--content {
width: 100% !important;
}

// Front page styling START

.frontpage h2 {
Expand Down
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ privacy_policy = "https://www.viam.com/privacy"
includes_dir = "_includes"
archived_version = false
url_latest_version = "https://docs.viam.com/"
algolia_docsearch = true
algolia_docsearch = false
offlineSearch = false
prism_syntax_highlighting = true
images = ["https://assets-global.website-files.com/62fba5686b6d47fe2a1ed2a6/63404a4db2c39ec3fbf1ed31_viam-open-graph-images.png"]
Expand Down
2 changes: 1 addition & 1 deletion layouts/docs/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</main>
{{ $img := resources.GetMatch "/icons/learn-viam-robot-icon-ai.svg" }}
</div>
<button onclick="initAndClick()" class="docsbutton" id="chatButton" title="Chatbot and support">
<button class="docsbutton" id="chatButton" title="Chatbot and support">
<span id="chatButtonContent">
<i style="font-size:x-large;" class="fas fa-comments"></i>
<span>Ask AI</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/docs/glossary.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h4 id="{{ printf "%s" $term_identifier }}" class="glossary-anchor">{{ .Title }}
</main>
</div>
{{ $img := resources.GetMatch "/icons/learn-viam-robot-icon-ai.svg" }}
<button onclick="initAndClick()" class="docsbutton" id="chatButton" title="Chatbot and support">
<button class="docsbutton" id="chatButton" title="Chatbot and support">
<span id="chatButtonContent">
<i style="font-size:x-large;" class="fas fa-comments"></i>
<span>Ask AI</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/docs/howto.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h4 class="alert-heading">Javascript</h4>
</main>
</div>
{{ $img := resources.GetMatch "/icons/learn-viam-robot-icon-ai.svg" }}
<button onclick="initAndClick()" class="docsbutton" id="chatButton" title="Chatbot and support">
<button class="docsbutton" id="chatButton" title="Chatbot and support">
<span id="chatButtonContent">
<i style="font-size:x-large;" class="fas fa-comments"></i>
<span>Ask AI</span>
Expand Down
6 changes: 1 addition & 5 deletions layouts/docs/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>{{ .Title }}</h1>
</main>
</div>
{{ $img := resources.GetMatch "/icons/learn-viam-robot-icon-ai.svg" }}
<button onclick="initAndClick()" class="docsbutton" id="chatButton" title="Chatbot and support">
<button class="docsbutton" id="chatButton" title="Chatbot and support">
<span id="chatButtonContent">
<i style="font-size:x-large;" class="fas fa-comments"></i>
<span>Ask AI</span>
Expand All @@ -53,9 +53,5 @@ <h1>{{ .Title }}</h1>

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

{{ $jsSearchResults := resources.Get "js/search-results.js" }}
{{ $jsSearchResults := $jsSearchResults | minify }}
<script type="text/javascript" src="{{ $jsSearchResults.RelPermalink }}" crossorigin="anonymous"></script>

</body>
</html>
2 changes: 1 addition & 1 deletion layouts/docs/tutorials.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h4 class="alert-heading">Javascript</h4>
</main>
</div>
{{ $img := resources.GetMatch "/icons/learn-viam-robot-icon-ai.svg" }}
<button onclick="initAndClick()" class="docsbutton" id="chatButton" title="Chatbot and support">
<button class="docsbutton" id="chatButton" title="Chatbot and support">
<span id="chatButtonContent">
<i style="font-size:x-large;" class="fas fa-comments"></i>
<span>Ask AI</span>
Expand Down
1 change: 0 additions & 1 deletion layouts/partials/hooks/head-end.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typesense-docsearch.js@1/dist/cdn/docsearch.min.css" />
<script>
window.Prism = window.Prism || {};
Prism.manual = true;
Expand Down
7 changes: 6 additions & 1 deletion layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</script>
{{ end }}

<!-- INKEEP start -->
<script type="text/javascript" src="/js/embed.js" crossorigin="anonymous" defer></script>
<!-- INKEEP end -->

<!-- START script for lazy loading -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js"></script>
{{ $jsLozad := resources.Get "js/lozad.js" }}
Expand Down Expand Up @@ -103,7 +107,7 @@
integrity='sha512-ZA/RPrAo88DlwRnnoNVqKINnQNcWERzRK03PDaA4GIJiVZvGFIWQbdWCsUebMZfkWohnfngsDjXzU6PokO4jGw==' crossorigin='anonymous'
{{ printf "onload='renderMathInElement(%s, %s);'" (( .Site.Params.katex.html_dom_element | default "document.body" ) | safeJS ) ( printf "%s" ( $.Site.Params.katex.options | jsonify )) | safeHTMLAttr }}></script>
{{ end }}
<script src="https://cdn.jsdelivr.net/npm/typesense-docsearch.js@1/dist/cdn/docsearch.min.js"></script>


{{ $jsIndex := resources.Get "js/index.js" }}
{{ $jsPrismViam := resources.Get "js/prism.js" }}
Expand Down Expand Up @@ -132,4 +136,5 @@
<script async src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous"></script>
<script async src="{{ $jsSentry.RelPermalink }}" crossorigin="anonymous"></script>
{{ end }}

{{ partial "hooks/body-end.html" . }}
14 changes: 6 additions & 8 deletions layouts/partials/sidebar-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
{{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}}
<div id="td-sidebar-menu" class="td-sidebar__inner{{ if $shouldDelayActive }} d-none{{ end }}">
{{ if not .Site.Params.ui.sidebar_search_disable -}}
<form class="td-sidebar__search d-flex align-items-center">
{{ partial "search-input.html" . }}
<div class="td-sidebar__search d-flex align-items-center" id="mobile-search">
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation" title="Toggle section navigation">
</button>
</form>
</div>
{{ else -}}
<div id="content-mobile">
<form class="td-sidebar__search d-flex align-items-center">
{{ partial "search-input.html" . }}
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation" title="Toggle section navigation">
</button>
</form>
<div class="td-sidebar__search d-flex align-items-center" id="mobile-search">
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation" title="Toggle section navigation">
</button>
</div>
</div>
<div id="content-desktop"></div>
{{ end -}}
Expand Down
3 changes: 3 additions & 0 deletions static/css/inkeep.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#inkeep-widget-root * .ikp-btn {
border-radius: 0 !important;
}
Loading

0 comments on commit 08e91e7

Please sign in to comment.