-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.vue
More file actions
201 lines (188 loc) · 4.85 KB
/
Copy pathapp.vue
File metadata and controls
201 lines (188 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<script async setup lang="ts">
// Nuxt version 3.13.1: https://github.com/nuxt/nuxt/issues/29674
import { ref } from 'vue';
import {
AisInstantSearchSsr,
AisRefinementList,
AisInfiniteHits,
AisConfigure,
AisPagination,
createServerRootMixin,
//@ts-ignore
} from 'vue-instantsearch/vue3/es';
import { renderToString } from 'vue/server-renderer';
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
import { useRequestURL } from 'nuxt/app';
const indexName = 'guitar-chords';
const searchClient = typesenseInstantsearchAdapter().searchClient;
const url = useRequestURL();
const routing = {
router: historyRouter({
//@ts-ignore
getLocation() {
return url;
},
cleanUrlOnDispose: true,
}),
};
// https://algolia.nuxtjs.org/advanced/vue-instantsearch/
const serverRootMixin = ref(
createServerRootMixin({
searchClient,
indexName,
future: {
preserveSharedStateOnUnmount: true,
},
routing: routing,
})
);
const { instantsearch } = serverRootMixin.value.data();
provide('$_ais_ssrInstantSearchInstance', instantsearch);
onBeforeMount(() => {
// Use data loaded on the server
if (algoliaState.value) {
instantsearch.hydrate(algoliaState.value);
}
});
const { data: algoliaState } = await useAsyncData('algolia-state', async () => {
return instantsearch.findResultsState({
// IMPORTANT: a component with access to `this.instantsearch` to be used by the createServerRootMixin code
component: {
$options: {
components: {
AisInstantSearchSsr,
AisConfigure,
AisRefinementList,
AisInfiniteHits,
AisPagination,
},
data() {
return { instantsearch };
},
provide: { $_ais_ssrInstantSearchInstance: instantsearch },
render() {
return h(AisInstantSearchSsr, null, () => [
// Include any vue-instantsearch components that you use including each refinement attribute
h(AisRefinementList, { attribute: 'key' }),
h(AisRefinementList, { attribute: 'suffix' }),
h(AisRefinementList, { attribute: 'positions.capo' }),
h(AisInfiniteHits),
h(AisConfigure),
]);
},
},
},
renderToString,
});
});
</script>
<template>
<main class="main">
<Heading />
<ais-instant-search-ssr
:search-client="searchClient"
index-name="guitar-chords"
:routing="routing"
>
<SearchAndFilter />
<ais-configure :hitsPerPage="12" />
<InfiniteHits />
</ais-instant-search-ssr>
</main>
</template>
<style>
:root {
/* @link https://utopia.fyi/type/calculator?c=320,15,1.25,1240,20,1.414,5,2,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
--step--2: clamp(0.6rem, 0.5913rem + 0.0435vw, 0.625rem);
--step--1: clamp(0.75rem, 0.7035rem + 0.2326vw, 0.8838rem);
--step-0: clamp(0.9375rem, 0.8288rem + 0.5435vw, 1.25rem);
--step-1: clamp(1.1719rem, 0.9647rem + 1.0359vw, 1.7675rem);
--step-2: clamp(1.465rem, 1.1052rem + 1.7989vw, 2.4994rem);
--step-3: clamp(1.8313rem, 1.2391rem + 2.9609vw, 3.5338rem);
--step-4: clamp(2.2888rem, 1.3468rem + 4.7098vw, 4.9969rem);
--step-5: clamp(2.8613rem, 1.3989rem + 7.312vw, 7.0656rem);
--100: #fff;
--200: #fafafa;
--300: #e4e4e4;
--400: #ababab;
--500: #363637;
--600: #252529;
--700: #1e1e20;
--800: #1b1b1f;
--900: #161618;
--txt-200: rgba(255, 255, 245, 0.86);
--txt-300: rgba(235, 235, 235, 0.6);
--accent: #ed0e73;
--primary-glow: conic-gradient(
from 180deg at 50% 50%,
#ed0e73 0deg,
hsla(210, 100%, 52%, 0.2) 55deg,
#54d6ff33 140deg,
#00dc8069 160deg,
transparent 360deg
);
--pad-top: 1rem;
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
width: 100vw;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
overflow-x: hidden !important;
}
body {
color: var(--700);
background-color: var(--100);
}
a {
color: inherit;
text-decoration: none;
}
a,
button {
cursor: pointer;
}
.main {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: calc(3rem + 3.5vmax) 1rem;
min-height: 100vh;
min-height: 100dvh;
gap: 5rem;
width: 100%;
max-width: 1200px;
margin: auto;
position: relative;
}
.ais-InstantSearch {
display: flex;
width: 100%;
align-items: flex-start;
gap: 2rem;
min-height: 474px;
}
.ais-InfiniteHits-loadMore,
.ais-RefinementList-showMore {
padding: 6px 12px;
border-radius: 5px;
color: var(--700);
background-color: #fff0;
border: 1px solid var(--700);
transition: all 0.25s;
}
.ais-InfiniteHits-loadMore:hover,
.ais-RefinementList-showMore:hover {
background-color: var(--700);
color: var(--100);
}
.ais-RefinementList-showMore:disabled {
display: none;
}
</style>