From ea68d21ddab1fbeecbd0eed4b31639ec8cde83b3 Mon Sep 17 00:00:00 2001 From: ossfx43d8146f Date: Fri, 20 Nov 2026 00:21:52 +0000 Subject: [PATCH] :sparkles: Add OpenSearch search integration Closes #43 - read the initial search query from q, with query as a compatibility fallback - start that search on page load and keep q in the URL after submit - expose an OpenSearch description so Firefox and compatible browsers can install the site as a search engine --- src/components/App.vue | 35 ++++++++++++++++++++++++++++------- src/components/AppHeader.vue | 13 ++++++++----- src/index.html | 3 ++- src/public/opensearch.xml | 16 ++++++++++++++++ 4 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 src/public/opensearch.xml diff --git a/src/components/App.vue b/src/components/App.vue index 651cb1f..745c185 100755 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -19,12 +19,18 @@ AppMain, AppFooter }, - 'data': () => ({ - isLoading: false, - items: [], - filterData: undefined, - filters: undefined - }), + data(){ + const urlParams = new URLSearchParams(window.location.search); + const initialQuery = (urlParams.get('q') || urlParams.get('query') || '').trim(); + + return { + initialQuery, + isLoading: false, + items: [], + filterData: undefined, + filters: undefined + }; + }, computed: { apiUrl: () => apiUrl, filteredItems: function(){ @@ -67,8 +73,19 @@ } }, methods: { + updateSearchUrl: function(query){ + const url = new URL(window.location.href); + url.searchParams.delete('query'); + if(query) + url.searchParams.set('q', query); + else + url.searchParams.delete('q'); + window.history.replaceState(window.history.state, '', url); + }, search: async function(query){ + query = (query || '').trim(); this.isLoading = true; + this.updateSearchUrl(query); this.filterData = undefined; this.items.splice(0, this.items.length); try { @@ -133,12 +150,16 @@ } ); window._sentry = Sentry; + + if(this.initialQuery) + this.search(this.initialQuery); } };