Next.js 16 + TypeScript + Tailwind v4 app with a YAML-driven config system: schema validation (zod), .env interpolation, and a widget registry rendering bookmark/search/group widgets. CSS custom properties (--pn-*) drive theming and are overridable from config.yml's theme.variables. Config load errors surface as a readable error page instead of crashing the app. Hot reload, docker/system/http collectors, and the WebSocket push layer land in later milestones per the approved plan.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { z } from "zod";
|
|
|
|
const searchEngineSchema = z.enum(["duckduckgo", "google", "bing"]);
|
|
|
|
export const bookmarkWidgetSchema = z.object({
|
|
type: z.literal("bookmark"),
|
|
name: z.string(),
|
|
href: z.string().url(),
|
|
description: z.string().optional(),
|
|
});
|
|
|
|
export const searchWidgetSchema = z.object({
|
|
type: z.literal("search"),
|
|
engines: z.array(searchEngineSchema).min(1).default(["duckduckgo"]),
|
|
defaultEngine: searchEngineSchema.optional(),
|
|
});
|
|
|
|
export const widgetSchema = z.discriminatedUnion("type", [
|
|
bookmarkWidgetSchema,
|
|
searchWidgetSchema,
|
|
]);
|
|
|
|
export const groupSchema = z.object({
|
|
name: z.string(),
|
|
widgets: z.array(widgetSchema),
|
|
});
|
|
|
|
export const themeSchema = z
|
|
.object({
|
|
mode: z.enum(["dark", "light", "auto"]).default("dark"),
|
|
variables: z.record(z.string(), z.string()).default({}),
|
|
customCssPath: z.string().optional(),
|
|
})
|
|
.default({ mode: "dark", variables: {} });
|
|
|
|
export const settingsSchema = z
|
|
.object({
|
|
title: z.string().default("PulseNode"),
|
|
})
|
|
.default({ title: "PulseNode" });
|
|
|
|
export const configSchema = z.object({
|
|
theme: themeSchema,
|
|
settings: settingsSchema,
|
|
groups: z.array(groupSchema).default([]),
|
|
});
|
|
|
|
export type Config = z.infer<typeof configSchema>;
|
|
export type Widget = z.infer<typeof widgetSchema>;
|
|
export type Group = z.infer<typeof groupSchema>;
|
|
export type SearchEngine = z.infer<typeof searchEngineSchema>;
|