홈 페이지와 갤러리 페이지에서 사진 및 동영상만 표시되도록 개선

This commit is contained in:
static
2025-12-26 22:58:09 +09:00
parent 6d02178c69
commit a1f30ee154
3 changed files with 30 additions and 11 deletions

View File

@@ -13,7 +13,9 @@
let { files, onFileClick }: Props = $props();
type FileEntry = { date?: Date; info: Writable<FileInfo | null> };
type FileEntry =
| { date?: undefined; contentType?: undefined; info: Writable<FileInfo | null> }
| { date: Date; contentType: string; info: Writable<FileInfo | null> };
type Row =
| { type: "header"; key: string; label: string }
| { type: "items"; key: string; items: FileEntry[] };
@@ -37,15 +39,28 @@
$effect(() => {
filesWithDate = files.map((file) => {
const { createdAt, lastModifiedAt } = get(file) ?? {};
return { date: createdAt ?? lastModifiedAt, info: file };
const info = get(file);
if (info) {
return {
date: info.createdAt ?? info.lastModifiedAt,
contentType: info.contentType,
info: file,
};
} else {
return { info: file };
}
});
const buildRows = () => {
const map = new Map<string, FileEntry[]>();
for (const file of filesWithDate) {
if (!file.date) continue;
if (
!file.date ||
!(file.contentType.startsWith("image/") || file.contentType.startsWith("video/"))
) {
continue;
}
const date = formatDateSortable(file.date);
const entries = map.get(date) ?? [];