Improve tag handling

This commit is contained in:
Weves
2024-02-27 15:41:36 -08:00
committed by Chris Weaver
parent 02d81c4be5
commit 78f2e07d23
2 changed files with 40 additions and 6 deletions

View File

@@ -110,6 +110,9 @@ export function DocumentMetadataBlock({
}: {
document: DanswerDocument;
}) {
// don't display super long tags, as they are ugly
const MAXIMUM_TAG_LENGTH = 40;
return (
<div className="flex flex-wrap gap-1">
{document.updated_at && (
@@ -120,11 +123,19 @@ export function DocumentMetadataBlock({
{Object.entries(document.metadata).length > 0 && (
<>
<div className="pl-1 border-l border-border" />
{Object.entries(document.metadata).map(([key, value]) => {
return (
<MetadataBadge key={key} icon={FiTag} value={`${key}=${value}`} />
);
})}
{Object.entries(document.metadata)
.filter(
([key, value]) => (key + value).length <= MAXIMUM_TAG_LENGTH
)
.map(([key, value]) => {
return (
<MetadataBadge
key={key}
icon={FiTag}
value={`${key}=${value}`}
/>
);
})}
</>
)}
</div>