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