merge: Choosing search engines for search mfm (!547)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/547

Approved-by: Luna <her@mint.lgbt>
Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
dakkar 2024-06-13 07:58:06 +00:00
commit fef64e9c69
9 changed files with 85 additions and 6 deletions

View file

@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store';
const props = defineProps<{
q: string;
@ -21,9 +22,10 @@ const props = defineProps<{
const query = ref(props.q);
const search = () => {
const sp = new URLSearchParams();
sp.append('q', query.value);
window.open(`https://www.google.com/search?${sp.toString()}`, '_blank', 'noopener');
const searchQuery = encodeURIComponent(query.value);
const searchUrl = defaultStore.state.searchEngine.replace(/{query}|%s\b/g, searchQuery);
window.open(searchUrl, '_blank', 'noopener');
};
</script>