Commit 46c301af72

46c301af725092b3c5c309f1b532a81659ef37ed

parent: 12477b9242

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-05-11 04:48 UTC

improve feedback prompt

Layout: unified · split

docs/.vitepress/theme/components/Feedback.vue +12 −16
@@ -13,6 +13,7 @@ import {
13 type FeedbackType, 13 type FeedbackType,
14 getFeedbackOption 14 getFeedbackOption
15} from '../../types/Feedback' 15} from '../../types/Feedback'
16import { resolvePrompts } from '../../utils/promptConfig'
16 17
17const props = defineProps<{ 18const props = defineProps<{
18 heading?: string 19 heading?: string
@@ -29,21 +30,17 @@ const sluggify = (text: string) =>
29const getURL = (heading: string) => 30const getURL = (heading: string) =>
30 `https://wotaku.wiki${withBase(router.route.path)}#${sluggify(heading)}` 31 `https://wotaku.wiki${withBase(router.route.path)}#${sluggify(heading)}`
31 32
32const prompts = [ 33const router = useRouter()
33 "Tips: Starring our GitHub repo increases the chances of your feedback being accepted twofold.", 34
34 "Tips: Keep your feedback precise.", 35/**
35 "Tips: Don't ask us questions as we can't really answer you here, join our Discord instead.", 36 * Resolve the prompt pool once on mount.
36 "Tips: If you are submitting a scraper site, mention all the sources.", 37 * Re-evaluates reactively if the route changes (SPA navigation).
37 "Tips: English, motherf**ker, do you speak it?!", 38 */
38 "Fun fact: We don't maintain any extension repos, complaining to us won't solve your issue.", 39const promptPool = computed(() => resolvePrompts(router.route.path))
39 "Fun fact: We can't really add or fix any type of extensions.", 40
40 "Fun fact: Meme is evil and has almost taken over the wiki.", 41function getPrompt(): string {
41 "Fun fact: Bloat ≠ quality.", 42 const pool = promptPool.value
42 "Damn! We got a visitor!" 43 return pool[Math.floor(Math.random() * pool.length)]
43]
44
45function getPrompt() {
46 return prompts[Math.floor(Math.random() * prompts.length)]
47} 44}
48 45
49const loading = ref<boolean>(false) 46const loading = ref<boolean>(false)
@@ -58,7 +55,6 @@ const isDisabled = computed(() => {
58 ) 55 )
59}) 56})
60 57
61const router = useRouter()
62// prettier-ignore 58// prettier-ignore
63const feedback = reactive< 59const feedback = reactive<
64 Pick<FeedbackType, 'message' | 'page'> & Partial<Pick<FeedbackType, 'type'>> 60 Pick<FeedbackType, 'message' | 'page'> & Partial<Pick<FeedbackType, 'type'>>
docs/.vitepress/utils/promptConfig.ts added +60
@@ -0,0 +1,60 @@
1export interface PromptRule {
2 pattern: string
3 prompts: string[]
4 includeDefault?: boolean
5}
6
7export const DEFAULT_PROMPTS: string[] = [
8 "Tips: Starring our GitHub repo increases the chances of your feedback being accepted twofold.",
9 "Tips: Keep your feedback precise.",
10 "Tips: Don't ask us questions as we can't really answer you here, join our Discord instead.",
11 "Tips: You should read rules before submitting links.",
12 "Tips: English, motherf**ker, do you speak it?!",
13 "Fun fact: Meme is evil and has almost taken over the wiki.",
14 "Fun fact: Bloat ≠ quality.",
15 "Damn! We got a visitor!"
16]
17
18export const PAGE_PROMPT_CONFIG: PromptRule[] = [
19 {
20 pattern: "/ext/*",
21 prompts: [
22 "Fun fact: We don't maintain any extension repos, complaining to us won't solve your issue.",
23 "Fun fact: We can't really add or fix any type of extensions.",
24 "Tips: Visit the extensions homepage to see which apps support which extension systems."
25 ]
26 },
27 {
28 pattern: "/websites",
29 includeDefault: true,
30 prompts: [
31 "Tips: If you are submitting a scraper site, mention all the sources.",
32 ]
33 },
34 {
35 pattern: "/japan/*",
36 prompts: [
37 "We're in urgent need of some solid contributions right now, especially on the software side of things."
38 ]
39 }
40]
41
42function matchPattern(pattern: string, path: string): boolean {
43 if (pattern.endsWith("/*")) {
44 const base = pattern.slice(0, -2)
45 return path === base || path.startsWith(base + "/") || path.startsWith(base)
46 }
47 return path === pattern
48}
49
50export function resolvePrompts(path: string): string[] {
51 const matched = PAGE_PROMPT_CONFIG.find((rule) =>
52 matchPattern(rule.pattern, path)
53 )
54
55 if (!matched) return DEFAULT_PROMPTS
56
57 return matched.includeDefault
58 ? [...matched.prompts, ...DEFAULT_PROMPTS]
59 : matched.prompts
60}\ No newline at end of file