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) => {
5959
6060 await fetcher()
6161 .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 )
7372 .catch((error) => {
7473 throw new Error(error)
7574 })
docs/.vitepress/theme/components/Feedback.vue +2 −23
@@ -61,24 +61,6 @@ function getPrompt() {
6161 return prompts[Math.floor(Math.random() * prompts.length)]
6262}
6363
64const 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
78function getMessage(type: FeedbackType['type']) {
79 return messages[type][Math.floor(Math.random() * messages[type].length)]
80}
81
8264const loading = ref<boolean>(false)
8365const error = ref<unknown>(null)
8466const success = ref<boolean>(false)
@@ -149,7 +131,6 @@ const helpfulDescription = props.heading
149131 : 'Let us know how helpful this page is.'
150132
151133const prompt = computed(() => getPrompt())
152const message = computed(() => getMessage(feedback.type!))
153134const toggleCard = () => (isCardShown.value = !isCardShown.value)
154135</script>
155136
@@ -200,11 +181,11 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value)
200181 </div>
201182 </div>
202183 <div v-else-if="feedback.type && !success">
203 <div>
184 <div class="mb-2">
204185 <p class="desc">{{ helpfulDescription }} - {{ prompt }}</p>
205186 <span>{{ getFeedbackOption(feedback.type)?.label }}</span>
206187 </div>
207 <p class="heading" v-text="message"></p>
188
208189 <div v-if="feedback.type === 'suggestion'" class="mb-2 text-sm">
209190 <details>
210191 <summary>
@@ -366,9 +347,7 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value)
366347
367348.desc {
368349 display: block;
369 line-height: 20px;
370350 font-size: 12px;
371 font-weight: 500;
372351 color: var(--vp-c-text-2);
373352}
374353
docs/.vitepress/types/Feedback.ts +16 −6
@@ -17,7 +17,14 @@ import z from 'zod'
1717
1818export const FeedbackSchema = z.object({
1919 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 ]),
2128 page: z.string().url(),
2229 // For heading based feedback
2330 heading: z.string().min(3).max(20).optional()
@@ -31,11 +38,15 @@ export interface Option {
3138export const feedbackOptions: Option[] = [
3239 {
3340 label: '➕ Submit link',
34 value: "suggestion"
41 value: 'submit'
3542 },
36 {
43 {
44 label: '❗️ Update link',
45 value: 'update'
46 },
47 {
3748 label: '❌ Report bad / dead link',
38 value: "suggestion"
49 value: 'report'
3950 },
4051 {
4152 label: '💡 Suggest edit',
@@ -45,8 +56,7 @@ export const feedbackOptions: Option[] = [
4556 label: '❤️ Love the wiki',
4657 value: 'appreciation'
4758 },
48 { label: '💬 Something else',
49 value: 'other' }
59 { label: '💬 Something else', value: 'other' }
5060]
5161
5262export function getFeedbackOption(
package.json +1
@@ -1,5 +1,6 @@
11{
22 "name": "@wotaku/repo",
3 "version": "0",
34 "type": "module",
45 "scripts": {
56 "postinstall": "nitropack prepare",