Commit a5cac01984
a5cac019846a8a26cb781a788eb034d71cd2c779
parent: 4973603d39
Unregistered key
taskylizard <75871323+taskylizard@users.noreply.github.com> · 2025-05-24 15:51 UTC
feat: update feedback types
Layout: unified · split
api/routes/index.post.ts
+10 −11
| @@ -59,17 +59,16 @@ export default defineEventHandler(async (event) => { |
| 59 | 59 | |
| 60 | 60 | await fetcher() |
| 61 | 61 | .post(env.WEBHOOK_URL, { |
| 62 | | username: 'Feedback', |
| 63 | | avatar_url: |
| 64 | | 'https://i.kym-cdn.com/entries/icons/facebook/000/043/403/cover3.jpg', |
| 65 | | embeds: [ |
| 66 | | { |
| 67 | | color: 3447003, |
| 68 | | title: getFeedbackOption(type)!.label, |
| 69 | | fields |
| 70 | | } |
| 71 | | ] |
| 72 | | }) |
| 62 | username: 'Feedback', |
| 63 | embeds: [ |
| 64 | { |
| 65 | color: 3447003, |
| 66 | title: getFeedbackOption(type)!.label, |
| 67 | fields |
| 68 | } |
| 69 | ] |
| 70 | } |
| 71 | ) |
| 73 | 72 | .catch((error) => { |
| 74 | 73 | throw new Error(error) |
| 75 | 74 | }) |
docs/.vitepress/theme/components/Feedback.vue
+2 −23
| @@ -61,24 +61,6 @@ function getPrompt() { |
| 61 | 61 | return prompts[Math.floor(Math.random() * prompts.length)] |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | | const messages = { |
| 65 | | suggestion: [ |
| 66 | | "We're glad you want to share your ideas!", |
| 67 | | 'Nix the fluff and just tell us what you think!', |
| 68 | | "We'll be happy to read your thoughts and incorporate them into our wiki.", |
| 69 | | "Hello! We're glad you want to share your ideas!" |
| 70 | | ], |
| 71 | | appreciation: [ |
| 72 | | 'We appreciate your support!', |
| 73 | | "We're always looking for ways to improve!" |
| 74 | | ], |
| 75 | | other: ["We're always looking for ways to improve!"] |
| 76 | | } |
| 77 | | |
| 78 | | function getMessage(type: FeedbackType['type']) { |
| 79 | | return messages[type][Math.floor(Math.random() * messages[type].length)] |
| 80 | | } |
| 81 | | |
| 82 | 64 | const loading = ref<boolean>(false) |
| 83 | 65 | const error = ref<unknown>(null) |
| 84 | 66 | const success = ref<boolean>(false) |
| @@ -149,7 +131,6 @@ const helpfulDescription = props.heading |
| 149 | 131 | : 'Let us know how helpful this page is.' |
| 150 | 132 | |
| 151 | 133 | const prompt = computed(() => getPrompt()) |
| 152 | | const message = computed(() => getMessage(feedback.type!)) |
| 153 | 134 | const toggleCard = () => (isCardShown.value = !isCardShown.value) |
| 154 | 135 | </script> |
| 155 | 136 | |
| @@ -200,11 +181,11 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value) |
| 200 | 181 | </div> |
| 201 | 182 | </div> |
| 202 | 183 | <div v-else-if="feedback.type && !success"> |
| 203 | | <div> |
| 184 | <div class="mb-2"> |
| 204 | 185 | <p class="desc">{{ helpfulDescription }} - {{ prompt }}</p> |
| 205 | 186 | <span>{{ getFeedbackOption(feedback.type)?.label }}</span> |
| 206 | 187 | </div> |
| 207 | | <p class="heading" v-text="message"></p> |
| 188 | |
| 208 | 189 | <div v-if="feedback.type === 'suggestion'" class="mb-2 text-sm"> |
| 209 | 190 | <details> |
| 210 | 191 | <summary> |
| @@ -366,9 +347,7 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value) |
| 366 | 347 | |
| 367 | 348 | .desc { |
| 368 | 349 | display: block; |
| 369 | | line-height: 20px; |
| 370 | 350 | font-size: 12px; |
| 371 | | font-weight: 500; |
| 372 | 351 | color: var(--vp-c-text-2); |
| 373 | 352 | } |
| 374 | 353 | |
docs/.vitepress/types/Feedback.ts
+16 −6
| @@ -17,7 +17,14 @@ import z from 'zod' |
| 17 | 17 | |
| 18 | 18 | export const FeedbackSchema = z.object({ |
| 19 | 19 | message: z.string().min(5).max(1000), |
| 20 | | type: z.enum(['suggestion', 'appreciation', 'other']), |
| 20 | type: z.enum([ |
| 21 | 'submit', |
| 22 | 'update', |
| 23 | 'report', |
| 24 | 'suggestion', |
| 25 | 'appreciation', |
| 26 | 'other' |
| 27 | ]), |
| 21 | 28 | page: z.string().url(), |
| 22 | 29 | // For heading based feedback |
| 23 | 30 | heading: z.string().min(3).max(20).optional() |
| @@ -31,11 +38,15 @@ export interface Option { |
| 31 | 38 | export const feedbackOptions: Option[] = [ |
| 32 | 39 | { |
| 33 | 40 | label: '➕ Submit link', |
| 34 | | value: "suggestion" |
| 41 | value: 'submit' |
| 35 | 42 | }, |
| 36 | | { |
| 43 | { |
| 44 | label: '❗️ Update link', |
| 45 | value: 'update' |
| 46 | }, |
| 47 | { |
| 37 | 48 | label: '❌ Report bad / dead link', |
| 38 | | value: "suggestion" |
| 49 | value: 'report' |
| 39 | 50 | }, |
| 40 | 51 | { |
| 41 | 52 | label: '💡 Suggest edit', |
| @@ -45,8 +56,7 @@ export const feedbackOptions: Option[] = [ |
| 45 | 56 | label: '❤️ Love the wiki', |
| 46 | 57 | value: 'appreciation' |
| 47 | 58 | }, |
| 48 | | { label: '💬 Something else', |
| 49 | | value: 'other' } |
| 59 | { label: '💬 Something else', value: 'other' } |
| 50 | 60 | ] |
| 51 | 61 | |
| 52 | 62 | export function getFeedbackOption( |
package.json
+1
| @@ -1,5 +1,6 @@ |
| 1 | 1 | { |
| 2 | 2 | "name": "@wotaku/repo", |
| 3 | "version": "0", |
| 3 | 4 | "type": "module", |
| 4 | 5 | "scripts": { |
| 5 | 6 | "postinstall": "nitropack prepare", |