2022-03-06 20:30:43 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { FaReddit } from 'react-icons/fa';
|
|
|
|
|
|
|
|
import { Card, Repeater, DedicatedAvailability } from '../core';
|
|
|
|
|
2022-03-09 17:18:42 +01:00
|
|
|
const SubredditCard: React.FC<{ query: string }> = ({ query }) => {
|
2022-03-06 20:30:43 +01:00
|
|
|
const { t } = useTranslation();
|
2022-03-09 17:18:42 +01:00
|
|
|
const normalizedQuery = normalize(query, {
|
|
|
|
allowUnderscore: false,
|
|
|
|
});
|
|
|
|
const lowerCase = normalizedQuery.toLowerCase();
|
2022-03-06 20:30:43 +01:00
|
|
|
|
2022-03-09 17:18:42 +01:00
|
|
|
const names = [normalizedQuery];
|
2022-03-06 20:30:43 +01:00
|
|
|
const moreNames = [
|
|
|
|
`get${lowerCase}`,
|
|
|
|
`${lowerCase}-team`,
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card title={t('providers.reddit')}>
|
|
|
|
<Repeater items={names} moreItems={moreNames}>
|
|
|
|
{(name) => (
|
|
|
|
<DedicatedAvailability
|
|
|
|
name={name}
|
|
|
|
service="reddit" // route to http://namae.dev/api/services/reddit/<query> which is /api/services/reddit/[query].ts on GitHub
|
|
|
|
link={`https://reddit.com/r/${name}`}
|
|
|
|
prefix="reddit.com/r/"
|
|
|
|
icon={<FaReddit />}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Repeater>
|
|
|
|
</Card>
|
|
|
|
);
|
2022-03-06 20:36:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default SubredditCard;
|