Skip to content

Commit 2570319

Browse files
committed
feat(new tool): Wiktionary Search
Fix CorentinTh#1042
1 parent f49e892 commit 2570319

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Books } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Online Dictionary',
6+
path: '/online-wiktionary',
7+
description: 'Search words in Wiktionary',
8+
keywords: ['online', 'dictionary', 'wiktionary'],
9+
component: () => import('./online-wiktionary.vue'),
10+
icon: Books,
11+
createdAt: new Date('2026-01-03'),
12+
category: 'Data',
13+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script setup>
2+
import { ref } from 'vue';
3+
import { useQueryParamOrStorage } from '@/composable/queryParams';
4+
5+
const query = ref('');
6+
const language = useQueryParamOrStorage({ name: 'lang', storageName: 'wiktionary:l', defaultValue: 'en' });
7+
8+
// Extend this list as needed
9+
const languageOptions = [
10+
{ label: 'English', value: 'en' },
11+
{ label: 'French', value: 'fr' },
12+
{ label: 'German', value: 'de' },
13+
{ label: 'Spanish', value: 'es' },
14+
{ label: 'Italian', value: 'it' },
15+
{ label: 'Russian', value: 'ru' },
16+
{ label: 'Chinese', value: 'zh' },
17+
{ label: 'Japanese', value: 'ja' },
18+
{ label: 'Arabic', value: 'ar' },
19+
];
20+
21+
const iframeUrl = ref('');
22+
function openSearch() {
23+
const encoded = encodeURIComponent(query.value.trim());
24+
iframeUrl.value = `https://${language.value}.wiktionary.org/wiki/Special:Search?search=${encoded}`;
25+
}
26+
</script>
27+
28+
<template>
29+
<div>
30+
<n-form-item label="" label-placement="left">
31+
<n-input
32+
v-model:value="query"
33+
placeholder="Enter a word…"
34+
clearable
35+
mr-1
36+
/>
37+
38+
<n-select
39+
v-model:value="language"
40+
:options="languageOptions"
41+
placeholder="Select a language"
42+
filterable
43+
/>
44+
</n-form-item>
45+
46+
<n-space justify="center">
47+
<n-button
48+
type="primary"
49+
:disabled="!query || !language"
50+
@click="openSearch"
51+
>
52+
Search on Wiktionary
53+
</n-button>
54+
</n-space>
55+
56+
<n-divider />
57+
58+
<div style="height: 70vh; border: 1px solid #ddd; border-radius: 6px; overflow: hidden;">
59+
<iframe
60+
v-if="iframeUrl"
61+
:src="iframeUrl"
62+
style="width: 100%; height: 100%; border: none;"
63+
/>
64+
<div v-else style="padding: 1rem; text-align: center; color: #888;">
65+
Enter a word and select a language to load Wiktionary
66+
</div>
67+
</div>
68+
</div>
69+
</template>

0 commit comments

Comments
 (0)