blob: e225608f3fd5e7017541e53530ed805324dc2ed7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { ExpandableWidget, List } from '@components/WidgetParts';
import { TopicPreview } from '@ts/types/taxonomies';
import Link from 'next/link';
import { useIntl } from 'react-intl';
const RelatedTopics = ({ topics }: { topics: TopicPreview[] }) => {
const intl = useIntl();
const sortedTopics = [...topics].sort((a, b) =>
a.title.localeCompare(b.title)
);
const topicsList = sortedTopics.map((topic) => {
return (
<li key={topic.databaseId}>
<Link href={`/sujet/${topic.slug}`}>
<a>{topic.title}</a>
</Link>
</li>
);
});
return (
<ExpandableWidget
title={intl.formatMessage(
{
defaultMessage:
'{topicsCount, plural, =0 {Related topics} one {Related topic} other {Related topics}}',
description: 'RelatedTopics: widget title',
},
{ topicsCount: topicsList.length }
)}
withBorders={true}
>
<noscript>
{intl.formatMessage({
defaultMessage: 'Javascript is required to load the topics.',
description: 'RelatedTopics: noscript tag',
})}
</noscript>
<List items={topicsList} />
</ExpandableWidget>
);
};
export default RelatedTopics;
|