feat: sites and authors integration into existing screens (& formated all frontend files kinda accidentally)

This commit is contained in:
Florian Sylvain committed 2026-10-15 05:25:44 +02:00
1 parent 3d81d2c717
commit 6b8990c55e
239 files changed
+9194 -1354

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { t } from '@/i18n'
import type { Byline } from '@/lib/articleTypes'
export function authorsSummary(authors: Byline[]) {
const [first] = authors
if (!first) {
return t('No authors')
}
return authors.length === 1 ? first.name : t('{0} +{1}', [first.name, authors.length - 1])
}
export function metaSummary(authors: Byline[], siteName: string | null) {
const summary = authorsSummary(authors)
return siteName ? t('{0} · {1}', [siteName, summary]) : summary
}
export function moveItem<T>(items: T[], from: number, to: number) {
if (from === to || from < 0 || to < 0 || from >= items.length || to >= items.length) {
return items
}
const next = [...items]
const [moved] = next.splice(from, 1)
next.splice(to, 0, moved!)
return next
}
export function insertionTarget(from: number, gap: number) {
return gap > from ? gap - 1 : gap
}
export function sameIds(left: Byline[], right: Byline[]) {
return left.length === right.length && left.every((item, index) => item.id === right[index]?.id)
}
export function toBylines(authors: Byline[]): Byline[] {
return authors.map(({ id, name, slug }) => ({ id, name, slug }))
}