docs/.vitepress/types/Feedback.ts

bfb0ea146c9a037574b61c77a9f25e70d13d5e4f
wotaku/docs/.vitepress/types/Feedback.ts history · blame · raw

60 lines · 1325 bytes

 1/**
 2 *  All Rights Reserved
 3 *
 4 *  Copyright (c) 2025 taskylizard
 5 *
 6 *  All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
 7 */
 8import z from 'zod'
 9
10export const FeedbackSchema = z.object({
11  message: z.string().min(5).max(1000),
12  type: z.enum([
13    'submit',
14    'update',
15    'report',
16    'suggestion',
17    'appreciation',
18    'other'
19  ]),
20  page: z.string().url(),
21  // For heading based feedback
22  heading: z.string().min(3).max(20).optional()
23})
24
25export interface Option {
26  label: string
27  value: FeedbackType['type']
28}
29
30export const feedbackOptions: Option[] = [
31  {
32    label: '➕ Submit link',
33    value: 'submit'
34  },
35  {
36    label: '❗ Update link',
37    value: 'update'
38  },
39  {
40    label: '❌ Report bad / dead link',
41    value: 'report'
42  },
43  {
44    label: '💡 Suggest edit',
45    value: 'suggestion'
46  },
47  {
48    label: '❤ Love the wiki',
49    value: 'appreciation'
50  },
51  { label: '💬 Something else', value: 'other' }
52]
53
54export function getFeedbackOption(
55  value: FeedbackType['type']
56): Option | undefined {
57  return feedbackOptions.find((option) => option.value === value)
58}
59
60export type FeedbackType = z.infer<typeof FeedbackSchema>