Load search from query

This commit is contained in:
Liam Dyer
2020-04-17 12:58:51 -04:00
parent b114754da7
commit ee06cb0caf
2 changed files with 18 additions and 2 deletions

View File

@@ -32,12 +32,21 @@ export default {
const searchParams = new URLSearchParams()
if (isNotEmpty(titles))
searchParams.append('keywords', titles)
if (isNotEmpty(tags))
if (isNotEmpty(tags))
searchParams.append('tags', R.map(this.removeFirstChar, tags))
this.$router.push(this.searchPath + '?' + searchParams.toString())
},
},
mounted() {
let keywords = this.$route.query.keywords || ''
keywords = keywords.split(',').join(' ')
let tags = this.$route.query.tags || ''
tags = R.filter(this.isTag, tags.split(',')).map(tag => `#${tag}`).join(' ')
this.searchInput = `${tags} ${keywords}`.trim()
},
}
</script>

View File

@@ -56,6 +56,13 @@ export default {
},
mounted() {
this.showTitle = true
const keywords = this.$route.query.keywords
const tags = this.$route.query.tags
this.searchInput = {
keywords: keywords && R.split(',', keywords),
tags: tags && R.split(',', tags),
}
},
methods: {
async createCopyUrl(resource) {