Skip to content

Commit fa2278e

Browse files
committed
Fix spacing and add https in search page
1 parent 86cd749 commit fa2278e

File tree

1 file changed

+129
-129
lines changed

1 file changed

+129
-129
lines changed

themes/vue/layout/search-page.ejs

Lines changed: 129 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,160 @@
11
<div id="search-page">
2-
<form class="search-form">
3-
<input
4-
class="search-query"
5-
v-model="search"
6-
placeholder="Search VueJS"
7-
>
8-
<p v-if="totalResults">
9-
<strong>{{ totalResults }} results</strong> found in {{ queryTime }}ms
10-
</p>
11-
</form>
2+
<form class="search-form">
3+
<input
4+
class="search-query"
5+
v-model="search"
6+
placeholder="Search Vue.js"
7+
>
8+
<p v-if="totalResults">
9+
<strong>{{ totalResults }} results</strong> found in {{ queryTime }}ms
10+
</p>
11+
</form>
1212

13-
<template v-if="results.length">
14-
<search-result
15-
v-for="(result, i) in results"
16-
:key="i"
17-
:result="result"
18-
></search-result>
19-
</template>
13+
<template v-if="results.length">
14+
<search-result
15+
v-for="(result, i) in results"
16+
:key="i"
17+
:result="result"
18+
></search-result>
19+
</template>
2020

21-
<p v-else>No results were found.</p>
21+
<p v-else>No results were found.</p>
2222

23-
<div ref="infiniteScrollAnchor"></div>
23+
<div ref="infiniteScrollAnchor"></div>
2424

2525
</div>
2626

27-
<script src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
28-
<script src="//cdn.jsdelivr.net/algoliasearch.helper/2/algoliasearch.helper.min.js"></script>
29-
<script src="//polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
27+
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
28+
<script src="https://cdn.jsdelivr.net/algoliasearch.helper/2/algoliasearch.helper.min.js"></script>
29+
<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
3030
<script>
3131
var match = window.location.pathname.match(/^\/(v\d+)/)
3232
var version = match ? match[1] : 'v2'
3333
var algolia = algoliasearch('BH4D9OD16A', '85cc3221c9f23bfbaa4e3913dd7625ea')
3434
var algoliaHelper = algoliasearchHelper(algolia, 'vuejs', {
35-
hitsPerPage: 15,
36-
maxValuesPerFacet: 10,
37-
advancedSyntax: true,
38-
facets: ['version'],
35+
hitsPerPage: 15,
36+
maxValuesPerFacet: 10,
37+
advancedSyntax: true,
38+
facets: ['version'],
3939
})
4040
4141
algoliaHelper.addFacetRefinement('version', version)
4242
algoliaHelper.on('result', parseSearchResults)
4343
4444
var searchPage = new Vue({
45-
el: '#search-page',
46-
components: {
47-
'search-result': {
48-
props: {
49-
result: {
50-
type: Object,
51-
required: true,
52-
},
53-
},
54-
render(h) {
55-
var content = []
56-
content.push(h('a', {
57-
attrs: {
58-
class: 'title',
59-
href: this.result.url,
60-
},
61-
domProps: { innerHTML: this.result.title },
62-
}))
63-
if (this.result.summary) {
64-
content.push(h('p', {
65-
attrs: { class: 'summary' },
66-
domProps: { innerHTML: this.result.summary },
67-
}))
68-
}
69-
content.push(h(
70-
'div',
71-
{ attrs: { class: 'breadcrumbs'} },
72-
this.result.breadcrumbs.map(function(breadcrumb) {
73-
return h('span', {
74-
attrs: { class: 'breadcrumb' },
75-
domProps: { innerHTML: breadcrumb },
76-
})
77-
})
78-
))
79-
return h('div', { attrs: { class: 'search-result' } }, content)
80-
}
81-
}
82-
},
83-
data: {
84-
search: (new URL(location)).searchParams.get('q') || '',
85-
totalResults: 0,
86-
queryTime: 0,
87-
results: [],
88-
totalPages: 0,
89-
lastPage: 0,
90-
},
91-
watch: {
92-
search() {
93-
this.updateSearch()
45+
el: '#search-page',
46+
components: {
47+
'search-result': {
48+
props: {
49+
result: {
50+
type: Object,
51+
required: true,
52+
},
53+
},
54+
render(h) {
55+
var content = []
56+
content.push(h('a', {
57+
attrs: {
58+
class: 'title',
59+
href: this.result.url,
60+
},
61+
domProps: { innerHTML: this.result.title },
62+
}))
63+
if (this.result.summary) {
64+
content.push(h('p', {
65+
attrs: { class: 'summary' },
66+
domProps: { innerHTML: this.result.summary },
67+
}))
9468
}
69+
content.push(h(
70+
'div',
71+
{ attrs: { class: 'breadcrumbs'} },
72+
this.result.breadcrumbs.map(function(breadcrumb) {
73+
return h('span', {
74+
attrs: { class: 'breadcrumb' },
75+
domProps: { innerHTML: breadcrumb },
76+
})
77+
})
78+
))
79+
return h('div', { attrs: { class: 'search-result' } }, content)
80+
}
81+
}
82+
},
83+
data: {
84+
search: (new URL(location)).searchParams.get('q') || '',
85+
totalResults: 0,
86+
queryTime: 0,
87+
results: [],
88+
totalPages: 0,
89+
lastPage: 0,
90+
},
91+
watch: {
92+
search() {
93+
this.updateSearch()
94+
}
95+
},
96+
created() {
97+
this.updateSearch()
98+
},
99+
mounted() {
100+
var observer = new IntersectionObserver(function(entries) {
101+
if (entries[0].isIntersecting && searchPage.totalPages > searchPage.lastPage + 1) {
102+
searchPage.addPage()
103+
}
104+
})
105+
observer.observe(this.$refs.infiniteScrollAnchor)
106+
},
107+
methods: {
108+
addPage() {
109+
algoliaHelper.setCurrentPage(this.lastPage + 1).search()
95110
},
96-
created() {
97-
this.updateSearch()
98-
},
99-
mounted() {
100-
var observer = new IntersectionObserver(function(entries) {
101-
if (entries[0].isIntersecting && searchPage.totalPages > searchPage.lastPage + 1) {
102-
searchPage.addPage()
103-
}
104-
})
105-
observer.observe(this.$refs.infiniteScrollAnchor)
111+
updateSearch() {
112+
algoliaHelper.setCurrentPage(0).setQuery(this.search).search()
106113
},
107-
methods: {
108-
addPage() {
109-
algoliaHelper.setCurrentPage(this.lastPage+1).search()
110-
},
111-
updateSearch() {
112-
algoliaHelper.setCurrentPage(0).setQuery(this.search).search()
113-
},
114-
}
114+
}
115115
})
116116
117117
function parseSearchResults(content) {
118-
if (content.query === '' || !(content.hits instanceof Array)) {
119-
searchPage.totalResults = 0
120-
searchPage.queryTime = 0
121-
searchPage.results = []
122-
searchPage.totalPages = 0
123-
searchPage.lastPage = 0
124-
return
125-
}
118+
if (content.query === '' || !(content.hits instanceof Array)) {
119+
searchPage.totalResults = 0
120+
searchPage.queryTime = 0
121+
searchPage.results = []
122+
searchPage.totalPages = 0
123+
searchPage.lastPage = 0
124+
return
125+
}
126126
127-
var results = []
127+
var results = []
128128
129-
for (var hit of content.hits) {
130-
var hierarchy = hit._highlightResult.hierarchy
131-
var titles = []
132-
var level = 0
133-
var levelName
134-
while ((levelName = 'lvl' + level++) in hierarchy) {
135-
titles.push(hierarchy[levelName].value)
136-
}
137-
var summary
138-
if (hit._snippetResult && hit._snippetResult.content) {
139-
summary = hit._snippetResult.content.value + '...'
140-
}
141-
results.push({
142-
title: titles.pop(),
143-
url: hit.url,
144-
summary: summary,
145-
breadcrumbs: titles,
146-
})
129+
for (var hit of content.hits) {
130+
var hierarchy = hit._highlightResult.hierarchy
131+
var titles = []
132+
var level = 0
133+
var levelName
134+
while ((levelName = 'lvl' + level++) in hierarchy) {
135+
titles.push(hierarchy[levelName].value)
136+
}
137+
var summary
138+
if (hit._snippetResult && hit._snippetResult.content) {
139+
summary = hit._snippetResult.content.value + '...'
147140
}
141+
results.push({
142+
title: titles.pop(),
143+
url: hit.url,
144+
summary: summary,
145+
breadcrumbs: titles,
146+
})
147+
}
148148
149-
searchPage.totalResults = content.nbHits
150-
searchPage.queryTime = content.processingTimeMS
151-
searchPage.totalPages = content.nbPages
152-
searchPage.lastPage = content.page
149+
searchPage.totalResults = content.nbHits
150+
searchPage.queryTime = content.processingTimeMS
151+
searchPage.totalPages = content.nbPages
152+
searchPage.lastPage = content.page
153153
154-
if (searchPage.lastPage === 0) {
155-
searchPage.results = results
156-
} else {
157-
searchPage.results = searchPage.results.concat(results)
158-
}
154+
if (searchPage.lastPage === 0) {
155+
searchPage.results = results
156+
} else {
157+
searchPage.results = searchPage.results.concat(results)
158+
}
159159
}
160160
</script>

0 commit comments

Comments
 (0)