Last active
March 25, 2026 19:20
-
-
Save freekh/d0eedc92479b681180eaeab072c4486b to your computer and use it in GitHub Desktop.
Val Email Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { s, c, nextAppRouter } from "../../../../../val.config"; | |
| import { proseSchema, proseToString } from "@/components/typography/prose.val"; | |
| const emailPageSchema = s.object({ | |
| sections: s | |
| .array( | |
| s.union( | |
| "type", | |
| // This should be in its own file | |
| s.object({ | |
| type: s.literal("text"), | |
| title: s.string(), | |
| text: proseSchema, | |
| }), | |
| // Add other sections here: hero, footer, image, ... | |
| ), | |
| ) | |
| // Make it prettier in Val Studio | |
| .render({ | |
| as: "list", | |
| select: ({ val }) => { | |
| return { | |
| title: val.title, | |
| subtitle: proseToString(val.text), | |
| }; | |
| }, | |
| }), | |
| }); | |
| export default c.define( | |
| "/src/app/(main)/emails/[type]/page.val.ts", | |
| s.router(nextAppRouter, emailPageSchema), | |
| { | |
| "/emails/email-1": { | |
| sections: [ | |
| { | |
| type: "text", | |
| title: "Product 1", | |
| text: [ | |
| { | |
| tag: "p", | |
| children: ["Email built with Val"], | |
| }, | |
| ], | |
| }, | |
| ], | |
| }, | |
| }, | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment