materiotheme: tab title from the search, safe terms of old URLs (F3)

- Base.vue: the browser tab shows the phrase searched (vue-meta), « Base »
  without a search.
- terms of an old or edited URL parsed without throwing: malformed JSON
  is ignored.
- Production build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShDspHaZGwHoRZCsPBJzsM
This commit is contained in:
2026-11-17 21:14:09 +01:00
co-authored by Claude Opus 5.5
parent fca4be3155
commit 54e7e28046
13 changed files with 26 additions and 9 deletions
@@ -51,7 +51,8 @@ export default {
count: state => state.Search.count,
noresults: state => state.Search.noresults,
limit: state => state.Search.limit,
searchId: state => state.Search.searchId
searchId: state => state.Search.searchId,
keys: state => state.Search.keys
}),
// items is a sparse array (pages placed by offset); drop the holes left by
// pages that returned fewer results than the limit before rendering.
@@ -59,7 +60,23 @@ export default {
return this.items.filter(Boolean)
}
},
// Title of the browser tab: the phrase searched (F3).
metaInfo () {
return {
title: this.keys && this.keys.length ? this.keys.join(', ') : 'Base'
}
},
methods: {
// terms of an URL: a JSON list, possibly malformed in an old or edited
// link; never break the page for it (F3).
parseTerms (value) {
try {
const terms = JSON.parse(value)
return Array.isArray(terms) ? terms : []
} catch (e) {
return []
}
},
...mapActions({
newSearch: 'Search/newSearch',
nextPage: 'Search/nextPage'
@@ -87,7 +104,7 @@ export default {
if (params.has('terms')) {
console.log('Base created, has terms', params.get('terms'))
// this.$store.commit('Search/setTerms', params.get('terms').split(','))
this.$store.commit('Search/setTerms', JSON.parse(params.get('terms')))
this.$store.commit('Search/setTerms', this.parseTerms(params.get('terms')))
} else {
this.$store.commit('Search/reSetTerms')
}
@@ -105,7 +122,7 @@ export default {
// to.query.terms is a raw JSON string (see SearchForm.submit) and must be
// parsed like in created(), otherwise getResults() double-encodes it and
// the backend silently drops the terms (less relevant results).
this.$store.commit('Search/setTerms', JSON.parse(to.query.terms))
this.$store.commit('Search/setTerms', this.parseTerms(to.query.terms))
}else{
this.$store.commit('Search/reSetTerms')
}