1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-21 18:55:36 +02:00

feat(ui): show website favicon in entry list for webpage entries

This commit is contained in:
TheGeneralist 2026-06-24 19:16:21 +02:00
parent 1206d7103d
commit 1239ad9f34
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
3 changed files with 27 additions and 3 deletions

View file

@ -164,6 +164,7 @@ export default function App() {
entries={entries}
selectedEntryUid={selectedEntryUid}
onSelectEntry={selectEntry}
archiveId={archiveId}
tagFilter={tagFilter}
onClearTagFilter={handleClearTagFilter}
searchQuery={searchQuery}

View file

@ -1,6 +1,6 @@
import EntryRow from './EntryRow';
export default function EntriesView({ entries, selectedEntryUid, onSelectEntry }) {
export default function EntriesView({ entries, selectedEntryUid, onSelectEntry, archiveId }) {
return (
<section id="archive-view" className="view is-active">
<div className="entry-table">
@ -16,6 +16,7 @@ export default function EntriesView({ entries, selectedEntryUid, onSelectEntry }
<EntryRow
key={entry.entry_uid}
entry={entry}
archiveId={archiveId}
isSelected={entry.entry_uid === selectedEntryUid}
onSelect={() => onSelectEntry(entry)}
/>

View file

@ -1,6 +1,28 @@
import { useState } from 'react';
import { formatTimestamp, formatBytes, valueText, sourceIconSvg } from '../utils';
export default function EntryRow({ entry, isSelected, onSelect }) {
export default function EntryRow({ entry, archiveId, isSelected, onSelect }) {
const [favFailed, setFavFailed] = useState(false);
const showFavicon =
entry.source_kind === 'web' &&
entry.entity_kind === 'page' &&
entry.has_favicon &&
archiveId &&
!favFailed;
const icon = showFavicon ? (
<img
src={`/api/archives/${archiveId}/entries/${entry.entry_uid}/favicon`}
width="16"
height="16"
alt=""
onError={() => setFavFailed(true)}
style={{ objectFit: 'contain' }}
/>
) : (
<span dangerouslySetInnerHTML={{ __html: sourceIconSvg(entry.source_kind) }} />
);
return (
<div
className={isSelected ? 'is-selected' : undefined}
@ -11,7 +33,7 @@ export default function EntryRow({ entry, isSelected, onSelect }) {
>
<div className="col-added">{formatTimestamp(entry.archived_at)}</div>
<div className="col-title">
<span className="source-icon" dangerouslySetInnerHTML={{ __html: sourceIconSvg(entry.source_kind) }} />
<span className="source-icon">{icon}</span>
<span className="entry-title">{valueText(entry.title) || valueText(entry.entry_uid)}</span>
</div>
<div className="col-type">