Merge branch 'buscador' into 'master'
Codificar correctamente los parámetros de búsqueda See merge request sutty/jekyll/sutty-base-jekyll-theme!15
This commit is contained in:
commit
93e35ebf66
1 changed files with 4 additions and 3 deletions
|
@ -16,10 +16,10 @@ export default class extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
connect () {
|
connect () {
|
||||||
const q = window.location.search.match(/^\?q=(?<q>.*)&?/)
|
const q = new URLSearchParams(window.location.search).get('q').trim()
|
||||||
|
|
||||||
if (q) {
|
if (q) {
|
||||||
this.qTarget.value = decodeURI(q.groups.q)
|
this.qTarget.value = q
|
||||||
this.search()
|
this.search()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,9 @@ export default class extends Controller {
|
||||||
const template = await request.text()
|
const template = await request.text()
|
||||||
const html = await this.engine.parseAndRender(template, { q, site, results })
|
const html = await this.engine.parseAndRender(template, { q, site, results })
|
||||||
const title = `${site.i18n.search.title} - ${q}`
|
const title = `${site.i18n.search.title} - ${q}`
|
||||||
|
const query = new URLSearchParams({ q })
|
||||||
|
|
||||||
window.history.pushState({ q }, title, `?q=${encodeURI(q)}`)
|
window.history.pushState({ q }, title, `?${query.toString()}`)
|
||||||
document.title = title
|
document.title = title
|
||||||
|
|
||||||
main.innerHTML = html
|
main.innerHTML = html
|
||||||
|
|
Loading…
Reference in a new issue