this repo has no description

fix: handle undefined publishDate to prevent Invalid time value crash

+10 -3
+4 -2
packages/cli/src/lib/atproto.ts
··· 245 245 config: PublisherConfig, 246 246 coverImage?: BlobObject, 247 247 ): Promise<string> { 248 - const publishDate = new Date(post.frontmatter.publishDate); 248 + const _d = new Date(post.frontmatter.publishDate ?? ""); 249 + const publishDate = isNaN(_d.getTime()) ? new Date() : _d; 249 250 const trimmedContent = post.content.trim(); 250 251 const textContent = getTextContent(post, config.textContentField); 251 252 const titleMatch = trimmedContent.match(/^# (.+)$/m); ··· 323 324 .pop()! 324 325 .replace(/\.pub$/, ""); 325 326 const finalPath = `/pub/${rkey}/${slugName}`; 326 - const publishDate = new Date(post.frontmatter.publishDate); 327 + const _d = new Date(post.frontmatter.publishDate ?? ""); 328 + const publishDate = isNaN(_d.getTime()) ? new Date() : _d; 327 329 const trimmedContent = post.content.trim(); 328 330 const textContent = getTextContent(post, config.textContentField); 329 331 const titleMatch = trimmedContent.match(/^# (.+)$/m);
+6 -1
packages/remanso-cli/src/lib/note.ts
··· 6 6 import { detectLanguage } from "./detect-languages"; 7 7 8 8 const LEXICON = "space.remanso.note"; 9 + 10 + function toISODate(value: string | undefined): string { 11 + const d = new Date(value ?? ""); 12 + return isNaN(d.getTime()) ? new Date().toISOString() : d.toISOString(); 13 + } 9 14 const MAX_CONTENT = 30000; 10 15 const MIN_CONTENT_FOR_TRANSLATION = 400; 11 16 ··· 197 202 post: BlogPost, 198 203 options: NoteOptions, 199 204 ): Promise<Record<string, unknown>> { 200 - const publishDate = new Date(post.frontmatter.publishDate).toISOString(); 205 + const publishDate = toISODate(post.frontmatter.publishDate); 201 206 const trimmedContent = post.content.trim(); 202 207 const titleMatch = trimmedContent.match(/^# (.+)$/m); 203 208 const title = titleMatch ? titleMatch[1] : post.frontmatter.title;