Update MessageBox.tsx

CTA link doc + web
This commit is contained in:
Lucas 2025-01-08 16:30:41 +01:00 committed by GitHub
parent 51de59b65c
commit b087f32690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,10 +54,16 @@ const MessageBox = ({
message.content.replace(
regex,
(_, number) => {
const url = message.sources?.[number - 1]?.metadata?.url || '';
// Extraire le nom de domaine sans l'extension
const sourceName = url.replace(/^(?:https?:\/\/)?(?:www\.)?([^./]+).*$/, '$1');
return `<a href="${url}" target="_blank" class="ml-2 px-3 py-1 text-xs bg-blue-500 hover:bg-blue-600 text-white rounded-md transition-colors duration-200 no-underline inline-flex items-center">${sourceName}</a>`;
const source = message.sources?.[number - 1];
const url = source?.metadata?.url || '';
const isDocument = source?.metadata?.isFile;
// Utiliser "Voir la source" pour les documents, sinon le nom de domaine
const linkText = isDocument
? "Voir la source"
: url.replace(/^(?:https?:\/\/)?(?:www\.)?([^./]+).*$/, '$1');
return `<a href="${url}" target="_blank" class="ml-2 px-3 py-1 text-xs bg-blue-500 hover:bg-blue-600 text-white rounded-md transition-colors duration-200 no-underline inline-flex items-center">${linkText}</a>`;
}
),
);