/** * 将 Directus 返回的 Solution 数据转换为 SolutionView 视图模型 * * @param raw: 原始的 Solution 数据 * @returns 转换后的 SolutionView 对象 * * --- * * @example * const view = toSolutionView(rawSolution); */ export function toSolutionView(raw: Solution): SolutionView { const trans = raw.translations?.[0]; return { id: raw.id.toString(), title: trans?.title ?? '', summary: trans?.summary ?? '', content: trans?.content ?? '', createAt: raw?.create_at ?? '', }; }