feat(bookmarks): classify URLs by type and adjust action buttons

- Add URL classification system (article, video, youtube, image)
- Classify based on domain (youtube) and file extensions
- Update button text: 'READ NOW' for articles, 'WATCH NOW' for videos, 'VIEW NOW' for images
- Update icons: faBookOpen for articles, faPlay for videos, faEye for images
- Apply classification to both individual URL buttons and main action button
This commit is contained in:
Gigi
2025-10-03 01:53:49 +02:00
parent 85695b5934
commit 448c4dac1c
2 changed files with 73 additions and 23 deletions

View File

@@ -10,4 +10,34 @@ export const extractNprofilePubkeys = (content: string): string[] => {
return Array.from(unique)
}
export type UrlType = 'video' | 'image' | 'youtube' | 'article'
export interface UrlClassification {
type: UrlType
buttonText: string
}
export const classifyUrl = (url: string): UrlClassification => {
const urlLower = url.toLowerCase()
// Check for YouTube
if (urlLower.includes('youtube.com') || urlLower.includes('youtu.be')) {
return { type: 'youtube', buttonText: 'WATCH NOW' }
}
// Check for video extensions
const videoExtensions = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.mkv', '.m4v']
if (videoExtensions.some(ext => urlLower.includes(ext))) {
return { type: 'video', buttonText: 'WATCH NOW' }
}
// Check for image extensions
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp', '.ico']
if (imageExtensions.some(ext => urlLower.includes(ext))) {
return { type: 'image', buttonText: 'VIEW NOW' }
}
// Default to article
return { type: 'article', buttonText: 'READ NOW' }
}