Merge pull request #10 from stevedylandev/fix/opml-atom-import 6c42735f
fix: updated extractPostDate
Steve Simkins · 2025-12-01 15:22 5 file(s) · +16 −7
src/App.tsx +2 −2
140 140
							title: sanitizedPost.title,
141 141
							author: sanitizedPost.author || null,
142 142
							feedTitle: sanitizedFeed.title,
143 -
							publishedDate: extractPostDate(post),
143 +
							publishedDate: extractPostDate(post, isAtom),
144 144
							link: sanitizedPost.link,
145 145
							feedId: result.value.id,
146 146
							content: extractPostContent(post, sanitizedPost.link),
303 303
					title: sanitizedPost.title,
304 304
					author: sanitizedPost.author || null,
305 305
					feedTitle: sanitizedFeed.title,
306 -
					publishedDate: extractPostDate(post),
306 +
					publishedDate: extractPostDate(post, isAtom),
307 307
					link: sanitizedPost.link,
308 308
					feedId: result.value.id,
309 309
					content: extractPostContent(post, sanitizedPost.link),
src/components/add-feed-dialog.tsx +1 −1
132 132
					title: sanitizedPost.title,
133 133
					author: sanitizedPost.author || null,
134 134
					feedTitle: sanitizedFeed.title,
135 -
					publishedDate: extractPostDate(post),
135 +
					publishedDate: extractPostDate(post, isAtom),
136 136
					link: sanitizedPost.link,
137 137
					feedId: result.value.id,
138 138
					content: extractPostContent(post, sanitizedPost.link),
src/components/app-sidebar.tsx +1 −1
433 433
							title: post.title,
434 434
							author: extractPostAuthor(post, isAtom, feedData.title),
435 435
							feedTitle: feed.title,
436 -
							publishedDate: extractPostDate(post),
436 +
							publishedDate: extractPostDate(post, isAtom),
437 437
							link: postLink,
438 438
							feedId: feed.id,
439 439
							content: extractPostContent(post, postLink),
src/components/nav-user.tsx +1 −1
136 136
							title: post.title,
137 137
							author: extractPostAuthor(post, isAtom, feedData.title),
138 138
							feedTitle: feed.title,
139 -
							publishedDate: extractPostDate(post),
139 +
							publishedDate: extractPostDate(post, isAtom),
140 140
							link: postLink,
141 141
							feedId: result.value.id,
142 142
							content: extractPostContent(post, postLink),
src/lib/feed-operations.ts +11 −2
438 438
/**
439 439
 * Extracts published date from RSS or Atom post entry
440 440
 */
441 -
export function extractPostDate(post: any): string {
441 +
export function extractPostDate(post: any, isAtom?: boolean): string {
442 442
	try {
443 -
		const dateValue = post.pubDate || post.updated || post.published;
443 +
		let dateValue: any;
444 +
		
445 +
		if (isAtom) {
446 +
			// For Atom feeds, prioritize published date over updated date
447 +
			dateValue = post.published || post.updated;
448 +
		} else {
449 +
			// For RSS feeds, use pubDate first, then fall back to Atom fields
450 +
			dateValue = post.pubDate || post.published || post.updated;
451 +
		}
452 +
		
444 453
		if (!dateValue) {
445 454
			return new Date().toISOString(); // Use current date if no date found
446 455
		}