Skip to content

Commit be1a3f6

Browse files
committed
fix: in preview tab links, fallback to domain when not handled + fix framalibre links
1 parent a5bbe42 commit be1a3f6

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

web/src/ui/pages/softwareDetails/PreviewTab.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ export const PreviewTab = (props: Props) => {
356356
{usefulLinks.map(identifier => {
357357
const url = identifier.url ?? identifier.subjectOf?.url;
358358

359+
if (!url) return null;
360+
359361
return (
360362
<LogoURLButton
361363
key={url?.toString()}

web/src/ui/shared/AuthorCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export function AuthorCard(props: Props) {
9292
{author.identifiers?.map(identifier => {
9393
return (
9494
<div className={classes.externalLinkButtons}>
95-
<LogoURLButton url={identifier.url} labelFromURL={true} />
95+
<LogoURLButton
96+
url={identifier.url ?? identifier.subjectOf?.url}
97+
labelFromURL={true}
98+
/>
9699
</div>
97100
);
98101
})}

web/src/ui/shared/LogoURLButton.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ const resolveLogoFromURL = (
6666
return resolveLogoFromType("CNLL");
6767
}
6868

69+
if (urlString.includes("framalibre")) {
70+
return resolveLogoFromType("FramaLibre");
71+
}
72+
6973
return {
7074
URLlogo: undefined,
71-
textFromURL: undefined
75+
textFromURL: new URL(urlString).hostname.replace("www.", "")
7276
};
7377
};
7478

@@ -167,17 +171,15 @@ export function LogoURLButton(props: Props) {
167171
iconId
168172
} = props;
169173

174+
if (!url) return null;
175+
170176
const urlString = typeof url === "string" ? url : url?.href;
171177

172178
const { classes } = useStyles();
173179

174180
const getUrlMetadata = () => {
175181
if (type) return resolveLogoFromType(type);
176-
if (url) return resolveLogoFromURL(url);
177-
return {
178-
URLlogo: undefined,
179-
textFromURL: undefined
180-
};
182+
return resolveLogoFromURL(url);
181183
};
182184

183185
const { URLlogo, textFromURL } = getUrlMetadata();
@@ -211,16 +213,3 @@ const useStyles = tss.withName({ LogoURLButton }).create({
211213
marginLeft: "7px"
212214
}
213215
});
214-
215-
const yo = [
216-
{
217-
"@type": "PropertyValue",
218-
value: "93",
219-
subjectOf: {
220-
url: "https://cnll.fr/",
221-
name: "Union des entreprises du logiciel libre et du numérique ouvert",
222-
"@type": "Website",
223-
additionalType: "cnll"
224-
}
225-
}
226-
];

0 commit comments

Comments
 (0)