Skip to content

Commit b36e117

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: convert public page to single install script tag
1 parent f1cbac6 commit b36e117

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed
+41-31
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,91 @@
11
<pre class="-my-4">
22
<code class="language-javascript">
3-
import { TrieveModalSearch } from 'trieve-search-component';
4-
import 'trieve-search-component/styles';
3+
&lt;link
4+
rel="stylesheet"
5+
href="https://unpkg.com/[email protected]/dist/index.css"
6+
/&gt;
57

6-
const App = () => {
7-
return (
8-
&lt;TrieveModalSearch
8+
&lt;script type="module"&gt;
9+
import {renderToDiv} from 'https://unpkg.com/[email protected]/dist/vanilla/index.js';
10+
window.addEventListener('load', () => {
11+
const root = document.getElementById('root');
12+
renderToDiv(root,
913
{% if params.apiKey -%}
10-
apiKey="{{ params.apiKey }}"
14+
apiKey: "{{ params.apiKey }}",
15+
{% endif -%}
16+
{% if params.datasetId -%}
17+
datasetId: "{{ params.datasetId }}",
1118
{% endif -%}
1219
{% if params.baseUrl -%}
13-
baseUrl="{{ params.baseUrl }}"
20+
baseUrl: "{{ params.baseUrl }}",
1421
{% endif -%}
1522
{% if params.type -%}
16-
type="{{ params.type }}"
23+
type: "{{ params.type }}",
1724
{% endif -%}
1825
{% if params.suggestedQueries -%}
19-
suggestedQueries={{ params.suggestedQueries }}
26+
suggestedQueries: {{ params.suggestedQueries }},
2027
{% endif -%}
2128
{% if params.analytics -%}
22-
analytics={{ params.analytics }}
29+
analytics: {{ params.analytics }},
2330
{% endif -%}
2431
{% if params.tags -%}
25-
tags={{ params.tags }}
32+
tags: {{ params.tags }},
2633
{% endif -%}
2734
{% if params.responsive -%}
28-
responsive={{ params.responsive }}
35+
responsive: {{ params.responsive }},
2936
{% endif -%}
3037
{% if params.chat -%}
31-
chat="{{ params.chat}}"
38+
chat: "{{ params.chat}}",
3239
{% endif -%}
3340
{% if params.theme -%}
34-
theme="{{ params.theme }}"
41+
theme: "{{ params.theme }}",
3542
{% endif -%}
3643
{% if params.search_options -%}
37-
search_options={{ params.searchOptions }}
44+
search_options: {{ params.searchOptions }},
3845
{% endif -%}
3946
{% if params.brandLogoImgSrcUrl -%}
40-
brandLogoImgSrcUrl="{{ params.brandLogoImgSrcUrl }}"
47+
brandLogoImgSrcUrl: "{{ params.brandLogoImgSrcUrl }}",
4148
{% endif -%}
4249
{% if params.brandName -%}
43-
brandName="{{ params.brandName }}"
50+
brandName: "{{ params.brandName }}",
4451
{% endif -%}
4552
{% if params.problemLink -%}
46-
problemLink="{{ params.problemLink }}"
53+
problemLink: "{{ params.problemLink }}",
4754
{% endif -%}
4855
{% if params.brandColor -%}
49-
brandColor="{{ params.brandColor }}"
56+
brandColor: "{{ params.brandColor }}",
5057
{% endif -%}
5158
{% if params.placeholder -%}
52-
placeholder="{{ params.placeholder }}"
59+
placeholder: "{{ params.placeholder }}",
5360
{% endif -%}
5461
{% if params.defaultSearchQueries -%}
55-
defaultSearchQueries={{ params.defaultSearchQueries }}
62+
defaultSearchQueries: {{ params.defaultSearchQueries }},
5663
{% endif -%}
5764
{% if params.defaultAiQuestions -%}
58-
defaultAiQuestions={{ params.defaultAiQuestions }}
65+
defaultAiQuestions: {{ params.defaultAiQuestions }},
5966
{% endif -%}
6067
{% if params.defaultSearchMode -%}
61-
defaultSearchMode="{{ params.defaultSearchMode }}"
68+
defaultSearchMode: "{{ params.defaultSearchMode }}",
6269
{% endif -%}
6370
{% if params.useGroupSearch -%}
64-
useGroupSearch={{ params.useGroupSearch }}
71+
useGroupSearch: {{ params.useGroupSearch }},
6572
{% endif -%}
6673
{% if params.allowSwitchingModes -%}
67-
allowSwitchingModes={{ params.allowSwitchingModes }}
74+
allowSwitchingModes: {{ params.allowSwitchingModes }},
6875
{% endif -%}
6976
{% if params.defaultCurrency -%}
70-
defaultCurrency="{{ params.defaultCurrency }}"
77+
defaultCurrency: "{{ params.defaultCurrency }}",
7178
{% endif -%}
7279
{% if params.currencyPosition -%}
73-
currencyPosition="{{ params.currencyPosition }}"
80+
currencyPosition: "{{ params.currencyPosition }}",
7481
{% endif -%}
7582
{% if params.debounceMs -%}
76-
debounceMs={{ params.debounceMs }}
83+
debounceMs: {{ params.debounceMs }},
7784
{% endif -%}
78-
/&gt;
79-
);
80-
} </code>
85+
86+
)
87+
});
88+
&lt;/script&gt;
89+
90+
</code>
8191
</pre>

0 commit comments

Comments
 (0)