Skip to content

Commit e6019d9

Browse files
Added Ask AI feature
1 parent 808839c commit e6019d9

13 files changed

Lines changed: 483 additions & 0 deletions

File tree

config-geekdoc.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ pluralizeListTitles = false
7171
# Render partial, script and stylesheet for the feedback form
7272
showFeedbackForm = true
7373

74+
aiSearchEndpoint = "https://docsearch.api.aspose.cloud/ask"
75+
aiSearchScopes = [ "viewer_cloud", "conversion_cloud"
76+
]
7477
[Params.Sitemap]
7578
changeFreq = "weekly"
7679
priority = 0.5
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// AI-powered search
2+
3+
.ai-search-invisible {
4+
display: none !important;
5+
}
6+
7+
.ai-search-form {
8+
display: flex;
9+
align-items: center;
10+
height: 30px;
11+
margin-bottom: 10px;
12+
padding: 0px 8px 0px 8px;
13+
border: solid 1px #cccccc;
14+
border-radius: 3px;
15+
background-color: #ffffff;
16+
margin-bottom: 30px;
17+
margin-right: 1px;
18+
position: relative;
19+
20+
21+
&:hover {
22+
border-color: #b2bac1;
23+
}
24+
25+
#aiSearchField {
26+
flex-grow: 1;
27+
margin-right: 7px;
28+
border: none;
29+
outline: none;
30+
font-family: $font-family-base;
31+
color: #222222;
32+
background-color: transparent;
33+
padding-right: 55px;
34+
}
35+
36+
#aiSearchButton {
37+
height: 30px;
38+
padding: 0px 12px;
39+
40+
border: none;
41+
outline: none;
42+
white-space: nowrap;
43+
background-color: #b2bac1;
44+
font-family: $font-family-base;
45+
color: #ffffff;
46+
cursor: pointer;
47+
position: absolute;
48+
right:-1px;
49+
border-bottom-right-radius: 3px;
50+
border-top-right-radius: 3px;
51+
52+
&:hover {
53+
background-color: #8d969d;
54+
}
55+
}
56+
}
57+
58+
#aiSearchResultsCurtain {
59+
z-index: 99;
60+
position: fixed;
61+
top: 0px;
62+
left: 0px;
63+
bottom: 0px;
64+
right: 0px;
65+
background-color: #000000;
66+
opacity: 0.7;
67+
}
68+
69+
#aiSearchResultsForm {
70+
display: flex;
71+
flex-direction: column;
72+
z-index: 100;
73+
position: fixed;
74+
top: 10%;
75+
left: 10%;
76+
bottom: 10%;
77+
right: 10%;
78+
padding: 20px;
79+
border: solid 1px #cccccc;
80+
box-shadow: 0px 0px 5px 3px rgba(68,68,68,1);
81+
background-color: #ffffff;
82+
83+
& > header {
84+
display: flex;
85+
align-items: center;
86+
margin-bottom: 20px;
87+
88+
.ai-search-results-prompt {
89+
display: flex;
90+
flex-grow: 1;
91+
align-items: center;
92+
height: 40px;
93+
padding: 0px 2px 0px 10px;
94+
padding-right: 80px;
95+
border: solid 1px #cccccc;
96+
border-radius: 3px;
97+
background-color: #ffffff;
98+
font-size: 16px;
99+
position: relative;
100+
101+
#aiSearchResultsField {
102+
flex-grow: 1;
103+
margin-right: 7px;
104+
border: none;
105+
outline: none;
106+
font-family: $font-family-base;
107+
color: #222222;
108+
background-color: transparent;
109+
}
110+
111+
#aiSearchResultsButton {
112+
height: 40px;
113+
padding: 0px 18px;
114+
115+
border: none;
116+
outline: none;
117+
white-space: nowrap;
118+
background-color: #558fff;
119+
font-family: $font-family-base;
120+
font-weight: 600;
121+
color: #ffffff;
122+
cursor: pointer;
123+
position: absolute;
124+
right:-1px;
125+
border-top-right-radius: 3px;
126+
border-bottom-right-radius: 3px;
127+
&:hover {
128+
background-color:#4172d4;
129+
}
130+
}
131+
}
132+
133+
.ai-search-results-tools {
134+
margin-left: 15px;
135+
136+
& > img {
137+
width: auto;
138+
height: 25px;
139+
cursor: pointer;
140+
opacity: 1;
141+
142+
&:hover {
143+
opacity: 0.7;
144+
}
145+
}
146+
}
147+
}
148+
149+
& > article {
150+
flex-grow: 1;
151+
overflow: auto;
152+
padding: 10px 0px;
153+
color: rgb(15, 23, 39);
154+
155+
#aiSearchResultsPreloader {
156+
margin-top: 15px;
157+
text-align: center;
158+
159+
& > img {
160+
margin-bottom: 15px;
161+
}
162+
163+
& > p {
164+
color: #666666;
165+
font-style: italic;
166+
}
167+
}
168+
169+
#aiSearchError {
170+
display: none;
171+
font-size: 16px;
172+
font-weight: 500;
173+
color: #aa0000;
174+
}
175+
176+
pre {
177+
padding: 10px;
178+
border: solid 1px #c2c2c2;
179+
background-color: #f8f9fa;
180+
}
181+
}
182+
183+
& > aside {
184+
display: none;
185+
186+
padding: 10px 20px;
187+
border-top: solid 1px #cccccc;
188+
margin: 0 -20px;
189+
margin-top: 20px;
190+
191+
.ai-search-results-title {
192+
margin-top: 5px;
193+
margin-bottom: 15px;
194+
font-weight: 500;
195+
font-size: 18px;
196+
color: rgb(15, 23, 39);
197+
}
198+
199+
#aiSearchRelatedArticles {
200+
display: flex;
201+
flex-wrap: wrap;
202+
align-items: top;
203+
204+
#aiSearchRelatedArticleTemplate {
205+
display: none;
206+
}
207+
208+
& > a {
209+
display: block;
210+
/* min-width: 200px; */
211+
margin: 0px 15px 5px 0px;
212+
padding: 12px 15px;
213+
border-radius: 3px;
214+
215+
text-decoration: none;
216+
white-space: nowrap;
217+
overflow: hidden;
218+
background-color: #f3f5f7;
219+
220+
&:hover {
221+
text-decoration: none;
222+
223+
}
224+
}
225+
}
226+
}
227+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Fonts
2+
3+
$google_font_name: "Arial" !default;
4+
$google_font_family: "Open+Sans:300,300i,400,400i,700,700i" !default;
5+
$web-font-path: "https://fonts.googleapis.com/css?family=#{$google_font_family}";
6+
7+
$td-fonts-serif: sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
8+
9+
// @if $td-enable-google-fonts {
10+
// $td-fonts-serif: prepend($td-fonts-serif, "#{$google_font_name}");
11+
// }
12+
13+
$font-family-sans-serif: $td-fonts-serif !default;
14+
15+
$font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
16+
$font-family-base: $font-family-sans-serif !default;
17+
$font-size-base: 0.875rem !default;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "variables";
2+
@import "ai-search";
3+

themes/hugo-geekdoc/layouts/_default/baseof.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@
3838

3939
{{ partial "site-header" . }}
4040

41+
{{ $aiSearchEnabled := false }}
42+
{{ $url := $.RelPermalink }}
43+
{{ $slittedUrl := split $url "/" }}
44+
{{ $aiSearchScope := (printf "%s_cloud" (index $slittedUrl 1)) }}
45+
{{ if in .Site.Params.aiSearchScopes $aiSearchScope }}
46+
{{ $aiSearchEnabled = true }}
47+
{{ end }}
4148

4249
<main class="container flex flex-even">
4350
{{ if $navEnabled }}
4451
<aside class="gdoc-nav">
52+
{{- if $aiSearchEnabled -}}
53+
{{- partial "ai-search-input" . -}}
54+
{{- end -}}
4555
{{ partial "menu" . }}
4656
</aside>
4757
{{ end }}
@@ -59,6 +69,10 @@
5969

6070
{{ partial "go-top" . }}
6171

72+
{{- if $aiSearchEnabled -}}
73+
{{- partial "ai-search-result" . -}}
74+
{{- end -}}
75+
6276
{{ partial "site-footer" . }}
6377
</div>
6478

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="ai-search-form">
2+
<input id="aiSearchField" type="text" maxlength="150" placeholder="What can I help you with?" autocomplete="off" />
3+
<button id="aiSearchButton">Ask AI</button>
4+
</div>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
{{- $close := resources.Get "icons/close.svg" -}}
3+
{{- $preloader := resources.Get "icons/preloader.svg" -}}
4+
5+
<div id="aiSearchResultsCurtain" class="ai-search-invisible"></div>
6+
<div id="aiSearchResultsForm" class="ai-search-invisible">
7+
<header>
8+
<div class="ai-search-results-prompt">
9+
<input id="aiSearchResultsField" type="text" maxlength="150" placeholder="What can I help you with?" autocomplete="off" />
10+
<button id="aiSearchResultsButton">Ask AI</button>
11+
</div>
12+
<div class="ai-search-results-tools">
13+
<img id="aiSearchResultsClose" src="/img/close.svg" alt="Close" title="Close" />
14+
</div>
15+
</header>
16+
<article>
17+
<div id="aiSearchResultsPreloader">
18+
<img src="/img/preloader.svg" alt="Loading" />
19+
<p>Analyzing your prompt, please hold on...</p>
20+
</div>
21+
<p id="aiSearchError">An error occurred while retrieving the results. Please refresh the page and try again.</p>
22+
<div id="aiSearchResultsSummary"></div>
23+
</article>
24+
<aside>
25+
<div class="ai-search-results-title">Related articles</div>
26+
<div id="aiSearchRelatedArticles">
27+
<a id="aiSearchRelatedArticleTemplate" href="#" target="_blank">-</a>
28+
</div>
29+
</aside>
30+
</div>
31+
32+
{{ $url := $.RelPermalink }}
33+
{{ $slittedUrl := split $url "/" }}
34+
{{ $aiSearchScope := (printf "%s_cloud" (index $slittedUrl 1)) }}
35+
<script>
36+
const aiSearchScope = "{{ $aiSearchScope }}";
37+
const aiSearchEndpoint = "{{ .Site.Params.aiSearchEndpoint }}";
38+
</script>
39+
<script
40+
src="https://code.jquery.com/jquery-3.3.1.min.js"
41+
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
42+
crossorigin="anonymous">
43+
</script>
44+
<script src="/js/showdown.min.js?v=25.2.0"></script>
45+
<script src="/js/thumbmark.umd.js?v=25.2.0"></script>
46+
<script src="/js/ai-search.js?v=25.2.1"></script>

themes/hugo-geekdoc/layouts/partials/head/others.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<script src="{{ index (index .Site.Data.assets "main.js") "src" | relURL }}"></script>
22

3+
{{- $scssMain := "scss/main.scss"}}
4+
{{- $css := resources.Get $scssMain | toCSS | resources.Minify | fingerprint -}}
5+
<link rel="preload" href="{{- $css.RelPermalink -}}" as="style">
6+
<link href="{{- $css.RelPermalink -}}" rel="stylesheet" integrity="{{- $css.Data.integrity -}}">
7+
38
<link
49
rel="preload"
510
as="font"
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)