Skip to content

Instantly share code, notes, and snippets.

@freekh
Last active March 25, 2026 19:20
Show Gist options
  • Select an option

  • Save freekh/d0eedc92479b681180eaeab072c4486b to your computer and use it in GitHub Desktop.

Select an option

Save freekh/d0eedc92479b681180eaeab072c4486b to your computer and use it in GitHub Desktop.
Val Email Page
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